effect
stringclasses
48 values
original_source_type
stringlengths
0
23k
opens_and_abbrevs
listlengths
2
92
isa_cross_project_example
bool
1 class
source_definition
stringlengths
9
57.9k
partial_definition
stringlengths
7
23.3k
is_div
bool
2 classes
is_type
null
is_proof
bool
2 classes
completed_definiton
stringlengths
1
250k
dependencies
dict
effect_flags
sequencelengths
0
2
ideal_premises
sequencelengths
0
236
mutual_with
sequencelengths
0
11
file_context
stringlengths
0
407k
interleaved
bool
1 class
is_simply_typed
bool
2 classes
file_name
stringlengths
5
48
vconfig
dict
is_simple_lemma
null
source_type
stringlengths
10
23k
proof_features
sequencelengths
0
1
name
stringlengths
8
95
source
dict
verbose_type
stringlengths
1
7.42k
source_range
dict
Prims.Tot
val liftM3 : ('a -> 'b -> 'c -> 'd) -> (tm 'a -> tm 'b -> tm 'c -> tm 'd)
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let liftM3 f x y z = let! xx = x in let! yy = y in let! zz = z in return (f xx yy zz)
val liftM3 : ('a -> 'b -> 'c -> 'd) -> (tm 'a -> tm 'b -> tm 'c -> tm 'd) let liftM3 f x y z =
false
null
false
let! xx = x in let! yy = y in let! zz = z in return (f xx yy zz)
{ "checked_file": "FStar.Reflection.V2.Arith.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ "total" ]
[ "FStar.Reflection.V2.Arith.tm", "FStar.Reflection.V2.Arith.op_let_Bang", "FStar.Reflection.V2.Arith.return" ]
[]
(* 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.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2) let eq e1 e2 = CompProp e1 C_Eq e2 let ne e1 e2 = CompProp e1 C_Ne e2 let gt e1 e2 = CompProp e1 C_Gt e2 let ge e1 e2 = CompProp (Plus (Lit 1) e1) C_Gt e2 (* Define a traversal monad! Makes exception handling and counter-keeping easy *) private let st = p:(nat * list term){fst p == List.Tot.Base.length (snd p)} private let tm a = st -> Tac (either string (a * st)) private let return (x:'a) : tm 'a = fun i -> Inr (x, i) private let (let!) (m : tm 'a) (f : 'a -> tm 'b) : tm 'b = fun i -> match m i with | Inr (x, j) -> f x j | s -> Inl (Inl?.v s) // why? To have a catch-all pattern and thus an easy WP val lift : ('a -> Tac 'b) -> ('a -> tm 'b) let lift f x st = Inr (f x, st) val liftM : ('a -> 'b) -> (tm 'a -> tm 'b) let liftM f x = let! xx = x in return (f xx) val liftM2 : ('a -> 'b -> 'c) -> (tm 'a -> tm 'b -> tm 'c) let liftM2 f x y = let! xx = x in let! yy = y in return (f xx yy) val liftM3 : ('a -> 'b -> 'c -> 'd) -> (tm 'a -> tm 'b -> tm 'c -> tm 'd)
false
false
FStar.Reflection.V2.Arith.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val liftM3 : ('a -> 'b -> 'c -> 'd) -> (tm 'a -> tm 'b -> tm 'c -> tm 'd)
[]
FStar.Reflection.V2.Arith.liftM3
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: (_: 'a -> _: 'b -> _: 'c -> 'd) -> _: FStar.Reflection.V2.Arith.tm 'a -> _: FStar.Reflection.V2.Arith.tm 'b -> _: FStar.Reflection.V2.Arith.tm 'c -> FStar.Reflection.V2.Arith.tm 'd
{ "end_col": 23, "end_line": 101, "start_col": 4, "start_line": 98 }
FStar.Tactics.Effect.Tac
val is_arith_prop : term -> st -> Tac (either string (prop * st))
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec is_arith_prop (t:term) = fun i -> (let! f = lift (fun t -> term_as_formula t) t in match f with | Comp (Eq _) l r -> liftM2 eq (is_arith_expr l) (is_arith_expr r) | Comp (BoolEq _) l r -> liftM2 eq (is_arith_expr l) (is_arith_expr r) | Comp Lt l r -> liftM2 lt (is_arith_expr l) (is_arith_expr r) | Comp Le l r -> liftM2 le (is_arith_expr l) (is_arith_expr r) | And l r -> liftM2 AndProp (is_arith_prop l) (is_arith_prop r) | Or l r -> liftM2 OrProp (is_arith_prop l) (is_arith_prop r) | _ -> let! s = lift term_to_string t in fail ("connector (" ^ s ^ ")")) i
val is_arith_prop : term -> st -> Tac (either string (prop * st)) let rec is_arith_prop (t: term) =
true
null
false
fun i -> (let! f = lift (fun t -> term_as_formula t) t in match f with | Comp (Eq _) l r -> liftM2 eq (is_arith_expr l) (is_arith_expr r) | Comp (BoolEq _) l r -> liftM2 eq (is_arith_expr l) (is_arith_expr r) | Comp Lt l r -> liftM2 lt (is_arith_expr l) (is_arith_expr r) | Comp Le l r -> liftM2 le (is_arith_expr l) (is_arith_expr r) | And l r -> liftM2 AndProp (is_arith_prop l) (is_arith_prop r) | Or l r -> liftM2 OrProp (is_arith_prop l) (is_arith_prop r) | _ -> let! s = lift term_to_string t in fail ("connector (" ^ s ^ ")")) i
{ "checked_file": "FStar.Reflection.V2.Arith.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[]
[ "FStar.Reflection.Types.term", "FStar.Reflection.V2.Arith.st", "FStar.Reflection.V2.Arith.op_let_Bang", "FStar.Reflection.V2.Formula.formula", "FStar.Reflection.V2.Arith.prop", "FStar.Reflection.V2.Arith.lift", "FStar.Tactics.NamedView.term", "FStar.Reflection.V2.Formula.term_as_formula", "FStar.Pervasives.Native.option", "FStar.Reflection.Types.typ", "FStar.Reflection.V2.Arith.liftM2", "FStar.Reflection.V2.Arith.expr", "FStar.Reflection.V2.Arith.eq", "FStar.Reflection.V2.Arith.is_arith_expr", "FStar.Reflection.V2.Arith.lt", "FStar.Reflection.V2.Arith.le", "FStar.Reflection.V2.Arith.AndProp", "FStar.Reflection.V2.Arith.is_arith_prop", "FStar.Reflection.V2.Arith.OrProp", "Prims.string", "FStar.Tactics.V2.Builtins.term_to_string", "FStar.Reflection.V2.Arith.fail", "Prims.op_Hat", "FStar.Reflection.V2.Arith.tm", "FStar.Pervasives.either", "FStar.Pervasives.Native.tuple2" ]
[]
(* 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.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2) let eq e1 e2 = CompProp e1 C_Eq e2 let ne e1 e2 = CompProp e1 C_Ne e2 let gt e1 e2 = CompProp e1 C_Gt e2 let ge e1 e2 = CompProp (Plus (Lit 1) e1) C_Gt e2 (* Define a traversal monad! Makes exception handling and counter-keeping easy *) private let st = p:(nat * list term){fst p == List.Tot.Base.length (snd p)} private let tm a = st -> Tac (either string (a * st)) private let return (x:'a) : tm 'a = fun i -> Inr (x, i) private let (let!) (m : tm 'a) (f : 'a -> tm 'b) : tm 'b = fun i -> match m i with | Inr (x, j) -> f x j | s -> Inl (Inl?.v s) // why? To have a catch-all pattern and thus an easy WP val lift : ('a -> Tac 'b) -> ('a -> tm 'b) let lift f x st = Inr (f x, st) val liftM : ('a -> 'b) -> (tm 'a -> tm 'b) let liftM f x = let! xx = x in return (f xx) val liftM2 : ('a -> 'b -> 'c) -> (tm 'a -> tm 'b -> tm 'c) let liftM2 f x y = let! xx = x in let! yy = y in return (f xx yy) val liftM3 : ('a -> 'b -> 'c -> 'd) -> (tm 'a -> tm 'b -> tm 'c -> tm 'd) let liftM3 f x y z = let! xx = x in let! yy = y in let! zz = z in return (f xx yy zz) private let rec find_idx (f : 'a -> Tac bool) (l : list 'a) : Tac (option ((n:nat{n < List.Tot.Base.length l}) * 'a)) = match l with | [] -> None | x::xs -> if f x then Some (0, x) else begin match find_idx f xs with | None -> None | Some (i, x) -> Some (i+1, x) end private let atom (t:term) : tm expr = fun (n, atoms) -> match find_idx (term_eq_old t) atoms with | None -> Inr (Atom n t, (n + 1, t::atoms)) | Some (i, t) -> Inr (Atom (n - 1 - i) t, (n, atoms)) private val fail : (#a:Type) -> string -> tm a private let fail #a s = fun i -> Inl s val as_arith_expr : term -> tm expr #push-options "--initial_fuel 4 --max_fuel 4" let rec as_arith_expr (t:term) = let hd, tl = collect_app_ln t in // Invoke [collect_app_order]: forall (arg, qual) ∈ tl, (arg, qual) << t collect_app_order t; // [precedes_fst_tl]: forall (arg, qual) ∈ tl, arg << t let precedes_fst_tl (arg: term) (q: aqualv) : Lemma (List.Tot.memP (arg, q) tl ==> arg << t) = let _: argv = arg, q in () in Classical.forall_intro_2 (precedes_fst_tl); match inspect_ln hd, tl with | Tv_FVar fv, [(e1, Q_Implicit); (e2, Q_Explicit) ; (e3, Q_Explicit)] -> let qn = inspect_fv fv in let e2' = as_arith_expr e2 in let e3' = as_arith_expr e3 in if qn = land_qn then liftM2 Land e2' e3' else if qn = lxor_qn then liftM2 Lxor e2' e3' else if qn = lor_qn then liftM2 Lor e2' e3' else if qn = shiftr_qn then liftM2 Shr e2' e3' else if qn = shiftl_qn then liftM2 Shl e2' e3' else if qn = udiv_qn then liftM2 Udiv e2' e3' else if qn = umod_qn then liftM2 Umod e2' e3' else if qn = mul_mod_qn then liftM2 MulMod e2' e3' else if qn = ladd_qn then liftM2 Ladd e2' e3' else if qn = lsub_qn then liftM2 Lsub e2' e3' else atom t | Tv_FVar fv, [(l, Q_Explicit); (r, Q_Explicit)] -> let qn = inspect_fv fv in // Have to go through hoops to get F* to typecheck this. // Maybe the do notation is twisting the terms somehow unexpected? let ll = as_arith_expr l in let rr = as_arith_expr r in if qn = add_qn then liftM2 Plus ll rr else if qn = minus_qn then liftM2 Minus ll rr else if qn = mult_qn then liftM2 Mult ll rr else if qn = mult'_qn then liftM2 Mult ll rr else atom t | Tv_FVar fv, [(l, Q_Implicit); (r, Q_Explicit)] -> let qn = inspect_fv fv in let ll = as_arith_expr l in let rr = as_arith_expr r in if qn = nat_bv_qn then liftM NatToBv rr else atom t | Tv_FVar fv, [(a, Q_Explicit)] -> let qn = inspect_fv fv in let aa = as_arith_expr a in if qn = neg_qn then liftM Neg aa else atom t | Tv_Const (C_Int i), _ -> return (Lit i) | _ -> atom t #pop-options val is_arith_expr : term -> tm expr let is_arith_expr t = let! a = as_arith_expr t in match a with | Atom _ t -> begin let hd, tl = collect_app_ref t in match inspect_ln hd, tl with | Tv_FVar _, [] | Tv_BVar _, [] | Tv_Var _, [] -> return a | _ -> let! s = lift term_to_string t in fail ("not an arithmetic expression: (" ^ s ^ ")") end | _ -> return a // Cannot use this... // val is_arith_prop : term -> tm prop
false
false
FStar.Reflection.V2.Arith.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val is_arith_prop : term -> st -> Tac (either string (prop * st))
[ "recursion" ]
FStar.Reflection.V2.Arith.is_arith_prop
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t: FStar.Reflection.Types.term -> i: FStar.Reflection.V2.Arith.st -> FStar.Tactics.Effect.Tac (FStar.Pervasives.either Prims.string (FStar.Reflection.V2.Arith.prop * FStar.Reflection.V2.Arith.st))
{ "end_col": 41, "end_line": 207, "start_col": 33, "start_line": 196 }
Prims.Tot
val is_arith_expr : term -> tm expr
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let is_arith_expr t = let! a = as_arith_expr t in match a with | Atom _ t -> begin let hd, tl = collect_app_ref t in match inspect_ln hd, tl with | Tv_FVar _, [] | Tv_BVar _, [] | Tv_Var _, [] -> return a | _ -> let! s = lift term_to_string t in fail ("not an arithmetic expression: (" ^ s ^ ")") end | _ -> return a
val is_arith_expr : term -> tm expr let is_arith_expr t =
false
null
false
let! a = as_arith_expr t in match a with | Atom _ t -> let hd, tl = collect_app_ref t in (match inspect_ln hd, tl with | Tv_FVar _, [] | Tv_BVar _, [] | Tv_Var _, [] -> return a | _ -> let! s = lift term_to_string t in fail ("not an arithmetic expression: (" ^ s ^ ")")) | _ -> return a
{ "checked_file": "FStar.Reflection.V2.Arith.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ "total" ]
[ "FStar.Reflection.Types.term", "FStar.Reflection.V2.Arith.op_let_Bang", "FStar.Reflection.V2.Arith.expr", "FStar.Reflection.V2.Arith.as_arith_expr", "Prims.nat", "Prims.l_or", "Prims.eq2", "Prims.precedes", "Prims.list", "FStar.Reflection.V2.Data.argv", "FStar.Pervasives.Native.fst", "FStar.Reflection.V2.Data.aqualv", "FStar.Pervasives.Native.Mktuple2", "FStar.Reflection.V2.Data.term_view", "FStar.Reflection.V2.Builtins.inspect_ln", "FStar.Reflection.Types.fv", "FStar.Reflection.V2.Arith.return", "FStar.Reflection.Types.bv", "FStar.Reflection.Types.namedv", "FStar.Pervasives.Native.tuple2", "Prims.string", "FStar.Reflection.V2.Arith.lift", "FStar.Tactics.V2.Builtins.term_to_string", "FStar.Reflection.V2.Arith.fail", "Prims.op_Hat", "FStar.Reflection.V2.Arith.tm", "FStar.Reflection.V2.Derived.Lemmas.collect_app_ref" ]
[]
(* 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.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2) let eq e1 e2 = CompProp e1 C_Eq e2 let ne e1 e2 = CompProp e1 C_Ne e2 let gt e1 e2 = CompProp e1 C_Gt e2 let ge e1 e2 = CompProp (Plus (Lit 1) e1) C_Gt e2 (* Define a traversal monad! Makes exception handling and counter-keeping easy *) private let st = p:(nat * list term){fst p == List.Tot.Base.length (snd p)} private let tm a = st -> Tac (either string (a * st)) private let return (x:'a) : tm 'a = fun i -> Inr (x, i) private let (let!) (m : tm 'a) (f : 'a -> tm 'b) : tm 'b = fun i -> match m i with | Inr (x, j) -> f x j | s -> Inl (Inl?.v s) // why? To have a catch-all pattern and thus an easy WP val lift : ('a -> Tac 'b) -> ('a -> tm 'b) let lift f x st = Inr (f x, st) val liftM : ('a -> 'b) -> (tm 'a -> tm 'b) let liftM f x = let! xx = x in return (f xx) val liftM2 : ('a -> 'b -> 'c) -> (tm 'a -> tm 'b -> tm 'c) let liftM2 f x y = let! xx = x in let! yy = y in return (f xx yy) val liftM3 : ('a -> 'b -> 'c -> 'd) -> (tm 'a -> tm 'b -> tm 'c -> tm 'd) let liftM3 f x y z = let! xx = x in let! yy = y in let! zz = z in return (f xx yy zz) private let rec find_idx (f : 'a -> Tac bool) (l : list 'a) : Tac (option ((n:nat{n < List.Tot.Base.length l}) * 'a)) = match l with | [] -> None | x::xs -> if f x then Some (0, x) else begin match find_idx f xs with | None -> None | Some (i, x) -> Some (i+1, x) end private let atom (t:term) : tm expr = fun (n, atoms) -> match find_idx (term_eq_old t) atoms with | None -> Inr (Atom n t, (n + 1, t::atoms)) | Some (i, t) -> Inr (Atom (n - 1 - i) t, (n, atoms)) private val fail : (#a:Type) -> string -> tm a private let fail #a s = fun i -> Inl s val as_arith_expr : term -> tm expr #push-options "--initial_fuel 4 --max_fuel 4" let rec as_arith_expr (t:term) = let hd, tl = collect_app_ln t in // Invoke [collect_app_order]: forall (arg, qual) ∈ tl, (arg, qual) << t collect_app_order t; // [precedes_fst_tl]: forall (arg, qual) ∈ tl, arg << t let precedes_fst_tl (arg: term) (q: aqualv) : Lemma (List.Tot.memP (arg, q) tl ==> arg << t) = let _: argv = arg, q in () in Classical.forall_intro_2 (precedes_fst_tl); match inspect_ln hd, tl with | Tv_FVar fv, [(e1, Q_Implicit); (e2, Q_Explicit) ; (e3, Q_Explicit)] -> let qn = inspect_fv fv in let e2' = as_arith_expr e2 in let e3' = as_arith_expr e3 in if qn = land_qn then liftM2 Land e2' e3' else if qn = lxor_qn then liftM2 Lxor e2' e3' else if qn = lor_qn then liftM2 Lor e2' e3' else if qn = shiftr_qn then liftM2 Shr e2' e3' else if qn = shiftl_qn then liftM2 Shl e2' e3' else if qn = udiv_qn then liftM2 Udiv e2' e3' else if qn = umod_qn then liftM2 Umod e2' e3' else if qn = mul_mod_qn then liftM2 MulMod e2' e3' else if qn = ladd_qn then liftM2 Ladd e2' e3' else if qn = lsub_qn then liftM2 Lsub e2' e3' else atom t | Tv_FVar fv, [(l, Q_Explicit); (r, Q_Explicit)] -> let qn = inspect_fv fv in // Have to go through hoops to get F* to typecheck this. // Maybe the do notation is twisting the terms somehow unexpected? let ll = as_arith_expr l in let rr = as_arith_expr r in if qn = add_qn then liftM2 Plus ll rr else if qn = minus_qn then liftM2 Minus ll rr else if qn = mult_qn then liftM2 Mult ll rr else if qn = mult'_qn then liftM2 Mult ll rr else atom t | Tv_FVar fv, [(l, Q_Implicit); (r, Q_Explicit)] -> let qn = inspect_fv fv in let ll = as_arith_expr l in let rr = as_arith_expr r in if qn = nat_bv_qn then liftM NatToBv rr else atom t | Tv_FVar fv, [(a, Q_Explicit)] -> let qn = inspect_fv fv in let aa = as_arith_expr a in if qn = neg_qn then liftM Neg aa else atom t | Tv_Const (C_Int i), _ -> return (Lit i) | _ -> atom t #pop-options val is_arith_expr : term -> tm expr
false
true
FStar.Reflection.V2.Arith.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val is_arith_expr : term -> tm expr
[]
FStar.Reflection.V2.Arith.is_arith_expr
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t: FStar.Reflection.Types.term -> FStar.Reflection.V2.Arith.tm FStar.Reflection.V2.Arith.expr
{ "end_col": 17, "end_line": 191, "start_col": 2, "start_line": 180 }
Prims.Tot
val op_let_Bang (m: tm 'a) (f: ('a -> tm 'b)) : tm 'b
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let (let!) (m : tm 'a) (f : 'a -> tm 'b) : tm 'b = fun i -> match m i with | Inr (x, j) -> f x j | s -> Inl (Inl?.v s)
val op_let_Bang (m: tm 'a) (f: ('a -> tm 'b)) : tm 'b let op_let_Bang (m: tm 'a) (f: ('a -> tm 'b)) : tm 'b =
false
null
false
fun i -> match m i with | Inr (x, j) -> f x j | s -> Inl (Inl?.v s)
{ "checked_file": "FStar.Reflection.V2.Arith.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ "total" ]
[ "FStar.Reflection.V2.Arith.tm", "FStar.Reflection.V2.Arith.st", "FStar.Pervasives.either", "Prims.string", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Inl", "FStar.Pervasives.__proj__Inl__item__v" ]
[]
(* 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.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2) let eq e1 e2 = CompProp e1 C_Eq e2 let ne e1 e2 = CompProp e1 C_Ne e2 let gt e1 e2 = CompProp e1 C_Gt e2 let ge e1 e2 = CompProp (Plus (Lit 1) e1) C_Gt e2 (* Define a traversal monad! Makes exception handling and counter-keeping easy *) private let st = p:(nat * list term){fst p == List.Tot.Base.length (snd p)} private let tm a = st -> Tac (either string (a * st)) private let return (x:'a) : tm 'a = fun i -> Inr (x, i)
false
false
FStar.Reflection.V2.Arith.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val op_let_Bang (m: tm 'a) (f: ('a -> tm 'b)) : tm 'b
[]
FStar.Reflection.V2.Arith.op_let_Bang
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
m: FStar.Reflection.V2.Arith.tm 'a -> f: (_: 'a -> FStar.Reflection.V2.Arith.tm 'b) -> FStar.Reflection.V2.Arith.tm 'b
{ "end_col": 34, "end_line": 79, "start_col": 4, "start_line": 77 }
Prims.Tot
val compare_expr (e1 e2: expr) : O.order
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec compare_expr (e1 e2 : expr) : O.order = match e1, e2 with | Lit i, Lit j -> O.compare_int i j | Atom _ t, Atom _ s -> compare_term t s | Plus l1 l2, Plus r1 r2 | Minus l1 l2, Minus r1 r2 | Mult l1 l2, Mult r1 r2 -> O.lex (compare_expr l1 r1) (fun () -> compare_expr l2 r2) | Neg e1, Neg e2 -> compare_expr e1 e2 | Lit _, _ -> O.Lt | _, Lit _ -> O.Gt | Atom _ _, _ -> O.Lt | _, Atom _ _ -> O.Gt | Plus _ _, _ -> O.Lt | _, Plus _ _ -> O.Gt | Mult _ _, _ -> O.Lt | _, Mult _ _ -> O.Gt | Neg _, _ -> O.Lt | _, Neg _ -> O.Gt | _ -> O.Gt
val compare_expr (e1 e2: expr) : O.order let rec compare_expr (e1 e2: expr) : O.order =
false
null
false
match e1, e2 with | Lit i, Lit j -> O.compare_int i j | Atom _ t, Atom _ s -> compare_term t s | Plus l1 l2, Plus r1 r2 | Minus l1 l2, Minus r1 r2 | Mult l1 l2, Mult r1 r2 -> O.lex (compare_expr l1 r1) (fun () -> compare_expr l2 r2) | Neg e1, Neg e2 -> compare_expr e1 e2 | Lit _, _ -> O.Lt | _, Lit _ -> O.Gt | Atom _ _, _ -> O.Lt | _, Atom _ _ -> O.Gt | Plus _ _, _ -> O.Lt | _, Plus _ _ -> O.Gt | Mult _ _, _ -> O.Lt | _, Mult _ _ -> O.Gt | Neg _, _ -> O.Lt | _, Neg _ -> O.Gt | _ -> O.Gt
{ "checked_file": "FStar.Reflection.V2.Arith.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ "total" ]
[ "FStar.Reflection.V2.Arith.expr", "FStar.Pervasives.Native.Mktuple2", "Prims.int", "FStar.Order.compare_int", "Prims.nat", "FStar.Reflection.Types.term", "FStar.Reflection.V2.Compare.compare_term", "FStar.Order.lex", "FStar.Reflection.V2.Arith.compare_expr", "Prims.unit", "FStar.Order.order", "FStar.Order.Lt", "FStar.Order.Gt", "FStar.Pervasives.Native.tuple2" ]
[]
(* 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.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2) let eq e1 e2 = CompProp e1 C_Eq e2 let ne e1 e2 = CompProp e1 C_Ne e2 let gt e1 e2 = CompProp e1 C_Gt e2 let ge e1 e2 = CompProp (Plus (Lit 1) e1) C_Gt e2 (* Define a traversal monad! Makes exception handling and counter-keeping easy *) private let st = p:(nat * list term){fst p == List.Tot.Base.length (snd p)} private let tm a = st -> Tac (either string (a * st)) private let return (x:'a) : tm 'a = fun i -> Inr (x, i) private let (let!) (m : tm 'a) (f : 'a -> tm 'b) : tm 'b = fun i -> match m i with | Inr (x, j) -> f x j | s -> Inl (Inl?.v s) // why? To have a catch-all pattern and thus an easy WP val lift : ('a -> Tac 'b) -> ('a -> tm 'b) let lift f x st = Inr (f x, st) val liftM : ('a -> 'b) -> (tm 'a -> tm 'b) let liftM f x = let! xx = x in return (f xx) val liftM2 : ('a -> 'b -> 'c) -> (tm 'a -> tm 'b -> tm 'c) let liftM2 f x y = let! xx = x in let! yy = y in return (f xx yy) val liftM3 : ('a -> 'b -> 'c -> 'd) -> (tm 'a -> tm 'b -> tm 'c -> tm 'd) let liftM3 f x y z = let! xx = x in let! yy = y in let! zz = z in return (f xx yy zz) private let rec find_idx (f : 'a -> Tac bool) (l : list 'a) : Tac (option ((n:nat{n < List.Tot.Base.length l}) * 'a)) = match l with | [] -> None | x::xs -> if f x then Some (0, x) else begin match find_idx f xs with | None -> None | Some (i, x) -> Some (i+1, x) end private let atom (t:term) : tm expr = fun (n, atoms) -> match find_idx (term_eq_old t) atoms with | None -> Inr (Atom n t, (n + 1, t::atoms)) | Some (i, t) -> Inr (Atom (n - 1 - i) t, (n, atoms)) private val fail : (#a:Type) -> string -> tm a private let fail #a s = fun i -> Inl s val as_arith_expr : term -> tm expr #push-options "--initial_fuel 4 --max_fuel 4" let rec as_arith_expr (t:term) = let hd, tl = collect_app_ln t in // Invoke [collect_app_order]: forall (arg, qual) ∈ tl, (arg, qual) << t collect_app_order t; // [precedes_fst_tl]: forall (arg, qual) ∈ tl, arg << t let precedes_fst_tl (arg: term) (q: aqualv) : Lemma (List.Tot.memP (arg, q) tl ==> arg << t) = let _: argv = arg, q in () in Classical.forall_intro_2 (precedes_fst_tl); match inspect_ln hd, tl with | Tv_FVar fv, [(e1, Q_Implicit); (e2, Q_Explicit) ; (e3, Q_Explicit)] -> let qn = inspect_fv fv in let e2' = as_arith_expr e2 in let e3' = as_arith_expr e3 in if qn = land_qn then liftM2 Land e2' e3' else if qn = lxor_qn then liftM2 Lxor e2' e3' else if qn = lor_qn then liftM2 Lor e2' e3' else if qn = shiftr_qn then liftM2 Shr e2' e3' else if qn = shiftl_qn then liftM2 Shl e2' e3' else if qn = udiv_qn then liftM2 Udiv e2' e3' else if qn = umod_qn then liftM2 Umod e2' e3' else if qn = mul_mod_qn then liftM2 MulMod e2' e3' else if qn = ladd_qn then liftM2 Ladd e2' e3' else if qn = lsub_qn then liftM2 Lsub e2' e3' else atom t | Tv_FVar fv, [(l, Q_Explicit); (r, Q_Explicit)] -> let qn = inspect_fv fv in // Have to go through hoops to get F* to typecheck this. // Maybe the do notation is twisting the terms somehow unexpected? let ll = as_arith_expr l in let rr = as_arith_expr r in if qn = add_qn then liftM2 Plus ll rr else if qn = minus_qn then liftM2 Minus ll rr else if qn = mult_qn then liftM2 Mult ll rr else if qn = mult'_qn then liftM2 Mult ll rr else atom t | Tv_FVar fv, [(l, Q_Implicit); (r, Q_Explicit)] -> let qn = inspect_fv fv in let ll = as_arith_expr l in let rr = as_arith_expr r in if qn = nat_bv_qn then liftM NatToBv rr else atom t | Tv_FVar fv, [(a, Q_Explicit)] -> let qn = inspect_fv fv in let aa = as_arith_expr a in if qn = neg_qn then liftM Neg aa else atom t | Tv_Const (C_Int i), _ -> return (Lit i) | _ -> atom t #pop-options val is_arith_expr : term -> tm expr let is_arith_expr t = let! a = as_arith_expr t in match a with | Atom _ t -> begin let hd, tl = collect_app_ref t in match inspect_ln hd, tl with | Tv_FVar _, [] | Tv_BVar _, [] | Tv_Var _, [] -> return a | _ -> let! s = lift term_to_string t in fail ("not an arithmetic expression: (" ^ s ^ ")") end | _ -> return a // Cannot use this... // val is_arith_prop : term -> tm prop val is_arith_prop : term -> st -> Tac (either string (prop * st)) let rec is_arith_prop (t:term) = fun i -> (let! f = lift (fun t -> term_as_formula t) t in match f with | Comp (Eq _) l r -> liftM2 eq (is_arith_expr l) (is_arith_expr r) | Comp (BoolEq _) l r -> liftM2 eq (is_arith_expr l) (is_arith_expr r) | Comp Lt l r -> liftM2 lt (is_arith_expr l) (is_arith_expr r) | Comp Le l r -> liftM2 le (is_arith_expr l) (is_arith_expr r) | And l r -> liftM2 AndProp (is_arith_prop l) (is_arith_prop r) | Or l r -> liftM2 OrProp (is_arith_prop l) (is_arith_prop r) | _ -> let! s = lift term_to_string t in fail ("connector (" ^ s ^ ")")) i // Run the monadic computations, disregard the counter let run_tm (m : tm 'a) : Tac (either string 'a) = match m (0, []) with | Inr (x, _) -> Inr x | s -> Inl (Inl?.v s) // why? To have a catch-all pattern and thus an easy WP let rec expr_to_string (e:expr) : string = match e with | Atom i _ -> "a"^(string_of_int i) | Lit i -> string_of_int i | Plus l r -> "(" ^ (expr_to_string l) ^ " + " ^ (expr_to_string r) ^ ")" | Minus l r -> "(" ^ (expr_to_string l) ^ " - " ^ (expr_to_string r) ^ ")" | Mult l r -> "(" ^ (expr_to_string l) ^ " * " ^ (expr_to_string r) ^ ")" | Neg l -> "(- " ^ (expr_to_string l) ^ ")" | Land l r -> "(" ^ (expr_to_string l) ^ " & " ^ (expr_to_string r) ^ ")" | Lor l r -> "(" ^ (expr_to_string l) ^ " | " ^ (expr_to_string r) ^ ")" | Lxor l r -> "(" ^ (expr_to_string l) ^ " ^ " ^ (expr_to_string r) ^ ")" | Ladd l r -> "(" ^ (expr_to_string l) ^ " >> " ^ (expr_to_string r) ^ ")" | Lsub l r -> "(" ^ (expr_to_string l) ^ " >> " ^ (expr_to_string r) ^ ")" | Shl l r -> "(" ^ (expr_to_string l) ^ " << " ^ (expr_to_string r) ^ ")" | Shr l r -> "(" ^ (expr_to_string l) ^ " >> " ^ (expr_to_string r) ^ ")" | NatToBv l -> "(" ^ "to_vec " ^ (expr_to_string l) ^ ")" | Udiv l r -> "(" ^ (expr_to_string l) ^ " / " ^ (expr_to_string r) ^ ")" | Umod l r -> "(" ^ (expr_to_string l) ^ " % " ^ (expr_to_string r) ^ ")" | MulMod l r -> "(" ^ (expr_to_string l) ^ " ** " ^ (expr_to_string r) ^ ")"
false
true
FStar.Reflection.V2.Arith.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val compare_expr (e1 e2: expr) : O.order
[ "recursion" ]
FStar.Reflection.V2.Arith.compare_expr
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
e1: FStar.Reflection.V2.Arith.expr -> e2: FStar.Reflection.V2.Arith.expr -> FStar.Order.order
{ "end_col": 15, "end_line": 249, "start_col": 4, "start_line": 237 }
Prims.Tot
val atom (t: term) : tm expr
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let atom (t:term) : tm expr = fun (n, atoms) -> match find_idx (term_eq_old t) atoms with | None -> Inr (Atom n t, (n + 1, t::atoms)) | Some (i, t) -> Inr (Atom (n - 1 - i) t, (n, atoms))
val atom (t: term) : tm expr let atom (t: term) : tm expr =
false
null
false
fun (n, atoms) -> match find_idx (term_eq_old t) atoms with | None -> Inr (Atom n t, (n + 1, t :: atoms)) | Some (i, t) -> Inr (Atom (n - 1 - i) t, (n, atoms))
{ "checked_file": "FStar.Reflection.V2.Arith.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ "total" ]
[ "FStar.Reflection.Types.term", "FStar.Reflection.V2.Arith.st", "Prims.nat", "Prims.list", "FStar.Pervasives.Inr", "Prims.string", "FStar.Pervasives.Native.tuple2", "FStar.Reflection.V2.Arith.expr", "FStar.Pervasives.Native.Mktuple2", "FStar.Reflection.V2.Arith.Atom", "Prims.op_Addition", "Prims.Cons", "Prims.b2t", "Prims.op_LessThan", "FStar.List.Tot.Base.length", "Prims.op_Subtraction", "FStar.Pervasives.either", "FStar.Pervasives.Native.option", "FStar.Reflection.V2.Arith.find_idx", "FStar.Tactics.V2.Builtins.term_eq_old", "FStar.Reflection.V2.Arith.tm" ]
[]
(* 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.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2) let eq e1 e2 = CompProp e1 C_Eq e2 let ne e1 e2 = CompProp e1 C_Ne e2 let gt e1 e2 = CompProp e1 C_Gt e2 let ge e1 e2 = CompProp (Plus (Lit 1) e1) C_Gt e2 (* Define a traversal monad! Makes exception handling and counter-keeping easy *) private let st = p:(nat * list term){fst p == List.Tot.Base.length (snd p)} private let tm a = st -> Tac (either string (a * st)) private let return (x:'a) : tm 'a = fun i -> Inr (x, i) private let (let!) (m : tm 'a) (f : 'a -> tm 'b) : tm 'b = fun i -> match m i with | Inr (x, j) -> f x j | s -> Inl (Inl?.v s) // why? To have a catch-all pattern and thus an easy WP val lift : ('a -> Tac 'b) -> ('a -> tm 'b) let lift f x st = Inr (f x, st) val liftM : ('a -> 'b) -> (tm 'a -> tm 'b) let liftM f x = let! xx = x in return (f xx) val liftM2 : ('a -> 'b -> 'c) -> (tm 'a -> tm 'b -> tm 'c) let liftM2 f x y = let! xx = x in let! yy = y in return (f xx yy) val liftM3 : ('a -> 'b -> 'c -> 'd) -> (tm 'a -> tm 'b -> tm 'c -> tm 'd) let liftM3 f x y z = let! xx = x in let! yy = y in let! zz = z in return (f xx yy zz) private let rec find_idx (f : 'a -> Tac bool) (l : list 'a) : Tac (option ((n:nat{n < List.Tot.Base.length l}) * 'a)) = match l with | [] -> None | x::xs -> if f x then Some (0, x) else begin match find_idx f xs with | None -> None | Some (i, x) -> Some (i+1, x) end
false
true
FStar.Reflection.V2.Arith.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val atom (t: term) : tm expr
[]
FStar.Reflection.V2.Arith.atom
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t: FStar.Reflection.Types.term -> FStar.Reflection.V2.Arith.tm FStar.Reflection.V2.Arith.expr
{ "end_col": 57, "end_line": 118, "start_col": 38, "start_line": 115 }
FStar.Tactics.Effect.Tac
val run_tm (m: tm 'a) : Tac (either string 'a)
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let run_tm (m : tm 'a) : Tac (either string 'a) = match m (0, []) with | Inr (x, _) -> Inr x | s -> Inl (Inl?.v s)
val run_tm (m: tm 'a) : Tac (either string 'a) let run_tm (m: tm 'a) : Tac (either string 'a) =
true
null
false
match m (0, []) with | Inr (x, _) -> Inr x | s -> Inl (Inl?.v s)
{ "checked_file": "FStar.Reflection.V2.Arith.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[]
[ "FStar.Reflection.V2.Arith.tm", "FStar.Reflection.V2.Arith.st", "FStar.Pervasives.Inr", "Prims.string", "FStar.Pervasives.either", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Inl", "FStar.Pervasives.__proj__Inl__item__v", "FStar.Pervasives.Native.Mktuple2", "Prims.nat", "Prims.list", "FStar.Reflection.Types.term", "Prims.Nil" ]
[]
(* 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.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2) let eq e1 e2 = CompProp e1 C_Eq e2 let ne e1 e2 = CompProp e1 C_Ne e2 let gt e1 e2 = CompProp e1 C_Gt e2 let ge e1 e2 = CompProp (Plus (Lit 1) e1) C_Gt e2 (* Define a traversal monad! Makes exception handling and counter-keeping easy *) private let st = p:(nat * list term){fst p == List.Tot.Base.length (snd p)} private let tm a = st -> Tac (either string (a * st)) private let return (x:'a) : tm 'a = fun i -> Inr (x, i) private let (let!) (m : tm 'a) (f : 'a -> tm 'b) : tm 'b = fun i -> match m i with | Inr (x, j) -> f x j | s -> Inl (Inl?.v s) // why? To have a catch-all pattern and thus an easy WP val lift : ('a -> Tac 'b) -> ('a -> tm 'b) let lift f x st = Inr (f x, st) val liftM : ('a -> 'b) -> (tm 'a -> tm 'b) let liftM f x = let! xx = x in return (f xx) val liftM2 : ('a -> 'b -> 'c) -> (tm 'a -> tm 'b -> tm 'c) let liftM2 f x y = let! xx = x in let! yy = y in return (f xx yy) val liftM3 : ('a -> 'b -> 'c -> 'd) -> (tm 'a -> tm 'b -> tm 'c -> tm 'd) let liftM3 f x y z = let! xx = x in let! yy = y in let! zz = z in return (f xx yy zz) private let rec find_idx (f : 'a -> Tac bool) (l : list 'a) : Tac (option ((n:nat{n < List.Tot.Base.length l}) * 'a)) = match l with | [] -> None | x::xs -> if f x then Some (0, x) else begin match find_idx f xs with | None -> None | Some (i, x) -> Some (i+1, x) end private let atom (t:term) : tm expr = fun (n, atoms) -> match find_idx (term_eq_old t) atoms with | None -> Inr (Atom n t, (n + 1, t::atoms)) | Some (i, t) -> Inr (Atom (n - 1 - i) t, (n, atoms)) private val fail : (#a:Type) -> string -> tm a private let fail #a s = fun i -> Inl s val as_arith_expr : term -> tm expr #push-options "--initial_fuel 4 --max_fuel 4" let rec as_arith_expr (t:term) = let hd, tl = collect_app_ln t in // Invoke [collect_app_order]: forall (arg, qual) ∈ tl, (arg, qual) << t collect_app_order t; // [precedes_fst_tl]: forall (arg, qual) ∈ tl, arg << t let precedes_fst_tl (arg: term) (q: aqualv) : Lemma (List.Tot.memP (arg, q) tl ==> arg << t) = let _: argv = arg, q in () in Classical.forall_intro_2 (precedes_fst_tl); match inspect_ln hd, tl with | Tv_FVar fv, [(e1, Q_Implicit); (e2, Q_Explicit) ; (e3, Q_Explicit)] -> let qn = inspect_fv fv in let e2' = as_arith_expr e2 in let e3' = as_arith_expr e3 in if qn = land_qn then liftM2 Land e2' e3' else if qn = lxor_qn then liftM2 Lxor e2' e3' else if qn = lor_qn then liftM2 Lor e2' e3' else if qn = shiftr_qn then liftM2 Shr e2' e3' else if qn = shiftl_qn then liftM2 Shl e2' e3' else if qn = udiv_qn then liftM2 Udiv e2' e3' else if qn = umod_qn then liftM2 Umod e2' e3' else if qn = mul_mod_qn then liftM2 MulMod e2' e3' else if qn = ladd_qn then liftM2 Ladd e2' e3' else if qn = lsub_qn then liftM2 Lsub e2' e3' else atom t | Tv_FVar fv, [(l, Q_Explicit); (r, Q_Explicit)] -> let qn = inspect_fv fv in // Have to go through hoops to get F* to typecheck this. // Maybe the do notation is twisting the terms somehow unexpected? let ll = as_arith_expr l in let rr = as_arith_expr r in if qn = add_qn then liftM2 Plus ll rr else if qn = minus_qn then liftM2 Minus ll rr else if qn = mult_qn then liftM2 Mult ll rr else if qn = mult'_qn then liftM2 Mult ll rr else atom t | Tv_FVar fv, [(l, Q_Implicit); (r, Q_Explicit)] -> let qn = inspect_fv fv in let ll = as_arith_expr l in let rr = as_arith_expr r in if qn = nat_bv_qn then liftM NatToBv rr else atom t | Tv_FVar fv, [(a, Q_Explicit)] -> let qn = inspect_fv fv in let aa = as_arith_expr a in if qn = neg_qn then liftM Neg aa else atom t | Tv_Const (C_Int i), _ -> return (Lit i) | _ -> atom t #pop-options val is_arith_expr : term -> tm expr let is_arith_expr t = let! a = as_arith_expr t in match a with | Atom _ t -> begin let hd, tl = collect_app_ref t in match inspect_ln hd, tl with | Tv_FVar _, [] | Tv_BVar _, [] | Tv_Var _, [] -> return a | _ -> let! s = lift term_to_string t in fail ("not an arithmetic expression: (" ^ s ^ ")") end | _ -> return a // Cannot use this... // val is_arith_prop : term -> tm prop val is_arith_prop : term -> st -> Tac (either string (prop * st)) let rec is_arith_prop (t:term) = fun i -> (let! f = lift (fun t -> term_as_formula t) t in match f with | Comp (Eq _) l r -> liftM2 eq (is_arith_expr l) (is_arith_expr r) | Comp (BoolEq _) l r -> liftM2 eq (is_arith_expr l) (is_arith_expr r) | Comp Lt l r -> liftM2 lt (is_arith_expr l) (is_arith_expr r) | Comp Le l r -> liftM2 le (is_arith_expr l) (is_arith_expr r) | And l r -> liftM2 AndProp (is_arith_prop l) (is_arith_prop r) | Or l r -> liftM2 OrProp (is_arith_prop l) (is_arith_prop r) | _ -> let! s = lift term_to_string t in fail ("connector (" ^ s ^ ")")) i // Run the monadic computations, disregard the counter
false
false
FStar.Reflection.V2.Arith.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val run_tm (m: tm 'a) : Tac (either string 'a)
[]
FStar.Reflection.V2.Arith.run_tm
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
m: FStar.Reflection.V2.Arith.tm 'a -> FStar.Tactics.Effect.Tac (FStar.Pervasives.either Prims.string 'a)
{ "end_col": 25, "end_line": 214, "start_col": 4, "start_line": 212 }
Prims.Tot
val expr_to_string (e: expr) : string
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec expr_to_string (e:expr) : string = match e with | Atom i _ -> "a"^(string_of_int i) | Lit i -> string_of_int i | Plus l r -> "(" ^ (expr_to_string l) ^ " + " ^ (expr_to_string r) ^ ")" | Minus l r -> "(" ^ (expr_to_string l) ^ " - " ^ (expr_to_string r) ^ ")" | Mult l r -> "(" ^ (expr_to_string l) ^ " * " ^ (expr_to_string r) ^ ")" | Neg l -> "(- " ^ (expr_to_string l) ^ ")" | Land l r -> "(" ^ (expr_to_string l) ^ " & " ^ (expr_to_string r) ^ ")" | Lor l r -> "(" ^ (expr_to_string l) ^ " | " ^ (expr_to_string r) ^ ")" | Lxor l r -> "(" ^ (expr_to_string l) ^ " ^ " ^ (expr_to_string r) ^ ")" | Ladd l r -> "(" ^ (expr_to_string l) ^ " >> " ^ (expr_to_string r) ^ ")" | Lsub l r -> "(" ^ (expr_to_string l) ^ " >> " ^ (expr_to_string r) ^ ")" | Shl l r -> "(" ^ (expr_to_string l) ^ " << " ^ (expr_to_string r) ^ ")" | Shr l r -> "(" ^ (expr_to_string l) ^ " >> " ^ (expr_to_string r) ^ ")" | NatToBv l -> "(" ^ "to_vec " ^ (expr_to_string l) ^ ")" | Udiv l r -> "(" ^ (expr_to_string l) ^ " / " ^ (expr_to_string r) ^ ")" | Umod l r -> "(" ^ (expr_to_string l) ^ " % " ^ (expr_to_string r) ^ ")" | MulMod l r -> "(" ^ (expr_to_string l) ^ " ** " ^ (expr_to_string r) ^ ")"
val expr_to_string (e: expr) : string let rec expr_to_string (e: expr) : string =
false
null
false
match e with | Atom i _ -> "a" ^ (string_of_int i) | Lit i -> string_of_int i | Plus l r -> "(" ^ (expr_to_string l) ^ " + " ^ (expr_to_string r) ^ ")" | Minus l r -> "(" ^ (expr_to_string l) ^ " - " ^ (expr_to_string r) ^ ")" | Mult l r -> "(" ^ (expr_to_string l) ^ " * " ^ (expr_to_string r) ^ ")" | Neg l -> "(- " ^ (expr_to_string l) ^ ")" | Land l r -> "(" ^ (expr_to_string l) ^ " & " ^ (expr_to_string r) ^ ")" | Lor l r -> "(" ^ (expr_to_string l) ^ " | " ^ (expr_to_string r) ^ ")" | Lxor l r -> "(" ^ (expr_to_string l) ^ " ^ " ^ (expr_to_string r) ^ ")" | Ladd l r -> "(" ^ (expr_to_string l) ^ " >> " ^ (expr_to_string r) ^ ")" | Lsub l r -> "(" ^ (expr_to_string l) ^ " >> " ^ (expr_to_string r) ^ ")" | Shl l r -> "(" ^ (expr_to_string l) ^ " << " ^ (expr_to_string r) ^ ")" | Shr l r -> "(" ^ (expr_to_string l) ^ " >> " ^ (expr_to_string r) ^ ")" | NatToBv l -> "(" ^ "to_vec " ^ (expr_to_string l) ^ ")" | Udiv l r -> "(" ^ (expr_to_string l) ^ " / " ^ (expr_to_string r) ^ ")" | Umod l r -> "(" ^ (expr_to_string l) ^ " % " ^ (expr_to_string r) ^ ")" | MulMod l r -> "(" ^ (expr_to_string l) ^ " ** " ^ (expr_to_string r) ^ ")"
{ "checked_file": "FStar.Reflection.V2.Arith.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ "total" ]
[ "FStar.Reflection.V2.Arith.expr", "Prims.nat", "FStar.Reflection.Types.term", "Prims.op_Hat", "Prims.string_of_int", "Prims.int", "FStar.Reflection.V2.Arith.expr_to_string", "Prims.string" ]
[]
(* 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.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2) let eq e1 e2 = CompProp e1 C_Eq e2 let ne e1 e2 = CompProp e1 C_Ne e2 let gt e1 e2 = CompProp e1 C_Gt e2 let ge e1 e2 = CompProp (Plus (Lit 1) e1) C_Gt e2 (* Define a traversal monad! Makes exception handling and counter-keeping easy *) private let st = p:(nat * list term){fst p == List.Tot.Base.length (snd p)} private let tm a = st -> Tac (either string (a * st)) private let return (x:'a) : tm 'a = fun i -> Inr (x, i) private let (let!) (m : tm 'a) (f : 'a -> tm 'b) : tm 'b = fun i -> match m i with | Inr (x, j) -> f x j | s -> Inl (Inl?.v s) // why? To have a catch-all pattern and thus an easy WP val lift : ('a -> Tac 'b) -> ('a -> tm 'b) let lift f x st = Inr (f x, st) val liftM : ('a -> 'b) -> (tm 'a -> tm 'b) let liftM f x = let! xx = x in return (f xx) val liftM2 : ('a -> 'b -> 'c) -> (tm 'a -> tm 'b -> tm 'c) let liftM2 f x y = let! xx = x in let! yy = y in return (f xx yy) val liftM3 : ('a -> 'b -> 'c -> 'd) -> (tm 'a -> tm 'b -> tm 'c -> tm 'd) let liftM3 f x y z = let! xx = x in let! yy = y in let! zz = z in return (f xx yy zz) private let rec find_idx (f : 'a -> Tac bool) (l : list 'a) : Tac (option ((n:nat{n < List.Tot.Base.length l}) * 'a)) = match l with | [] -> None | x::xs -> if f x then Some (0, x) else begin match find_idx f xs with | None -> None | Some (i, x) -> Some (i+1, x) end private let atom (t:term) : tm expr = fun (n, atoms) -> match find_idx (term_eq_old t) atoms with | None -> Inr (Atom n t, (n + 1, t::atoms)) | Some (i, t) -> Inr (Atom (n - 1 - i) t, (n, atoms)) private val fail : (#a:Type) -> string -> tm a private let fail #a s = fun i -> Inl s val as_arith_expr : term -> tm expr #push-options "--initial_fuel 4 --max_fuel 4" let rec as_arith_expr (t:term) = let hd, tl = collect_app_ln t in // Invoke [collect_app_order]: forall (arg, qual) ∈ tl, (arg, qual) << t collect_app_order t; // [precedes_fst_tl]: forall (arg, qual) ∈ tl, arg << t let precedes_fst_tl (arg: term) (q: aqualv) : Lemma (List.Tot.memP (arg, q) tl ==> arg << t) = let _: argv = arg, q in () in Classical.forall_intro_2 (precedes_fst_tl); match inspect_ln hd, tl with | Tv_FVar fv, [(e1, Q_Implicit); (e2, Q_Explicit) ; (e3, Q_Explicit)] -> let qn = inspect_fv fv in let e2' = as_arith_expr e2 in let e3' = as_arith_expr e3 in if qn = land_qn then liftM2 Land e2' e3' else if qn = lxor_qn then liftM2 Lxor e2' e3' else if qn = lor_qn then liftM2 Lor e2' e3' else if qn = shiftr_qn then liftM2 Shr e2' e3' else if qn = shiftl_qn then liftM2 Shl e2' e3' else if qn = udiv_qn then liftM2 Udiv e2' e3' else if qn = umod_qn then liftM2 Umod e2' e3' else if qn = mul_mod_qn then liftM2 MulMod e2' e3' else if qn = ladd_qn then liftM2 Ladd e2' e3' else if qn = lsub_qn then liftM2 Lsub e2' e3' else atom t | Tv_FVar fv, [(l, Q_Explicit); (r, Q_Explicit)] -> let qn = inspect_fv fv in // Have to go through hoops to get F* to typecheck this. // Maybe the do notation is twisting the terms somehow unexpected? let ll = as_arith_expr l in let rr = as_arith_expr r in if qn = add_qn then liftM2 Plus ll rr else if qn = minus_qn then liftM2 Minus ll rr else if qn = mult_qn then liftM2 Mult ll rr else if qn = mult'_qn then liftM2 Mult ll rr else atom t | Tv_FVar fv, [(l, Q_Implicit); (r, Q_Explicit)] -> let qn = inspect_fv fv in let ll = as_arith_expr l in let rr = as_arith_expr r in if qn = nat_bv_qn then liftM NatToBv rr else atom t | Tv_FVar fv, [(a, Q_Explicit)] -> let qn = inspect_fv fv in let aa = as_arith_expr a in if qn = neg_qn then liftM Neg aa else atom t | Tv_Const (C_Int i), _ -> return (Lit i) | _ -> atom t #pop-options val is_arith_expr : term -> tm expr let is_arith_expr t = let! a = as_arith_expr t in match a with | Atom _ t -> begin let hd, tl = collect_app_ref t in match inspect_ln hd, tl with | Tv_FVar _, [] | Tv_BVar _, [] | Tv_Var _, [] -> return a | _ -> let! s = lift term_to_string t in fail ("not an arithmetic expression: (" ^ s ^ ")") end | _ -> return a // Cannot use this... // val is_arith_prop : term -> tm prop val is_arith_prop : term -> st -> Tac (either string (prop * st)) let rec is_arith_prop (t:term) = fun i -> (let! f = lift (fun t -> term_as_formula t) t in match f with | Comp (Eq _) l r -> liftM2 eq (is_arith_expr l) (is_arith_expr r) | Comp (BoolEq _) l r -> liftM2 eq (is_arith_expr l) (is_arith_expr r) | Comp Lt l r -> liftM2 lt (is_arith_expr l) (is_arith_expr r) | Comp Le l r -> liftM2 le (is_arith_expr l) (is_arith_expr r) | And l r -> liftM2 AndProp (is_arith_prop l) (is_arith_prop r) | Or l r -> liftM2 OrProp (is_arith_prop l) (is_arith_prop r) | _ -> let! s = lift term_to_string t in fail ("connector (" ^ s ^ ")")) i // Run the monadic computations, disregard the counter let run_tm (m : tm 'a) : Tac (either string 'a) = match m (0, []) with | Inr (x, _) -> Inr x | s -> Inl (Inl?.v s) // why? To have a catch-all pattern and thus an easy WP
false
true
FStar.Reflection.V2.Arith.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val expr_to_string (e: expr) : string
[ "recursion" ]
FStar.Reflection.V2.Arith.expr_to_string
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
e: FStar.Reflection.V2.Arith.expr -> Prims.string
{ "end_col": 80, "end_line": 234, "start_col": 4, "start_line": 217 }
FStar.Tactics.Effect.Tac
val find_idx (f: ('a -> Tac bool)) (l: list 'a) : Tac (option ((n: nat{n < List.Tot.Base.length l}) * 'a))
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec find_idx (f : 'a -> Tac bool) (l : list 'a) : Tac (option ((n:nat{n < List.Tot.Base.length l}) * 'a)) = match l with | [] -> None | x::xs -> if f x then Some (0, x) else begin match find_idx f xs with | None -> None | Some (i, x) -> Some (i+1, x) end
val find_idx (f: ('a -> Tac bool)) (l: list 'a) : Tac (option ((n: nat{n < List.Tot.Base.length l}) * 'a)) let rec find_idx (f: ('a -> Tac bool)) (l: list 'a) : Tac (option ((n: nat{n < List.Tot.Base.length l}) * 'a)) =
true
null
false
match l with | [] -> None | x :: xs -> if f x then Some (0, x) else match find_idx f xs with | None -> None | Some (i, x) -> Some (i + 1, x)
{ "checked_file": "FStar.Reflection.V2.Arith.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[]
[ "Prims.bool", "Prims.list", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.tuple2", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.List.Tot.Base.length", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.Mktuple2", "Prims.op_Addition", "FStar.Reflection.V2.Arith.find_idx" ]
[]
(* 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.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2) let eq e1 e2 = CompProp e1 C_Eq e2 let ne e1 e2 = CompProp e1 C_Ne e2 let gt e1 e2 = CompProp e1 C_Gt e2 let ge e1 e2 = CompProp (Plus (Lit 1) e1) C_Gt e2 (* Define a traversal monad! Makes exception handling and counter-keeping easy *) private let st = p:(nat * list term){fst p == List.Tot.Base.length (snd p)} private let tm a = st -> Tac (either string (a * st)) private let return (x:'a) : tm 'a = fun i -> Inr (x, i) private let (let!) (m : tm 'a) (f : 'a -> tm 'b) : tm 'b = fun i -> match m i with | Inr (x, j) -> f x j | s -> Inl (Inl?.v s) // why? To have a catch-all pattern and thus an easy WP val lift : ('a -> Tac 'b) -> ('a -> tm 'b) let lift f x st = Inr (f x, st) val liftM : ('a -> 'b) -> (tm 'a -> tm 'b) let liftM f x = let! xx = x in return (f xx) val liftM2 : ('a -> 'b -> 'c) -> (tm 'a -> tm 'b -> tm 'c) let liftM2 f x y = let! xx = x in let! yy = y in return (f xx yy) val liftM3 : ('a -> 'b -> 'c -> 'd) -> (tm 'a -> tm 'b -> tm 'c -> tm 'd) let liftM3 f x y z = let! xx = x in let! yy = y in let! zz = z in return (f xx yy zz)
false
false
FStar.Reflection.V2.Arith.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val find_idx (f: ('a -> Tac bool)) (l: list 'a) : Tac (option ((n: nat{n < List.Tot.Base.length l}) * 'a))
[ "recursion" ]
FStar.Reflection.V2.Arith.find_idx
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: (_: 'a -> FStar.Tactics.Effect.Tac Prims.bool) -> l: Prims.list 'a -> FStar.Tactics.Effect.Tac (FStar.Pervasives.Native.option (n: Prims.nat{n < FStar.List.Tot.Base.length l} * 'a))
{ "end_col": 16, "end_line": 113, "start_col": 4, "start_line": 105 }
Prims.Tot
val as_arith_expr : term -> tm expr
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "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.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec as_arith_expr (t:term) = let hd, tl = collect_app_ln t in // Invoke [collect_app_order]: forall (arg, qual) ∈ tl, (arg, qual) << t collect_app_order t; // [precedes_fst_tl]: forall (arg, qual) ∈ tl, arg << t let precedes_fst_tl (arg: term) (q: aqualv) : Lemma (List.Tot.memP (arg, q) tl ==> arg << t) = let _: argv = arg, q in () in Classical.forall_intro_2 (precedes_fst_tl); match inspect_ln hd, tl with | Tv_FVar fv, [(e1, Q_Implicit); (e2, Q_Explicit) ; (e3, Q_Explicit)] -> let qn = inspect_fv fv in let e2' = as_arith_expr e2 in let e3' = as_arith_expr e3 in if qn = land_qn then liftM2 Land e2' e3' else if qn = lxor_qn then liftM2 Lxor e2' e3' else if qn = lor_qn then liftM2 Lor e2' e3' else if qn = shiftr_qn then liftM2 Shr e2' e3' else if qn = shiftl_qn then liftM2 Shl e2' e3' else if qn = udiv_qn then liftM2 Udiv e2' e3' else if qn = umod_qn then liftM2 Umod e2' e3' else if qn = mul_mod_qn then liftM2 MulMod e2' e3' else if qn = ladd_qn then liftM2 Ladd e2' e3' else if qn = lsub_qn then liftM2 Lsub e2' e3' else atom t | Tv_FVar fv, [(l, Q_Explicit); (r, Q_Explicit)] -> let qn = inspect_fv fv in // Have to go through hoops to get F* to typecheck this. // Maybe the do notation is twisting the terms somehow unexpected? let ll = as_arith_expr l in let rr = as_arith_expr r in if qn = add_qn then liftM2 Plus ll rr else if qn = minus_qn then liftM2 Minus ll rr else if qn = mult_qn then liftM2 Mult ll rr else if qn = mult'_qn then liftM2 Mult ll rr else atom t | Tv_FVar fv, [(l, Q_Implicit); (r, Q_Explicit)] -> let qn = inspect_fv fv in let ll = as_arith_expr l in let rr = as_arith_expr r in if qn = nat_bv_qn then liftM NatToBv rr else atom t | Tv_FVar fv, [(a, Q_Explicit)] -> let qn = inspect_fv fv in let aa = as_arith_expr a in if qn = neg_qn then liftM Neg aa else atom t | Tv_Const (C_Int i), _ -> return (Lit i) | _ -> atom t
val as_arith_expr : term -> tm expr let rec as_arith_expr (t: term) =
false
null
false
let hd, tl = collect_app_ln t in collect_app_order t; let precedes_fst_tl (arg: term) (q: aqualv) : Lemma (List.Tot.memP (arg, q) tl ==> arg << t) = let _:argv = arg, q in () in Classical.forall_intro_2 (precedes_fst_tl); match inspect_ln hd, tl with | Tv_FVar fv, [e1, Q_Implicit ; e2, Q_Explicit ; e3, Q_Explicit] -> let qn = inspect_fv fv in let e2' = as_arith_expr e2 in let e3' = as_arith_expr e3 in if qn = land_qn then liftM2 Land e2' e3' else if qn = lxor_qn then liftM2 Lxor e2' e3' else if qn = lor_qn then liftM2 Lor e2' e3' else if qn = shiftr_qn then liftM2 Shr e2' e3' else if qn = shiftl_qn then liftM2 Shl e2' e3' else if qn = udiv_qn then liftM2 Udiv e2' e3' else if qn = umod_qn then liftM2 Umod e2' e3' else if qn = mul_mod_qn then liftM2 MulMod e2' e3' else if qn = ladd_qn then liftM2 Ladd e2' e3' else if qn = lsub_qn then liftM2 Lsub e2' e3' else atom t | Tv_FVar fv, [l, Q_Explicit ; r, Q_Explicit] -> let qn = inspect_fv fv in let ll = as_arith_expr l in let rr = as_arith_expr r in if qn = add_qn then liftM2 Plus ll rr else if qn = minus_qn then liftM2 Minus ll rr else if qn = mult_qn then liftM2 Mult ll rr else if qn = mult'_qn then liftM2 Mult ll rr else atom t | Tv_FVar fv, [l, Q_Implicit ; r, Q_Explicit] -> let qn = inspect_fv fv in let ll = as_arith_expr l in let rr = as_arith_expr r in if qn = nat_bv_qn then liftM NatToBv rr else atom t | Tv_FVar fv, [a, Q_Explicit] -> let qn = inspect_fv fv in let aa = as_arith_expr a in if qn = neg_qn then liftM Neg aa else atom t | Tv_Const (C_Int i), _ -> return (Lit i) | _ -> atom t
{ "checked_file": "FStar.Reflection.V2.Arith.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ "total" ]
[ "FStar.Reflection.Types.term", "Prims.list", "FStar.Reflection.V2.Data.argv", "FStar.Pervasives.Native.Mktuple2", "FStar.Reflection.V2.Data.term_view", "FStar.Pervasives.Native.tuple2", "FStar.Reflection.V2.Data.aqualv", "FStar.Reflection.V2.Builtins.inspect_ln", "FStar.Reflection.Types.fv", "Prims.op_Equality", "Prims.string", "FStar.Reflection.Const.land_qn", "FStar.Reflection.V2.Arith.liftM2", "FStar.Reflection.V2.Arith.expr", "FStar.Reflection.V2.Arith.Land", "Prims.bool", "FStar.Reflection.Const.lxor_qn", "FStar.Reflection.V2.Arith.Lxor", "FStar.Reflection.Const.lor_qn", "FStar.Reflection.V2.Arith.Lor", "FStar.Reflection.Const.shiftr_qn", "FStar.Reflection.V2.Arith.Shr", "FStar.Reflection.Const.shiftl_qn", "FStar.Reflection.V2.Arith.Shl", "FStar.Reflection.Const.udiv_qn", "FStar.Reflection.V2.Arith.Udiv", "FStar.Reflection.Const.umod_qn", "FStar.Reflection.V2.Arith.Umod", "FStar.Reflection.Const.mul_mod_qn", "FStar.Reflection.V2.Arith.MulMod", "FStar.Reflection.Const.ladd_qn", "FStar.Reflection.V2.Arith.Ladd", "FStar.Reflection.Const.lsub_qn", "FStar.Reflection.V2.Arith.Lsub", "FStar.Reflection.V2.Arith.atom", "FStar.Reflection.V2.Arith.tm", "FStar.Reflection.V2.Arith.as_arith_expr", "FStar.Reflection.Types.name", "FStar.Reflection.V2.Builtins.inspect_fv", "FStar.Reflection.Const.add_qn", "FStar.Reflection.V2.Arith.Plus", "FStar.Reflection.Const.minus_qn", "FStar.Reflection.V2.Arith.Minus", "FStar.Reflection.Const.mult_qn", "FStar.Reflection.V2.Arith.Mult", "FStar.Reflection.Const.mult'_qn", "FStar.Reflection.Const.nat_bv_qn", "FStar.Reflection.V2.Arith.liftM", "FStar.Reflection.V2.Arith.NatToBv", "FStar.Reflection.Const.neg_qn", "FStar.Reflection.V2.Arith.Neg", "Prims.int", "FStar.Reflection.V2.Arith.return", "FStar.Reflection.V2.Arith.Lit", "Prims.unit", "FStar.Classical.forall_intro_2", "Prims.l_imp", "FStar.List.Tot.Base.memP", "Prims.precedes", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Reflection.V2.Derived.Lemmas.collect_app_order", "FStar.Reflection.V2.Derived.collect_app_ln" ]
[]
(* 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.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2) let eq e1 e2 = CompProp e1 C_Eq e2 let ne e1 e2 = CompProp e1 C_Ne e2 let gt e1 e2 = CompProp e1 C_Gt e2 let ge e1 e2 = CompProp (Plus (Lit 1) e1) C_Gt e2 (* Define a traversal monad! Makes exception handling and counter-keeping easy *) private let st = p:(nat * list term){fst p == List.Tot.Base.length (snd p)} private let tm a = st -> Tac (either string (a * st)) private let return (x:'a) : tm 'a = fun i -> Inr (x, i) private let (let!) (m : tm 'a) (f : 'a -> tm 'b) : tm 'b = fun i -> match m i with | Inr (x, j) -> f x j | s -> Inl (Inl?.v s) // why? To have a catch-all pattern and thus an easy WP val lift : ('a -> Tac 'b) -> ('a -> tm 'b) let lift f x st = Inr (f x, st) val liftM : ('a -> 'b) -> (tm 'a -> tm 'b) let liftM f x = let! xx = x in return (f xx) val liftM2 : ('a -> 'b -> 'c) -> (tm 'a -> tm 'b -> tm 'c) let liftM2 f x y = let! xx = x in let! yy = y in return (f xx yy) val liftM3 : ('a -> 'b -> 'c -> 'd) -> (tm 'a -> tm 'b -> tm 'c -> tm 'd) let liftM3 f x y z = let! xx = x in let! yy = y in let! zz = z in return (f xx yy zz) private let rec find_idx (f : 'a -> Tac bool) (l : list 'a) : Tac (option ((n:nat{n < List.Tot.Base.length l}) * 'a)) = match l with | [] -> None | x::xs -> if f x then Some (0, x) else begin match find_idx f xs with | None -> None | Some (i, x) -> Some (i+1, x) end private let atom (t:term) : tm expr = fun (n, atoms) -> match find_idx (term_eq_old t) atoms with | None -> Inr (Atom n t, (n + 1, t::atoms)) | Some (i, t) -> Inr (Atom (n - 1 - i) t, (n, atoms)) private val fail : (#a:Type) -> string -> tm a private let fail #a s = fun i -> Inl s val as_arith_expr : term -> tm expr
false
true
FStar.Reflection.V2.Arith.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 4, "initial_ifuel": 1, "max_fuel": 4, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val as_arith_expr : term -> tm expr
[ "recursion" ]
FStar.Reflection.V2.Arith.as_arith_expr
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t: FStar.Reflection.Types.term -> FStar.Reflection.V2.Arith.tm FStar.Reflection.V2.Arith.expr
{ "end_col": 14, "end_line": 175, "start_col": 32, "start_line": 125 }
FStar.All.ML
val simplify_atomic_action (env: T.env_t) (a: atomic_action) : ML atomic_action
[ { "abbrev": true, "full_module": "TypeSizes", "short_module": "T" }, { "abbrev": true, "full_module": "Binding", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": true, "full_module": "Binding", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let simplify_atomic_action (env:T.env_t) (a:atomic_action) : ML atomic_action = match a with | Action_return e -> Action_return (simplify_expr env e) | Action_assignment lhs rhs -> Action_assignment (simplify_out_expr env lhs) (simplify_expr env rhs) | Action_field_ptr_after sz write_to -> Action_field_ptr_after (simplify_expr env sz) (simplify_out_expr env write_to) | Action_call f args -> Action_call f (List.map (simplify_expr env) args) | _ -> a
val simplify_atomic_action (env: T.env_t) (a: atomic_action) : ML atomic_action let simplify_atomic_action (env: T.env_t) (a: atomic_action) : ML atomic_action =
true
null
false
match a with | Action_return e -> Action_return (simplify_expr env e) | Action_assignment lhs rhs -> Action_assignment (simplify_out_expr env lhs) (simplify_expr env rhs) | Action_field_ptr_after sz write_to -> Action_field_ptr_after (simplify_expr env sz) (simplify_out_expr env write_to) | Action_call f args -> Action_call f (List.map (simplify_expr env) args) | _ -> a
{ "checked_file": "Simplify.fst.checked", "dependencies": [ "TypeSizes.fsti.checked", "prims.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.fst.checked", "FStar.All.fst.checked", "Binding.fsti.checked", "Ast.fst.checked" ], "interface_file": true, "source_file": "Simplify.fst" }
[ "ml" ]
[ "TypeSizes.env_t", "Ast.atomic_action", "Ast.expr", "Ast.Action_return", "Simplify.simplify_expr", "Ast.out_expr", "Ast.Action_assignment", "Simplify.simplify_out_expr", "Ast.Action_field_ptr_after", "Ast.ident", "Prims.list", "Ast.Action_call", "FStar.List.map" ]
[]
(* Copyright 2019 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 Simplify open Ast open FStar.All module B = Binding module T = TypeSizes (* This module implements a pass over the source AST 1. Simplifying refinement expressions, in particular reducing sizeof expressions to constants 2. Reducing typedef abbreviations *) let rec simplify_expr (env:T.env_t) (e:expr) : ML expr = match e.v with | This -> failwith "Impossible: should have been eliminated already" | App SizeOf _ -> begin match T.value_of_const_expr env e with | Some (Inr (t, n)) -> with_range (Constant (Int t n)) e.range | _ -> error (Printf.sprintf "Could not evaluate %s to a compile-time constant" (print_expr e)) e.range end | App op es -> let es = List.map (simplify_expr env) es in { e with v = App op es } | _ -> e (* * Simplify output expressions, mainly their metadata to resolve * abbrevs in the types that appear in the metadata *) let rec simplify_typ_param (env:T.env_t) (p:typ_param) : ML typ_param = match p with | Inl e -> simplify_expr env e |> Inl | Inr oe -> simplify_out_expr env oe |> Inr and simplify_typ (env:T.env_t) (t:typ) : ML typ = match t.v with | Pointer t -> {t with v=Pointer (simplify_typ env t)} | Type_app s b ps -> let ps = List.map (simplify_typ_param env) ps in let s = B.resolve_record_case_output_extern_type_name (fst env) s in let t = { t with v = Type_app s b ps } in B.unfold_typ_abbrev_only (fst env) t and simplify_out_expr_node (env:T.env_t) (oe:with_meta_t out_expr') : ML (with_meta_t out_expr') = oe and simplify_out_expr_meta (env:T.env_t) (mopt:option out_expr_meta_t) : ML (option out_expr_meta_t) = match mopt with | None -> None | Some ({ out_expr_base_t = bt; out_expr_t = t; out_expr_bit_width = n }) -> Some ({ out_expr_base_t = simplify_typ env bt; out_expr_t = simplify_typ env t; out_expr_bit_width = n }) and simplify_out_expr (env:T.env_t) (oe:out_expr) : ML out_expr = {oe with out_expr_node = simplify_out_expr_node env oe.out_expr_node; out_expr_meta = simplify_out_expr_meta env oe.out_expr_meta} let simplify_atomic_action (env:T.env_t) (a:atomic_action)
false
false
Simplify.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val simplify_atomic_action (env: T.env_t) (a: atomic_action) : ML atomic_action
[]
Simplify.simplify_atomic_action
{ "file_name": "src/3d/Simplify.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
env: TypeSizes.env_t -> a: Ast.atomic_action -> FStar.All.ML Ast.atomic_action
{ "end_col": 12, "end_line": 95, "start_col": 4, "start_line": 88 }
FStar.All.ML
val simplify_out_expr_node (env: T.env_t) (oe: with_meta_t out_expr') : ML (with_meta_t out_expr')
[ { "abbrev": true, "full_module": "TypeSizes", "short_module": "T" }, { "abbrev": true, "full_module": "Binding", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": true, "full_module": "Binding", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec simplify_typ_param (env:T.env_t) (p:typ_param) : ML typ_param = match p with | Inl e -> simplify_expr env e |> Inl | Inr oe -> simplify_out_expr env oe |> Inr and simplify_typ (env:T.env_t) (t:typ) : ML typ = match t.v with | Pointer t -> {t with v=Pointer (simplify_typ env t)} | Type_app s b ps -> let ps = List.map (simplify_typ_param env) ps in let s = B.resolve_record_case_output_extern_type_name (fst env) s in let t = { t with v = Type_app s b ps } in B.unfold_typ_abbrev_only (fst env) t and simplify_out_expr_node (env:T.env_t) (oe:with_meta_t out_expr') : ML (with_meta_t out_expr') = oe and simplify_out_expr_meta (env:T.env_t) (mopt:option out_expr_meta_t) : ML (option out_expr_meta_t) = match mopt with | None -> None | Some ({ out_expr_base_t = bt; out_expr_t = t; out_expr_bit_width = n }) -> Some ({ out_expr_base_t = simplify_typ env bt; out_expr_t = simplify_typ env t; out_expr_bit_width = n }) and simplify_out_expr (env:T.env_t) (oe:out_expr) : ML out_expr = {oe with out_expr_node = simplify_out_expr_node env oe.out_expr_node; out_expr_meta = simplify_out_expr_meta env oe.out_expr_meta}
val simplify_out_expr_node (env: T.env_t) (oe: with_meta_t out_expr') : ML (with_meta_t out_expr') let rec simplify_out_expr_node (env: T.env_t) (oe: with_meta_t out_expr') : ML (with_meta_t out_expr') =
true
null
false
oe
{ "checked_file": "Simplify.fst.checked", "dependencies": [ "TypeSizes.fsti.checked", "prims.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.fst.checked", "FStar.All.fst.checked", "Binding.fsti.checked", "Ast.fst.checked" ], "interface_file": true, "source_file": "Simplify.fst" }
[ "ml" ]
[ "TypeSizes.env_t", "Ast.with_meta_t", "Ast.out_expr'" ]
[ "simplify_typ_param", "simplify_typ", "simplify_out_expr_node", "simplify_out_expr_meta", "simplify_out_expr" ]
(* Copyright 2019 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 Simplify open Ast open FStar.All module B = Binding module T = TypeSizes (* This module implements a pass over the source AST 1. Simplifying refinement expressions, in particular reducing sizeof expressions to constants 2. Reducing typedef abbreviations *) let rec simplify_expr (env:T.env_t) (e:expr) : ML expr = match e.v with | This -> failwith "Impossible: should have been eliminated already" | App SizeOf _ -> begin match T.value_of_const_expr env e with | Some (Inr (t, n)) -> with_range (Constant (Int t n)) e.range | _ -> error (Printf.sprintf "Could not evaluate %s to a compile-time constant" (print_expr e)) e.range end | App op es -> let es = List.map (simplify_expr env) es in { e with v = App op es } | _ -> e (* * Simplify output expressions, mainly their metadata to resolve * abbrevs in the types that appear in the metadata *) let rec simplify_typ_param (env:T.env_t) (p:typ_param) : ML typ_param = match p with | Inl e -> simplify_expr env e |> Inl | Inr oe -> simplify_out_expr env oe |> Inr and simplify_typ (env:T.env_t) (t:typ) : ML typ = match t.v with | Pointer t -> {t with v=Pointer (simplify_typ env t)} | Type_app s b ps -> let ps = List.map (simplify_typ_param env) ps in let s = B.resolve_record_case_output_extern_type_name (fst env) s in let t = { t with v = Type_app s b ps } in B.unfold_typ_abbrev_only (fst env) t and simplify_out_expr_node (env:T.env_t) (oe:with_meta_t out_expr')
false
false
Simplify.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val simplify_out_expr_node (env: T.env_t) (oe: with_meta_t out_expr') : ML (with_meta_t out_expr')
[ "mutual recursion" ]
Simplify.simplify_out_expr_node
{ "file_name": "src/3d/Simplify.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
env: TypeSizes.env_t -> oe: Ast.with_meta_t Ast.out_expr' -> FStar.All.ML (Ast.with_meta_t Ast.out_expr')
{ "end_col": 6, "end_line": 68, "start_col": 4, "start_line": 68 }
FStar.All.ML
val simplify_prog (benv:B.global_env) (senv:TypeSizes.size_env) (p:list decl) : ML (list decl)
[ { "abbrev": true, "full_module": "TypeSizes", "short_module": "T" }, { "abbrev": true, "full_module": "Binding", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": true, "full_module": "Binding", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let simplify_prog benv senv (p:list decl) = List.map (simplify_decl (B.mk_env benv, senv)) p
val simplify_prog (benv:B.global_env) (senv:TypeSizes.size_env) (p:list decl) : ML (list decl) let simplify_prog benv senv (p: list decl) =
true
null
false
List.map (simplify_decl (B.mk_env benv, senv)) p
{ "checked_file": "Simplify.fst.checked", "dependencies": [ "TypeSizes.fsti.checked", "prims.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.fst.checked", "FStar.All.fst.checked", "Binding.fsti.checked", "Ast.fst.checked" ], "interface_file": true, "source_file": "Simplify.fst" }
[ "ml" ]
[ "GlobalEnv.global_env", "TypeSizes.size_env", "Prims.list", "Ast.decl", "FStar.List.map", "Simplify.simplify_decl", "TypeSizes.env_t", "FStar.Pervasives.Native.Mktuple2", "Binding.env", "Binding.mk_env" ]
[]
(* Copyright 2019 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 Simplify open Ast open FStar.All module B = Binding module T = TypeSizes (* This module implements a pass over the source AST 1. Simplifying refinement expressions, in particular reducing sizeof expressions to constants 2. Reducing typedef abbreviations *) let rec simplify_expr (env:T.env_t) (e:expr) : ML expr = match e.v with | This -> failwith "Impossible: should have been eliminated already" | App SizeOf _ -> begin match T.value_of_const_expr env e with | Some (Inr (t, n)) -> with_range (Constant (Int t n)) e.range | _ -> error (Printf.sprintf "Could not evaluate %s to a compile-time constant" (print_expr e)) e.range end | App op es -> let es = List.map (simplify_expr env) es in { e with v = App op es } | _ -> e (* * Simplify output expressions, mainly their metadata to resolve * abbrevs in the types that appear in the metadata *) let rec simplify_typ_param (env:T.env_t) (p:typ_param) : ML typ_param = match p with | Inl e -> simplify_expr env e |> Inl | Inr oe -> simplify_out_expr env oe |> Inr and simplify_typ (env:T.env_t) (t:typ) : ML typ = match t.v with | Pointer t -> {t with v=Pointer (simplify_typ env t)} | Type_app s b ps -> let ps = List.map (simplify_typ_param env) ps in let s = B.resolve_record_case_output_extern_type_name (fst env) s in let t = { t with v = Type_app s b ps } in B.unfold_typ_abbrev_only (fst env) t and simplify_out_expr_node (env:T.env_t) (oe:with_meta_t out_expr') : ML (with_meta_t out_expr') = oe and simplify_out_expr_meta (env:T.env_t) (mopt:option out_expr_meta_t) : ML (option out_expr_meta_t) = match mopt with | None -> None | Some ({ out_expr_base_t = bt; out_expr_t = t; out_expr_bit_width = n }) -> Some ({ out_expr_base_t = simplify_typ env bt; out_expr_t = simplify_typ env t; out_expr_bit_width = n }) and simplify_out_expr (env:T.env_t) (oe:out_expr) : ML out_expr = {oe with out_expr_node = simplify_out_expr_node env oe.out_expr_node; out_expr_meta = simplify_out_expr_meta env oe.out_expr_meta} let simplify_atomic_action (env:T.env_t) (a:atomic_action) : ML atomic_action = match a with | Action_return e -> Action_return (simplify_expr env e) | Action_assignment lhs rhs -> Action_assignment (simplify_out_expr env lhs) (simplify_expr env rhs) | Action_field_ptr_after sz write_to -> Action_field_ptr_after (simplify_expr env sz) (simplify_out_expr env write_to) | Action_call f args -> Action_call f (List.map (simplify_expr env) args) | _ -> a //action mutable identifiers are not subject to substitution let rec simplify_action (env:T.env_t) (a:action) : ML action = match a.v with | Atomic_action aa -> {a with v = Atomic_action (simplify_atomic_action env aa)} | Action_seq hd tl -> {a with v = Action_seq (simplify_atomic_action env hd) (simplify_action env tl) } | Action_ite hd then_ else_ -> {a with v = Action_ite (simplify_expr env hd) (simplify_action env then_) (simplify_action_opt env else_) } | Action_let i aa k -> {a with v = Action_let i (simplify_atomic_action env aa) (simplify_action env k) } | Action_act a -> { a with v = Action_act (simplify_action env a) } and simplify_action_opt (env:T.env_t) (a:option action) : ML (option action) = match a with | None -> None | Some a -> Some (simplify_action env a) let simplify_field_array (env:T.env_t) (f:field_array_t) : ML field_array_t = match f with | FieldScalar -> FieldScalar | FieldArrayQualified (e, b) -> FieldArrayQualified (simplify_expr env e, b) | FieldString sz -> FieldString (map_opt (simplify_expr env) sz) let simplify_atomic_field (env:T.env_t) (f:atomic_field) : ML atomic_field = let sf = f.v in let ft = simplify_typ env sf.field_type in let fa = simplify_field_array env sf.field_array_opt in let fc = sf.field_constraint |> map_opt (simplify_expr env) in let fact = match sf.field_action with | None -> None | Some (a, b) -> Some (simplify_action env a, b) in let sf = { sf with field_type = ft; field_array_opt = fa; field_constraint = fc; field_action = fact } in { f with v = sf } let rec simplify_field (env:T.env_t) (f:field) : ML field = match f.v with | AtomicField af -> { f with v = AtomicField (simplify_atomic_field env af) } | RecordField fs i -> { f with v = RecordField (List.map (simplify_field env) fs) i } | SwitchCaseField swc i -> { f with v = SwitchCaseField (simplify_switch_case env swc) i } and simplify_switch_case (env:T.env_t) (c:switch_case) : ML switch_case = let (e, cases) = c in let e = simplify_expr env e in let cases = List.map (function Case e f -> Case (simplify_expr env e) (simplify_field env f) | DefaultCase f -> DefaultCase (simplify_field env f)) cases in e, cases let rec simplify_out_fields (env:T.env_t) (flds:list out_field) : ML (list out_field) = List.map (fun fld -> match fld with | Out_field_named id t n -> Out_field_named id (simplify_typ env t) n | Out_field_anon flds is_union -> Out_field_anon (simplify_out_fields env flds) is_union) flds let simplify_decl (env:T.env_t) (d:decl) : ML decl = match d.d_decl.v with | ModuleAbbrev _ _ -> d | Define i None c -> d | Define i (Some t) c -> decl_with_v d (Define i (Some (simplify_typ env t)) c) | TypeAbbrev t i -> let t' = simplify_typ env t in B.update_typ_abbrev (fst env) i t'; decl_with_v d (TypeAbbrev t' i) | Enum t i cases -> let t = simplify_typ env t in decl_with_v d (Enum t i cases) | Record tdnames params wopt fields -> let params = List.map (fun (t, i, q) -> simplify_typ env t, i, q) params in let fields = List.map (simplify_field env) fields in let wopt = match wopt with | None -> None | Some w -> Some (simplify_expr env w) in decl_with_v d (Record tdnames params wopt fields) | CaseType tdnames params switch -> let params = List.map (fun (t, i, q) -> simplify_typ env t, i, q) params in let switch = simplify_switch_case env switch in decl_with_v d (CaseType tdnames params switch) | OutputType out_t -> decl_with_v d (OutputType ({out_t with out_typ_fields=simplify_out_fields env out_t.out_typ_fields})) | ExternType tdnames -> d | ExternFn f ret params -> let ret = simplify_typ env ret in let params = List.map (fun (t, i, q) -> simplify_typ env t, i, q) params in decl_with_v d (ExternFn f ret params)
false
false
Simplify.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val simplify_prog (benv:B.global_env) (senv:TypeSizes.size_env) (p:list decl) : ML (list decl)
[]
Simplify.simplify_prog
{ "file_name": "src/3d/Simplify.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
benv: GlobalEnv.global_env -> senv: TypeSizes.size_env -> p: Prims.list Ast.decl -> FStar.All.ML (Prims.list Ast.decl)
{ "end_col": 50, "end_line": 196, "start_col": 2, "start_line": 196 }
FStar.All.ML
val simplify_expr (env: T.env_t) (e: expr) : ML expr
[ { "abbrev": true, "full_module": "TypeSizes", "short_module": "T" }, { "abbrev": true, "full_module": "Binding", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": true, "full_module": "Binding", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec simplify_expr (env:T.env_t) (e:expr) : ML expr = match e.v with | This -> failwith "Impossible: should have been eliminated already" | App SizeOf _ -> begin match T.value_of_const_expr env e with | Some (Inr (t, n)) -> with_range (Constant (Int t n)) e.range | _ -> error (Printf.sprintf "Could not evaluate %s to a compile-time constant" (print_expr e)) e.range end | App op es -> let es = List.map (simplify_expr env) es in { e with v = App op es } | _ -> e
val simplify_expr (env: T.env_t) (e: expr) : ML expr let rec simplify_expr (env: T.env_t) (e: expr) : ML expr =
true
null
false
match e.v with | This -> failwith "Impossible: should have been eliminated already" | App SizeOf _ -> (match T.value_of_const_expr env e with | Some (Inr (t, n)) -> with_range (Constant (Int t n)) e.range | _ -> error (Printf.sprintf "Could not evaluate %s to a compile-time constant" (print_expr e)) e.range) | App op es -> let es = List.map (simplify_expr env) es in { e with v = App op es } | _ -> e
{ "checked_file": "Simplify.fst.checked", "dependencies": [ "TypeSizes.fsti.checked", "prims.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.fst.checked", "FStar.All.fst.checked", "Binding.fsti.checked", "Ast.fst.checked" ], "interface_file": true, "source_file": "Simplify.fst" }
[ "ml" ]
[ "TypeSizes.env_t", "Ast.expr", "Ast.__proj__Mkwith_meta_t__item__v", "Ast.expr'", "FStar.All.failwith", "Prims.list", "Ast.with_meta_t", "Ast.integer_type", "Prims.int", "Ast.with_range", "Ast.Constant", "Ast.Int", "Ast.__proj__Mkwith_meta_t__item__range", "FStar.Pervasives.Native.option", "Ast.either", "Prims.bool", "FStar.Pervasives.Native.tuple2", "Ast.error", "FStar.Printf.sprintf", "Ast.print_expr", "TypeSizes.value_of_const_expr", "Ast.op", "Ast.Mkwith_meta_t", "Ast.App", "Ast.__proj__Mkwith_meta_t__item__comments", "FStar.List.map", "Simplify.simplify_expr" ]
[]
(* Copyright 2019 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 Simplify open Ast open FStar.All module B = Binding module T = TypeSizes (* This module implements a pass over the source AST 1. Simplifying refinement expressions, in particular reducing sizeof expressions to constants 2. Reducing typedef abbreviations *) let rec simplify_expr (env:T.env_t) (e:expr)
false
false
Simplify.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val simplify_expr (env: T.env_t) (e: expr) : ML expr
[ "recursion" ]
Simplify.simplify_expr
{ "file_name": "src/3d/Simplify.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
env: TypeSizes.env_t -> e: Ast.expr -> FStar.All.ML Ast.expr
{ "end_col": 12, "end_line": 45, "start_col": 4, "start_line": 33 }
FStar.All.ML
val simplify_atomic_field (env: T.env_t) (f: atomic_field) : ML atomic_field
[ { "abbrev": true, "full_module": "TypeSizes", "short_module": "T" }, { "abbrev": true, "full_module": "Binding", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": true, "full_module": "Binding", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let simplify_atomic_field (env:T.env_t) (f:atomic_field) : ML atomic_field = let sf = f.v in let ft = simplify_typ env sf.field_type in let fa = simplify_field_array env sf.field_array_opt in let fc = sf.field_constraint |> map_opt (simplify_expr env) in let fact = match sf.field_action with | None -> None | Some (a, b) -> Some (simplify_action env a, b) in let sf = { sf with field_type = ft; field_array_opt = fa; field_constraint = fc; field_action = fact } in { f with v = sf }
val simplify_atomic_field (env: T.env_t) (f: atomic_field) : ML atomic_field let simplify_atomic_field (env: T.env_t) (f: atomic_field) : ML atomic_field =
true
null
false
let sf = f.v in let ft = simplify_typ env sf.field_type in let fa = simplify_field_array env sf.field_array_opt in let fc = sf.field_constraint |> map_opt (simplify_expr env) in let fact = match sf.field_action with | None -> None | Some (a, b) -> Some (simplify_action env a, b) in let sf = { sf with field_type = ft; field_array_opt = fa; field_constraint = fc; field_action = fact } in { f with v = sf }
{ "checked_file": "Simplify.fst.checked", "dependencies": [ "TypeSizes.fsti.checked", "prims.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.fst.checked", "FStar.All.fst.checked", "Binding.fsti.checked", "Ast.fst.checked" ], "interface_file": true, "source_file": "Simplify.fst" }
[ "ml" ]
[ "TypeSizes.env_t", "Ast.atomic_field", "Ast.Mkwith_meta_t", "Ast.atomic_field'", "Ast.__proj__Mkwith_meta_t__item__range", "Ast.__proj__Mkwith_meta_t__item__comments", "Ast.Mkatomic_field'", "Ast.__proj__Mkatomic_field'__item__field_dependence", "Ast.__proj__Mkatomic_field'__item__field_ident", "Ast.__proj__Mkatomic_field'__item__field_bitwidth", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "Ast.action", "Prims.bool", "Ast.__proj__Mkatomic_field'__item__field_action", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.Mktuple2", "Simplify.simplify_action", "Ast.expr", "FStar.All.op_Bar_Greater", "Ast.__proj__Mkatomic_field'__item__field_constraint", "Ast.map_opt", "Simplify.simplify_expr", "Ast.field_array_t", "Simplify.simplify_field_array", "Ast.__proj__Mkatomic_field'__item__field_array_opt", "Ast.typ", "Simplify.simplify_typ", "Ast.__proj__Mkatomic_field'__item__field_type", "Ast.__proj__Mkwith_meta_t__item__v" ]
[]
(* Copyright 2019 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 Simplify open Ast open FStar.All module B = Binding module T = TypeSizes (* This module implements a pass over the source AST 1. Simplifying refinement expressions, in particular reducing sizeof expressions to constants 2. Reducing typedef abbreviations *) let rec simplify_expr (env:T.env_t) (e:expr) : ML expr = match e.v with | This -> failwith "Impossible: should have been eliminated already" | App SizeOf _ -> begin match T.value_of_const_expr env e with | Some (Inr (t, n)) -> with_range (Constant (Int t n)) e.range | _ -> error (Printf.sprintf "Could not evaluate %s to a compile-time constant" (print_expr e)) e.range end | App op es -> let es = List.map (simplify_expr env) es in { e with v = App op es } | _ -> e (* * Simplify output expressions, mainly their metadata to resolve * abbrevs in the types that appear in the metadata *) let rec simplify_typ_param (env:T.env_t) (p:typ_param) : ML typ_param = match p with | Inl e -> simplify_expr env e |> Inl | Inr oe -> simplify_out_expr env oe |> Inr and simplify_typ (env:T.env_t) (t:typ) : ML typ = match t.v with | Pointer t -> {t with v=Pointer (simplify_typ env t)} | Type_app s b ps -> let ps = List.map (simplify_typ_param env) ps in let s = B.resolve_record_case_output_extern_type_name (fst env) s in let t = { t with v = Type_app s b ps } in B.unfold_typ_abbrev_only (fst env) t and simplify_out_expr_node (env:T.env_t) (oe:with_meta_t out_expr') : ML (with_meta_t out_expr') = oe and simplify_out_expr_meta (env:T.env_t) (mopt:option out_expr_meta_t) : ML (option out_expr_meta_t) = match mopt with | None -> None | Some ({ out_expr_base_t = bt; out_expr_t = t; out_expr_bit_width = n }) -> Some ({ out_expr_base_t = simplify_typ env bt; out_expr_t = simplify_typ env t; out_expr_bit_width = n }) and simplify_out_expr (env:T.env_t) (oe:out_expr) : ML out_expr = {oe with out_expr_node = simplify_out_expr_node env oe.out_expr_node; out_expr_meta = simplify_out_expr_meta env oe.out_expr_meta} let simplify_atomic_action (env:T.env_t) (a:atomic_action) : ML atomic_action = match a with | Action_return e -> Action_return (simplify_expr env e) | Action_assignment lhs rhs -> Action_assignment (simplify_out_expr env lhs) (simplify_expr env rhs) | Action_field_ptr_after sz write_to -> Action_field_ptr_after (simplify_expr env sz) (simplify_out_expr env write_to) | Action_call f args -> Action_call f (List.map (simplify_expr env) args) | _ -> a //action mutable identifiers are not subject to substitution let rec simplify_action (env:T.env_t) (a:action) : ML action = match a.v with | Atomic_action aa -> {a with v = Atomic_action (simplify_atomic_action env aa)} | Action_seq hd tl -> {a with v = Action_seq (simplify_atomic_action env hd) (simplify_action env tl) } | Action_ite hd then_ else_ -> {a with v = Action_ite (simplify_expr env hd) (simplify_action env then_) (simplify_action_opt env else_) } | Action_let i aa k -> {a with v = Action_let i (simplify_atomic_action env aa) (simplify_action env k) } | Action_act a -> { a with v = Action_act (simplify_action env a) } and simplify_action_opt (env:T.env_t) (a:option action) : ML (option action) = match a with | None -> None | Some a -> Some (simplify_action env a) let simplify_field_array (env:T.env_t) (f:field_array_t) : ML field_array_t = match f with | FieldScalar -> FieldScalar | FieldArrayQualified (e, b) -> FieldArrayQualified (simplify_expr env e, b) | FieldString sz -> FieldString (map_opt (simplify_expr env) sz) let simplify_atomic_field (env:T.env_t) (f:atomic_field)
false
false
Simplify.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val simplify_atomic_field (env: T.env_t) (f: atomic_field) : ML atomic_field
[]
Simplify.simplify_atomic_field
{ "file_name": "src/3d/Simplify.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
env: TypeSizes.env_t -> f: Ast.atomic_field -> FStar.All.ML Ast.atomic_field
{ "end_col": 21, "end_line": 130, "start_col": 3, "start_line": 117 }
FStar.All.ML
val simplify_field_array (env: T.env_t) (f: field_array_t) : ML field_array_t
[ { "abbrev": true, "full_module": "TypeSizes", "short_module": "T" }, { "abbrev": true, "full_module": "Binding", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": true, "full_module": "Binding", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let simplify_field_array (env:T.env_t) (f:field_array_t) : ML field_array_t = match f with | FieldScalar -> FieldScalar | FieldArrayQualified (e, b) -> FieldArrayQualified (simplify_expr env e, b) | FieldString sz -> FieldString (map_opt (simplify_expr env) sz)
val simplify_field_array (env: T.env_t) (f: field_array_t) : ML field_array_t let simplify_field_array (env: T.env_t) (f: field_array_t) : ML field_array_t =
true
null
false
match f with | FieldScalar -> FieldScalar | FieldArrayQualified (e, b) -> FieldArrayQualified (simplify_expr env e, b) | FieldString sz -> FieldString (map_opt (simplify_expr env) sz)
{ "checked_file": "Simplify.fst.checked", "dependencies": [ "TypeSizes.fsti.checked", "prims.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.fst.checked", "FStar.All.fst.checked", "Binding.fsti.checked", "Ast.fst.checked" ], "interface_file": true, "source_file": "Simplify.fst" }
[ "ml" ]
[ "TypeSizes.env_t", "Ast.field_array_t", "Ast.FieldScalar", "Ast.expr", "Ast.array_qualifier", "Ast.FieldArrayQualified", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "Simplify.simplify_expr", "FStar.Pervasives.Native.option", "Ast.FieldString", "Ast.map_opt" ]
[]
(* Copyright 2019 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 Simplify open Ast open FStar.All module B = Binding module T = TypeSizes (* This module implements a pass over the source AST 1. Simplifying refinement expressions, in particular reducing sizeof expressions to constants 2. Reducing typedef abbreviations *) let rec simplify_expr (env:T.env_t) (e:expr) : ML expr = match e.v with | This -> failwith "Impossible: should have been eliminated already" | App SizeOf _ -> begin match T.value_of_const_expr env e with | Some (Inr (t, n)) -> with_range (Constant (Int t n)) e.range | _ -> error (Printf.sprintf "Could not evaluate %s to a compile-time constant" (print_expr e)) e.range end | App op es -> let es = List.map (simplify_expr env) es in { e with v = App op es } | _ -> e (* * Simplify output expressions, mainly their metadata to resolve * abbrevs in the types that appear in the metadata *) let rec simplify_typ_param (env:T.env_t) (p:typ_param) : ML typ_param = match p with | Inl e -> simplify_expr env e |> Inl | Inr oe -> simplify_out_expr env oe |> Inr and simplify_typ (env:T.env_t) (t:typ) : ML typ = match t.v with | Pointer t -> {t with v=Pointer (simplify_typ env t)} | Type_app s b ps -> let ps = List.map (simplify_typ_param env) ps in let s = B.resolve_record_case_output_extern_type_name (fst env) s in let t = { t with v = Type_app s b ps } in B.unfold_typ_abbrev_only (fst env) t and simplify_out_expr_node (env:T.env_t) (oe:with_meta_t out_expr') : ML (with_meta_t out_expr') = oe and simplify_out_expr_meta (env:T.env_t) (mopt:option out_expr_meta_t) : ML (option out_expr_meta_t) = match mopt with | None -> None | Some ({ out_expr_base_t = bt; out_expr_t = t; out_expr_bit_width = n }) -> Some ({ out_expr_base_t = simplify_typ env bt; out_expr_t = simplify_typ env t; out_expr_bit_width = n }) and simplify_out_expr (env:T.env_t) (oe:out_expr) : ML out_expr = {oe with out_expr_node = simplify_out_expr_node env oe.out_expr_node; out_expr_meta = simplify_out_expr_meta env oe.out_expr_meta} let simplify_atomic_action (env:T.env_t) (a:atomic_action) : ML atomic_action = match a with | Action_return e -> Action_return (simplify_expr env e) | Action_assignment lhs rhs -> Action_assignment (simplify_out_expr env lhs) (simplify_expr env rhs) | Action_field_ptr_after sz write_to -> Action_field_ptr_after (simplify_expr env sz) (simplify_out_expr env write_to) | Action_call f args -> Action_call f (List.map (simplify_expr env) args) | _ -> a //action mutable identifiers are not subject to substitution let rec simplify_action (env:T.env_t) (a:action) : ML action = match a.v with | Atomic_action aa -> {a with v = Atomic_action (simplify_atomic_action env aa)} | Action_seq hd tl -> {a with v = Action_seq (simplify_atomic_action env hd) (simplify_action env tl) } | Action_ite hd then_ else_ -> {a with v = Action_ite (simplify_expr env hd) (simplify_action env then_) (simplify_action_opt env else_) } | Action_let i aa k -> {a with v = Action_let i (simplify_atomic_action env aa) (simplify_action env k) } | Action_act a -> { a with v = Action_act (simplify_action env a) } and simplify_action_opt (env:T.env_t) (a:option action) : ML (option action) = match a with | None -> None | Some a -> Some (simplify_action env a)
false
false
Simplify.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val simplify_field_array (env: T.env_t) (f: field_array_t) : ML field_array_t
[]
Simplify.simplify_field_array
{ "file_name": "src/3d/Simplify.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
env: TypeSizes.env_t -> f: Ast.field_array_t -> FStar.All.ML Ast.field_array_t
{ "end_col": 66, "end_line": 113, "start_col": 2, "start_line": 110 }
FStar.All.ML
val simplify_out_fields (env: T.env_t) (flds: list out_field) : ML (list out_field)
[ { "abbrev": true, "full_module": "TypeSizes", "short_module": "T" }, { "abbrev": true, "full_module": "Binding", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": true, "full_module": "Binding", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec simplify_out_fields (env:T.env_t) (flds:list out_field) : ML (list out_field) = List.map (fun fld -> match fld with | Out_field_named id t n -> Out_field_named id (simplify_typ env t) n | Out_field_anon flds is_union -> Out_field_anon (simplify_out_fields env flds) is_union) flds
val simplify_out_fields (env: T.env_t) (flds: list out_field) : ML (list out_field) let rec simplify_out_fields (env: T.env_t) (flds: list out_field) : ML (list out_field) =
true
null
false
List.map (function | Out_field_named id t n -> Out_field_named id (simplify_typ env t) n | Out_field_anon flds is_union -> Out_field_anon (simplify_out_fields env flds) is_union) flds
{ "checked_file": "Simplify.fst.checked", "dependencies": [ "TypeSizes.fsti.checked", "prims.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.fst.checked", "FStar.All.fst.checked", "Binding.fsti.checked", "Ast.fst.checked" ], "interface_file": true, "source_file": "Simplify.fst" }
[ "ml" ]
[ "TypeSizes.env_t", "Prims.list", "Ast.out_field", "FStar.List.map", "Ast.ident", "Ast.typ", "FStar.Pervasives.Native.option", "Prims.int", "Ast.Out_field_named", "Simplify.simplify_typ", "Prims.bool", "Ast.Out_field_anon", "Simplify.simplify_out_fields" ]
[]
(* Copyright 2019 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 Simplify open Ast open FStar.All module B = Binding module T = TypeSizes (* This module implements a pass over the source AST 1. Simplifying refinement expressions, in particular reducing sizeof expressions to constants 2. Reducing typedef abbreviations *) let rec simplify_expr (env:T.env_t) (e:expr) : ML expr = match e.v with | This -> failwith "Impossible: should have been eliminated already" | App SizeOf _ -> begin match T.value_of_const_expr env e with | Some (Inr (t, n)) -> with_range (Constant (Int t n)) e.range | _ -> error (Printf.sprintf "Could not evaluate %s to a compile-time constant" (print_expr e)) e.range end | App op es -> let es = List.map (simplify_expr env) es in { e with v = App op es } | _ -> e (* * Simplify output expressions, mainly their metadata to resolve * abbrevs in the types that appear in the metadata *) let rec simplify_typ_param (env:T.env_t) (p:typ_param) : ML typ_param = match p with | Inl e -> simplify_expr env e |> Inl | Inr oe -> simplify_out_expr env oe |> Inr and simplify_typ (env:T.env_t) (t:typ) : ML typ = match t.v with | Pointer t -> {t with v=Pointer (simplify_typ env t)} | Type_app s b ps -> let ps = List.map (simplify_typ_param env) ps in let s = B.resolve_record_case_output_extern_type_name (fst env) s in let t = { t with v = Type_app s b ps } in B.unfold_typ_abbrev_only (fst env) t and simplify_out_expr_node (env:T.env_t) (oe:with_meta_t out_expr') : ML (with_meta_t out_expr') = oe and simplify_out_expr_meta (env:T.env_t) (mopt:option out_expr_meta_t) : ML (option out_expr_meta_t) = match mopt with | None -> None | Some ({ out_expr_base_t = bt; out_expr_t = t; out_expr_bit_width = n }) -> Some ({ out_expr_base_t = simplify_typ env bt; out_expr_t = simplify_typ env t; out_expr_bit_width = n }) and simplify_out_expr (env:T.env_t) (oe:out_expr) : ML out_expr = {oe with out_expr_node = simplify_out_expr_node env oe.out_expr_node; out_expr_meta = simplify_out_expr_meta env oe.out_expr_meta} let simplify_atomic_action (env:T.env_t) (a:atomic_action) : ML atomic_action = match a with | Action_return e -> Action_return (simplify_expr env e) | Action_assignment lhs rhs -> Action_assignment (simplify_out_expr env lhs) (simplify_expr env rhs) | Action_field_ptr_after sz write_to -> Action_field_ptr_after (simplify_expr env sz) (simplify_out_expr env write_to) | Action_call f args -> Action_call f (List.map (simplify_expr env) args) | _ -> a //action mutable identifiers are not subject to substitution let rec simplify_action (env:T.env_t) (a:action) : ML action = match a.v with | Atomic_action aa -> {a with v = Atomic_action (simplify_atomic_action env aa)} | Action_seq hd tl -> {a with v = Action_seq (simplify_atomic_action env hd) (simplify_action env tl) } | Action_ite hd then_ else_ -> {a with v = Action_ite (simplify_expr env hd) (simplify_action env then_) (simplify_action_opt env else_) } | Action_let i aa k -> {a with v = Action_let i (simplify_atomic_action env aa) (simplify_action env k) } | Action_act a -> { a with v = Action_act (simplify_action env a) } and simplify_action_opt (env:T.env_t) (a:option action) : ML (option action) = match a with | None -> None | Some a -> Some (simplify_action env a) let simplify_field_array (env:T.env_t) (f:field_array_t) : ML field_array_t = match f with | FieldScalar -> FieldScalar | FieldArrayQualified (e, b) -> FieldArrayQualified (simplify_expr env e, b) | FieldString sz -> FieldString (map_opt (simplify_expr env) sz) let simplify_atomic_field (env:T.env_t) (f:atomic_field) : ML atomic_field = let sf = f.v in let ft = simplify_typ env sf.field_type in let fa = simplify_field_array env sf.field_array_opt in let fc = sf.field_constraint |> map_opt (simplify_expr env) in let fact = match sf.field_action with | None -> None | Some (a, b) -> Some (simplify_action env a, b) in let sf = { sf with field_type = ft; field_array_opt = fa; field_constraint = fc; field_action = fact } in { f with v = sf } let rec simplify_field (env:T.env_t) (f:field) : ML field = match f.v with | AtomicField af -> { f with v = AtomicField (simplify_atomic_field env af) } | RecordField fs i -> { f with v = RecordField (List.map (simplify_field env) fs) i } | SwitchCaseField swc i -> { f with v = SwitchCaseField (simplify_switch_case env swc) i } and simplify_switch_case (env:T.env_t) (c:switch_case) : ML switch_case = let (e, cases) = c in let e = simplify_expr env e in let cases = List.map (function Case e f -> Case (simplify_expr env e) (simplify_field env f) | DefaultCase f -> DefaultCase (simplify_field env f)) cases in e, cases
false
false
Simplify.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val simplify_out_fields (env: T.env_t) (flds: list out_field) : ML (list out_field)
[ "recursion" ]
Simplify.simplify_out_fields
{ "file_name": "src/3d/Simplify.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
env: TypeSizes.env_t -> flds: Prims.list Ast.out_field -> FStar.All.ML (Prims.list Ast.out_field)
{ "end_col": 66, "end_line": 156, "start_col": 2, "start_line": 153 }
FStar.All.ML
val simplify_decl (env: T.env_t) (d: decl) : ML decl
[ { "abbrev": true, "full_module": "TypeSizes", "short_module": "T" }, { "abbrev": true, "full_module": "Binding", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": true, "full_module": "Binding", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Ast", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let simplify_decl (env:T.env_t) (d:decl) : ML decl = match d.d_decl.v with | ModuleAbbrev _ _ -> d | Define i None c -> d | Define i (Some t) c -> decl_with_v d (Define i (Some (simplify_typ env t)) c) | TypeAbbrev t i -> let t' = simplify_typ env t in B.update_typ_abbrev (fst env) i t'; decl_with_v d (TypeAbbrev t' i) | Enum t i cases -> let t = simplify_typ env t in decl_with_v d (Enum t i cases) | Record tdnames params wopt fields -> let params = List.map (fun (t, i, q) -> simplify_typ env t, i, q) params in let fields = List.map (simplify_field env) fields in let wopt = match wopt with | None -> None | Some w -> Some (simplify_expr env w) in decl_with_v d (Record tdnames params wopt fields) | CaseType tdnames params switch -> let params = List.map (fun (t, i, q) -> simplify_typ env t, i, q) params in let switch = simplify_switch_case env switch in decl_with_v d (CaseType tdnames params switch) | OutputType out_t -> decl_with_v d (OutputType ({out_t with out_typ_fields=simplify_out_fields env out_t.out_typ_fields})) | ExternType tdnames -> d | ExternFn f ret params -> let ret = simplify_typ env ret in let params = List.map (fun (t, i, q) -> simplify_typ env t, i, q) params in decl_with_v d (ExternFn f ret params)
val simplify_decl (env: T.env_t) (d: decl) : ML decl let simplify_decl (env: T.env_t) (d: decl) : ML decl =
true
null
false
match d.d_decl.v with | ModuleAbbrev _ _ -> d | Define i None c -> d | Define i (Some t) c -> decl_with_v d (Define i (Some (simplify_typ env t)) c) | TypeAbbrev t i -> let t' = simplify_typ env t in B.update_typ_abbrev (fst env) i t'; decl_with_v d (TypeAbbrev t' i) | Enum t i cases -> let t = simplify_typ env t in decl_with_v d (Enum t i cases) | Record tdnames params wopt fields -> let params = List.map (fun (t, i, q) -> simplify_typ env t, i, q) params in let fields = List.map (simplify_field env) fields in let wopt = match wopt with | None -> None | Some w -> Some (simplify_expr env w) in decl_with_v d (Record tdnames params wopt fields) | CaseType tdnames params switch -> let params = List.map (fun (t, i, q) -> simplify_typ env t, i, q) params in let switch = simplify_switch_case env switch in decl_with_v d (CaseType tdnames params switch) | OutputType out_t -> decl_with_v d (OutputType ({ out_t with out_typ_fields = simplify_out_fields env out_t.out_typ_fields })) | ExternType tdnames -> d | ExternFn f ret params -> let ret = simplify_typ env ret in let params = List.map (fun (t, i, q) -> simplify_typ env t, i, q) params in decl_with_v d (ExternFn f ret params)
{ "checked_file": "Simplify.fst.checked", "dependencies": [ "TypeSizes.fsti.checked", "prims.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.fst.checked", "FStar.All.fst.checked", "Binding.fsti.checked", "Ast.fst.checked" ], "interface_file": true, "source_file": "Simplify.fst" }
[ "ml" ]
[ "TypeSizes.env_t", "Ast.decl", "Ast.__proj__Mkwith_meta_t__item__v", "Ast.decl'", "Ast.__proj__Mkdecl__item__d_decl", "Ast.ident", "Ast.constant", "Ast.typ", "Ast.decl_with_v", "Ast.Define", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.Some", "Simplify.simplify_typ", "Ast.TypeAbbrev", "Prims.unit", "Binding.update_typ_abbrev", "FStar.Pervasives.Native.fst", "Binding.env", "TypeSizes.size_env", "Prims.list", "Ast.enum_case", "Ast.Enum", "Ast.typedef_names", "Ast.param", "Ast.expr", "Ast.record", "Ast.Record", "FStar.Pervasives.Native.None", "Simplify.simplify_expr", "Ast.with_meta_t", "Ast.field'", "FStar.List.map", "Simplify.simplify_field", "FStar.Pervasives.Native.tuple3", "Ast.qualifier", "FStar.Pervasives.Native.Mktuple3", "Ast.switch_case", "Ast.CaseType", "Simplify.simplify_switch_case", "Ast.out_typ", "Ast.OutputType", "Ast.Mkout_typ", "Ast.__proj__Mkout_typ__item__out_typ_names", "Ast.__proj__Mkout_typ__item__out_typ_is_union", "Ast.out_field", "Simplify.simplify_out_fields", "Ast.__proj__Mkout_typ__item__out_typ_fields", "Ast.ExternFn" ]
[]
(* Copyright 2019 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 Simplify open Ast open FStar.All module B = Binding module T = TypeSizes (* This module implements a pass over the source AST 1. Simplifying refinement expressions, in particular reducing sizeof expressions to constants 2. Reducing typedef abbreviations *) let rec simplify_expr (env:T.env_t) (e:expr) : ML expr = match e.v with | This -> failwith "Impossible: should have been eliminated already" | App SizeOf _ -> begin match T.value_of_const_expr env e with | Some (Inr (t, n)) -> with_range (Constant (Int t n)) e.range | _ -> error (Printf.sprintf "Could not evaluate %s to a compile-time constant" (print_expr e)) e.range end | App op es -> let es = List.map (simplify_expr env) es in { e with v = App op es } | _ -> e (* * Simplify output expressions, mainly their metadata to resolve * abbrevs in the types that appear in the metadata *) let rec simplify_typ_param (env:T.env_t) (p:typ_param) : ML typ_param = match p with | Inl e -> simplify_expr env e |> Inl | Inr oe -> simplify_out_expr env oe |> Inr and simplify_typ (env:T.env_t) (t:typ) : ML typ = match t.v with | Pointer t -> {t with v=Pointer (simplify_typ env t)} | Type_app s b ps -> let ps = List.map (simplify_typ_param env) ps in let s = B.resolve_record_case_output_extern_type_name (fst env) s in let t = { t with v = Type_app s b ps } in B.unfold_typ_abbrev_only (fst env) t and simplify_out_expr_node (env:T.env_t) (oe:with_meta_t out_expr') : ML (with_meta_t out_expr') = oe and simplify_out_expr_meta (env:T.env_t) (mopt:option out_expr_meta_t) : ML (option out_expr_meta_t) = match mopt with | None -> None | Some ({ out_expr_base_t = bt; out_expr_t = t; out_expr_bit_width = n }) -> Some ({ out_expr_base_t = simplify_typ env bt; out_expr_t = simplify_typ env t; out_expr_bit_width = n }) and simplify_out_expr (env:T.env_t) (oe:out_expr) : ML out_expr = {oe with out_expr_node = simplify_out_expr_node env oe.out_expr_node; out_expr_meta = simplify_out_expr_meta env oe.out_expr_meta} let simplify_atomic_action (env:T.env_t) (a:atomic_action) : ML atomic_action = match a with | Action_return e -> Action_return (simplify_expr env e) | Action_assignment lhs rhs -> Action_assignment (simplify_out_expr env lhs) (simplify_expr env rhs) | Action_field_ptr_after sz write_to -> Action_field_ptr_after (simplify_expr env sz) (simplify_out_expr env write_to) | Action_call f args -> Action_call f (List.map (simplify_expr env) args) | _ -> a //action mutable identifiers are not subject to substitution let rec simplify_action (env:T.env_t) (a:action) : ML action = match a.v with | Atomic_action aa -> {a with v = Atomic_action (simplify_atomic_action env aa)} | Action_seq hd tl -> {a with v = Action_seq (simplify_atomic_action env hd) (simplify_action env tl) } | Action_ite hd then_ else_ -> {a with v = Action_ite (simplify_expr env hd) (simplify_action env then_) (simplify_action_opt env else_) } | Action_let i aa k -> {a with v = Action_let i (simplify_atomic_action env aa) (simplify_action env k) } | Action_act a -> { a with v = Action_act (simplify_action env a) } and simplify_action_opt (env:T.env_t) (a:option action) : ML (option action) = match a with | None -> None | Some a -> Some (simplify_action env a) let simplify_field_array (env:T.env_t) (f:field_array_t) : ML field_array_t = match f with | FieldScalar -> FieldScalar | FieldArrayQualified (e, b) -> FieldArrayQualified (simplify_expr env e, b) | FieldString sz -> FieldString (map_opt (simplify_expr env) sz) let simplify_atomic_field (env:T.env_t) (f:atomic_field) : ML atomic_field = let sf = f.v in let ft = simplify_typ env sf.field_type in let fa = simplify_field_array env sf.field_array_opt in let fc = sf.field_constraint |> map_opt (simplify_expr env) in let fact = match sf.field_action with | None -> None | Some (a, b) -> Some (simplify_action env a, b) in let sf = { sf with field_type = ft; field_array_opt = fa; field_constraint = fc; field_action = fact } in { f with v = sf } let rec simplify_field (env:T.env_t) (f:field) : ML field = match f.v with | AtomicField af -> { f with v = AtomicField (simplify_atomic_field env af) } | RecordField fs i -> { f with v = RecordField (List.map (simplify_field env) fs) i } | SwitchCaseField swc i -> { f with v = SwitchCaseField (simplify_switch_case env swc) i } and simplify_switch_case (env:T.env_t) (c:switch_case) : ML switch_case = let (e, cases) = c in let e = simplify_expr env e in let cases = List.map (function Case e f -> Case (simplify_expr env e) (simplify_field env f) | DefaultCase f -> DefaultCase (simplify_field env f)) cases in e, cases let rec simplify_out_fields (env:T.env_t) (flds:list out_field) : ML (list out_field) = List.map (fun fld -> match fld with | Out_field_named id t n -> Out_field_named id (simplify_typ env t) n | Out_field_anon flds is_union -> Out_field_anon (simplify_out_fields env flds) is_union) flds
false
false
Simplify.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val simplify_decl (env: T.env_t) (d: decl) : ML decl
[]
Simplify.simplify_decl
{ "file_name": "src/3d/Simplify.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
env: TypeSizes.env_t -> d: Ast.decl -> FStar.All.ML Ast.decl
{ "end_col": 41, "end_line": 192, "start_col": 2, "start_line": 159 }
Prims.Tot
val va_wp_VPolyAdd (dst src1 src2: va_operand_vec_opr) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[ { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_wp_VPolyAdd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add a1 a2) ==> va_k va_sM (())))
val va_wp_VPolyAdd (dst src1 src2: va_operand_vec_opr) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 let va_wp_VPolyAdd (dst src1 src2: va_operand_vec_opr) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 =
false
null
false
(va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst: va_value_vec_opr). let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let a1:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let a2:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add a1 a2) ==> va_k va_sM (())))
{ "checked_file": "Vale.AES.PPC64LE.PolyOps.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.QuickCodes.fsti.checked", "Vale.PPC64LE.QuickCode.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.InsVector.fsti.checked", "Vale.PPC64LE.InsMem.fsti.checked", "Vale.PPC64LE.InsBasic.fsti.checked", "Vale.PPC64LE.Decls.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Lemmas.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Math.Poly2.Bits.fsti.checked", "Vale.Math.Poly2.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GHash_BE.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.PPC64LE.PolyOps.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Decls.va_operand_vec_opr", "Vale.PPC64LE.Decls.va_state", "Prims.unit", "Prims.l_and", "Vale.PPC64LE.Decls.va_is_dst_vec_opr", "Vale.PPC64LE.Decls.va_is_src_vec_opr", "Prims.b2t", "Vale.PPC64LE.Decls.va_get_ok", "Prims.l_Forall", "Vale.PPC64LE.Decls.va_value_vec_opr", "Prims.l_imp", "Prims.eq2", "Vale.Math.Poly2_s.poly", "Vale.Math.Poly2.Bits_s.of_quad32", "Vale.PPC64LE.Decls.va_eval_vec_opr", "Vale.Math.Poly2_s.add", "Vale.PPC64LE.Machine_s.state", "Vale.PPC64LE.Decls.va_upd_operand_vec_opr" ]
[]
module Vale.AES.PPC64LE.PolyOps open Vale.Def.Types_s open Vale.Arch.Types open Vale.Math.Poly2_s open Vale.Math.Poly2 open Vale.Math.Poly2.Bits_s open Vale.Math.Poly2.Bits open Vale.Math.Poly2.Lemmas open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.InsBasic open Vale.PPC64LE.InsMem open Vale.PPC64LE.InsVector open Vale.PPC64LE.QuickCode open Vale.PPC64LE.QuickCodes open Vale.AES.GHash_BE //-- VPolyAdd val va_code_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyAdd : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyAdd dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add a1 a2) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyAdd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr)
false
true
Vale.AES.PPC64LE.PolyOps.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wp_VPolyAdd (dst src1 src2: va_operand_vec_opr) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[]
Vale.AES.PPC64LE.PolyOps.va_wp_VPolyAdd
{ "file_name": "obj/Vale.AES.PPC64LE.PolyOps.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.PPC64LE.Decls.va_operand_vec_opr -> src1: Vale.PPC64LE.Decls.va_operand_vec_opr -> src2: Vale.PPC64LE.Decls.va_operand_vec_opr -> va_s0: Vale.PPC64LE.Decls.va_state -> va_k: (_: Vale.PPC64LE.Decls.va_state -> _: Prims.unit -> Type0) -> Type0
{ "end_col": 25, "end_line": 46, "start_col": 2, "start_line": 40 }
Prims.Tot
val va_wp_VPolyAnd (dst src1 src2: va_operand_vec_opr) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[ { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_wp_VPolyAnd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.poly_and a1 a2) ==> va_k va_sM (())))
val va_wp_VPolyAnd (dst src1 src2: va_operand_vec_opr) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 let va_wp_VPolyAnd (dst src1 src2: va_operand_vec_opr) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 =
false
null
false
(va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst: va_value_vec_opr). let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let a1:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let a2:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.poly_and a1 a2) ==> va_k va_sM (())))
{ "checked_file": "Vale.AES.PPC64LE.PolyOps.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.QuickCodes.fsti.checked", "Vale.PPC64LE.QuickCode.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.InsVector.fsti.checked", "Vale.PPC64LE.InsMem.fsti.checked", "Vale.PPC64LE.InsBasic.fsti.checked", "Vale.PPC64LE.Decls.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Lemmas.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Math.Poly2.Bits.fsti.checked", "Vale.Math.Poly2.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GHash_BE.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.PPC64LE.PolyOps.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Decls.va_operand_vec_opr", "Vale.PPC64LE.Decls.va_state", "Prims.unit", "Prims.l_and", "Vale.PPC64LE.Decls.va_is_dst_vec_opr", "Vale.PPC64LE.Decls.va_is_src_vec_opr", "Prims.b2t", "Vale.PPC64LE.Decls.va_get_ok", "Prims.l_Forall", "Vale.PPC64LE.Decls.va_value_vec_opr", "Prims.l_imp", "Prims.eq2", "Vale.Math.Poly2_s.poly", "Vale.Math.Poly2.Bits_s.of_quad32", "Vale.PPC64LE.Decls.va_eval_vec_opr", "Vale.Math.Poly2.poly_and", "Vale.PPC64LE.Machine_s.state", "Vale.PPC64LE.Decls.va_upd_operand_vec_opr" ]
[]
module Vale.AES.PPC64LE.PolyOps open Vale.Def.Types_s open Vale.Arch.Types open Vale.Math.Poly2_s open Vale.Math.Poly2 open Vale.Math.Poly2.Bits_s open Vale.Math.Poly2.Bits open Vale.Math.Poly2.Lemmas open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.InsBasic open Vale.PPC64LE.InsMem open Vale.PPC64LE.InsVector open Vale.PPC64LE.QuickCode open Vale.PPC64LE.QuickCodes open Vale.AES.GHash_BE //-- VPolyAdd val va_code_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyAdd : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyAdd dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add a1 a2) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyAdd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add a1 a2) ==> va_k va_sM (()))) val va_wpProof_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyAdd dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyAdd dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyAdd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyAdd dst src1 src2)) = (va_QProc (va_code_VPolyAdd dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyAdd dst src1 src2) (va_wpProof_VPolyAdd dst src1 src2)) //-- //-- VPolyAnd val va_code_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyAnd : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyAnd dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.poly_and a1 a2) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyAnd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr)
false
true
Vale.AES.PPC64LE.PolyOps.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wp_VPolyAnd (dst src1 src2: va_operand_vec_opr) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[]
Vale.AES.PPC64LE.PolyOps.va_wp_VPolyAnd
{ "file_name": "obj/Vale.AES.PPC64LE.PolyOps.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.PPC64LE.Decls.va_operand_vec_opr -> src1: Vale.PPC64LE.Decls.va_operand_vec_opr -> src2: Vale.PPC64LE.Decls.va_operand_vec_opr -> va_s0: Vale.PPC64LE.Decls.va_state -> va_k: (_: Vale.PPC64LE.Decls.va_state -> _: Prims.unit -> Type0) -> Type0
{ "end_col": 25, "end_line": 88, "start_col": 2, "start_line": 82 }
Prims.Tot
val va_wp_VSwap (dst src: va_operand_vec_opr) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[ { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_wp_VSwap (dst:va_operand_vec_opr) (src:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.swap a 64) ==> va_k va_sM (())))
val va_wp_VSwap (dst src: va_operand_vec_opr) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 let va_wp_VSwap (dst src: va_operand_vec_opr) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 =
false
null
false
(va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst: va_value_vec_opr). let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let a:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.swap a 64) ==> va_k va_sM (())))
{ "checked_file": "Vale.AES.PPC64LE.PolyOps.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.QuickCodes.fsti.checked", "Vale.PPC64LE.QuickCode.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.InsVector.fsti.checked", "Vale.PPC64LE.InsMem.fsti.checked", "Vale.PPC64LE.InsBasic.fsti.checked", "Vale.PPC64LE.Decls.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Lemmas.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Math.Poly2.Bits.fsti.checked", "Vale.Math.Poly2.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GHash_BE.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.PPC64LE.PolyOps.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Decls.va_operand_vec_opr", "Vale.PPC64LE.Decls.va_state", "Prims.unit", "Prims.l_and", "Vale.PPC64LE.Decls.va_is_dst_vec_opr", "Vale.PPC64LE.Decls.va_is_src_vec_opr", "Prims.b2t", "Vale.PPC64LE.Decls.va_get_ok", "Prims.l_Forall", "Vale.PPC64LE.Decls.va_value_vec_opr", "Prims.l_imp", "Prims.eq2", "Vale.Math.Poly2_s.poly", "Vale.Math.Poly2.Bits_s.of_quad32", "Vale.PPC64LE.Decls.va_eval_vec_opr", "Vale.Math.Poly2.swap", "Vale.PPC64LE.Machine_s.state", "Vale.PPC64LE.Decls.va_upd_operand_vec_opr" ]
[]
module Vale.AES.PPC64LE.PolyOps open Vale.Def.Types_s open Vale.Arch.Types open Vale.Math.Poly2_s open Vale.Math.Poly2 open Vale.Math.Poly2.Bits_s open Vale.Math.Poly2.Bits open Vale.Math.Poly2.Lemmas open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.InsBasic open Vale.PPC64LE.InsMem open Vale.PPC64LE.InsVector open Vale.PPC64LE.QuickCode open Vale.PPC64LE.QuickCodes open Vale.AES.GHash_BE //-- VPolyAdd val va_code_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyAdd : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyAdd dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add a1 a2) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyAdd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add a1 a2) ==> va_k va_sM (()))) val va_wpProof_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyAdd dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyAdd dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyAdd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyAdd dst src1 src2)) = (va_QProc (va_code_VPolyAdd dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyAdd dst src1 src2) (va_wpProof_VPolyAdd dst src1 src2)) //-- //-- VPolyAnd val va_code_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyAnd : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyAnd dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.poly_and a1 a2) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyAnd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.poly_and a1 a2) ==> va_k va_sM (()))) val va_wpProof_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyAnd dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyAnd dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyAnd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyAnd dst src1 src2)) = (va_QProc (va_code_VPolyAnd dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyAnd dst src1 src2) (va_wpProof_VPolyAnd dst src1 src2)) //-- //-- VSwap val va_code_VSwap : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> Tot va_code val va_codegen_success_VSwap : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> Tot va_pbool val va_lemma_VSwap : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VSwap dst src) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.swap a 64) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VSwap (dst:va_operand_vec_opr) (src:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state
false
true
Vale.AES.PPC64LE.PolyOps.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wp_VSwap (dst src: va_operand_vec_opr) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[]
Vale.AES.PPC64LE.PolyOps.va_wp_VSwap
{ "file_name": "obj/Vale.AES.PPC64LE.PolyOps.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.PPC64LE.Decls.va_operand_vec_opr -> src: Vale.PPC64LE.Decls.va_operand_vec_opr -> va_s0: Vale.PPC64LE.Decls.va_state -> va_k: (_: Vale.PPC64LE.Decls.va_state -> _: Prims.unit -> Type0) -> Type0
{ "end_col": 52, "end_line": 124, "start_col": 2, "start_line": 120 }
Prims.Tot
val va_wp_VPolyMul (dst src1 src2: va_operand_vec_opr) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[ { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_wp_VPolyMul (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask a1 64) (Vale.Math.Poly2.mask a2 64)) (Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift a1 (-64)) (Vale.Math.Poly2_s.shift a2 (-64)))) ==> va_k va_sM (())))
val va_wp_VPolyMul (dst src1 src2: va_operand_vec_opr) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 let va_wp_VPolyMul (dst src1 src2: va_operand_vec_opr) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 =
false
null
false
(va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst: va_value_vec_opr). let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let a1:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let a2:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask a1 64) (Vale.Math.Poly2.mask a2 64)) (Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift a1 (- 64)) (Vale.Math.Poly2_s.shift a2 (- 64)))) ==> va_k va_sM (())))
{ "checked_file": "Vale.AES.PPC64LE.PolyOps.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.QuickCodes.fsti.checked", "Vale.PPC64LE.QuickCode.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.InsVector.fsti.checked", "Vale.PPC64LE.InsMem.fsti.checked", "Vale.PPC64LE.InsBasic.fsti.checked", "Vale.PPC64LE.Decls.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Lemmas.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Math.Poly2.Bits.fsti.checked", "Vale.Math.Poly2.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GHash_BE.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.PPC64LE.PolyOps.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Decls.va_operand_vec_opr", "Vale.PPC64LE.Decls.va_state", "Prims.unit", "Prims.l_and", "Vale.PPC64LE.Decls.va_is_dst_vec_opr", "Vale.PPC64LE.Decls.va_is_src_vec_opr", "Prims.b2t", "Vale.PPC64LE.Decls.va_get_ok", "Prims.l_Forall", "Vale.PPC64LE.Decls.va_value_vec_opr", "Prims.l_imp", "Prims.eq2", "Vale.Math.Poly2_s.poly", "Vale.Math.Poly2.Bits_s.of_quad32", "Vale.PPC64LE.Decls.va_eval_vec_opr", "Vale.Math.Poly2_s.add", "Vale.Math.Poly2_s.mul", "Vale.Math.Poly2.mask", "Vale.Math.Poly2_s.shift", "Prims.op_Minus", "Vale.PPC64LE.Machine_s.state", "Vale.PPC64LE.Decls.va_upd_operand_vec_opr" ]
[]
module Vale.AES.PPC64LE.PolyOps open Vale.Def.Types_s open Vale.Arch.Types open Vale.Math.Poly2_s open Vale.Math.Poly2 open Vale.Math.Poly2.Bits_s open Vale.Math.Poly2.Bits open Vale.Math.Poly2.Lemmas open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.InsBasic open Vale.PPC64LE.InsMem open Vale.PPC64LE.InsVector open Vale.PPC64LE.QuickCode open Vale.PPC64LE.QuickCodes open Vale.AES.GHash_BE //-- VPolyAdd val va_code_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyAdd : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyAdd dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add a1 a2) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyAdd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add a1 a2) ==> va_k va_sM (()))) val va_wpProof_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyAdd dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyAdd dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyAdd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyAdd dst src1 src2)) = (va_QProc (va_code_VPolyAdd dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyAdd dst src1 src2) (va_wpProof_VPolyAdd dst src1 src2)) //-- //-- VPolyAnd val va_code_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyAnd : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyAnd dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.poly_and a1 a2) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyAnd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.poly_and a1 a2) ==> va_k va_sM (()))) val va_wpProof_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyAnd dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyAnd dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyAnd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyAnd dst src1 src2)) = (va_QProc (va_code_VPolyAnd dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyAnd dst src1 src2) (va_wpProof_VPolyAnd dst src1 src2)) //-- //-- VSwap val va_code_VSwap : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> Tot va_code val va_codegen_success_VSwap : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> Tot va_pbool val va_lemma_VSwap : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VSwap dst src) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.swap a 64) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VSwap (dst:va_operand_vec_opr) (src:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.swap a 64) ==> va_k va_sM (()))) val va_wpProof_VSwap : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VSwap dst src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VSwap dst src) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VSwap (dst:va_operand_vec_opr) (src:va_operand_vec_opr) : (va_quickCode unit (va_code_VSwap dst src)) = (va_QProc (va_code_VSwap dst src) ([va_mod_vec_opr dst]) (va_wp_VSwap dst src) (va_wpProof_VSwap dst src)) //-- //-- VPolyMul val va_code_VPolyMul : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyMul : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyMul : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyMul dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask a1 64) (Vale.Math.Poly2.mask a2 64)) (Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift a1 (-64)) (Vale.Math.Poly2_s.shift a2 (-64)))) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyMul (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr)
false
true
Vale.AES.PPC64LE.PolyOps.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wp_VPolyMul (dst src1 src2: va_operand_vec_opr) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[]
Vale.AES.PPC64LE.PolyOps.va_wp_VPolyMul
{ "file_name": "obj/Vale.AES.PPC64LE.PolyOps.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.PPC64LE.Decls.va_operand_vec_opr -> src1: Vale.PPC64LE.Decls.va_operand_vec_opr -> src2: Vale.PPC64LE.Decls.va_operand_vec_opr -> va_s0: Vale.PPC64LE.Decls.va_state -> va_k: (_: Vale.PPC64LE.Decls.va_state -> _: Prims.unit -> Type0) -> Type0
{ "end_col": 25, "end_line": 169, "start_col": 2, "start_line": 161 }
Prims.Tot
val va_wp_VPolyMulLow (dst src1 src2: va_operand_vec_opr) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[ { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_wp_VPolyMulLow (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in l_or (Vale.Math.Poly2_s.shift a1 (-64) == zero) (Vale.Math.Poly2_s.shift a2 (-64) == zero)) /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask a1 64) (Vale.Math.Poly2.mask a2 64)) ==> va_k va_sM (())))
val va_wp_VPolyMulLow (dst src1 src2: va_operand_vec_opr) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 let va_wp_VPolyMulLow (dst src1 src2: va_operand_vec_opr) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 =
false
null
false
(va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (let a1:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let a2:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in l_or (Vale.Math.Poly2_s.shift a1 (- 64) == zero) (Vale.Math.Poly2_s.shift a2 (- 64) == zero)) /\ (forall (va_x_dst: va_value_vec_opr). let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let a1:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let a2:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask a1 64) (Vale.Math.Poly2.mask a2 64)) ==> va_k va_sM (())))
{ "checked_file": "Vale.AES.PPC64LE.PolyOps.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.QuickCodes.fsti.checked", "Vale.PPC64LE.QuickCode.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.InsVector.fsti.checked", "Vale.PPC64LE.InsMem.fsti.checked", "Vale.PPC64LE.InsBasic.fsti.checked", "Vale.PPC64LE.Decls.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Lemmas.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Math.Poly2.Bits.fsti.checked", "Vale.Math.Poly2.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GHash_BE.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.PPC64LE.PolyOps.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Decls.va_operand_vec_opr", "Vale.PPC64LE.Decls.va_state", "Prims.unit", "Prims.l_and", "Vale.PPC64LE.Decls.va_is_dst_vec_opr", "Vale.PPC64LE.Decls.va_is_src_vec_opr", "Prims.b2t", "Vale.PPC64LE.Decls.va_get_ok", "Prims.l_or", "Prims.eq2", "Vale.Math.Poly2_s.poly", "Vale.Math.Poly2_s.shift", "Prims.op_Minus", "Vale.Math.Poly2_s.zero", "Vale.Math.Poly2.Bits_s.of_quad32", "Vale.PPC64LE.Decls.va_eval_vec_opr", "Prims.l_Forall", "Vale.PPC64LE.Decls.va_value_vec_opr", "Prims.l_imp", "Vale.Math.Poly2_s.mul", "Vale.Math.Poly2.mask", "Vale.PPC64LE.Machine_s.state", "Vale.PPC64LE.Decls.va_upd_operand_vec_opr" ]
[]
module Vale.AES.PPC64LE.PolyOps open Vale.Def.Types_s open Vale.Arch.Types open Vale.Math.Poly2_s open Vale.Math.Poly2 open Vale.Math.Poly2.Bits_s open Vale.Math.Poly2.Bits open Vale.Math.Poly2.Lemmas open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.InsBasic open Vale.PPC64LE.InsMem open Vale.PPC64LE.InsVector open Vale.PPC64LE.QuickCode open Vale.PPC64LE.QuickCodes open Vale.AES.GHash_BE //-- VPolyAdd val va_code_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyAdd : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyAdd dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add a1 a2) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyAdd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add a1 a2) ==> va_k va_sM (()))) val va_wpProof_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyAdd dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyAdd dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyAdd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyAdd dst src1 src2)) = (va_QProc (va_code_VPolyAdd dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyAdd dst src1 src2) (va_wpProof_VPolyAdd dst src1 src2)) //-- //-- VPolyAnd val va_code_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyAnd : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyAnd dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.poly_and a1 a2) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyAnd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.poly_and a1 a2) ==> va_k va_sM (()))) val va_wpProof_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyAnd dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyAnd dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyAnd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyAnd dst src1 src2)) = (va_QProc (va_code_VPolyAnd dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyAnd dst src1 src2) (va_wpProof_VPolyAnd dst src1 src2)) //-- //-- VSwap val va_code_VSwap : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> Tot va_code val va_codegen_success_VSwap : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> Tot va_pbool val va_lemma_VSwap : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VSwap dst src) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.swap a 64) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VSwap (dst:va_operand_vec_opr) (src:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.swap a 64) ==> va_k va_sM (()))) val va_wpProof_VSwap : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VSwap dst src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VSwap dst src) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VSwap (dst:va_operand_vec_opr) (src:va_operand_vec_opr) : (va_quickCode unit (va_code_VSwap dst src)) = (va_QProc (va_code_VSwap dst src) ([va_mod_vec_opr dst]) (va_wp_VSwap dst src) (va_wpProof_VSwap dst src)) //-- //-- VPolyMul val va_code_VPolyMul : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyMul : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyMul : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyMul dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask a1 64) (Vale.Math.Poly2.mask a2 64)) (Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift a1 (-64)) (Vale.Math.Poly2_s.shift a2 (-64)))) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyMul (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask a1 64) (Vale.Math.Poly2.mask a2 64)) (Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift a1 (-64)) (Vale.Math.Poly2_s.shift a2 (-64)))) ==> va_k va_sM (()))) val va_wpProof_VPolyMul : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyMul dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyMul dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyMul (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyMul dst src1 src2)) = (va_QProc (va_code_VPolyMul dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyMul dst src1 src2) (va_wpProof_VPolyMul dst src1 src2)) //-- //-- VPolyMulLow val va_code_VPolyMulLow : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyMulLow : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyMulLow : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyMulLow dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in l_or (Vale.Math.Poly2_s.shift a1 (-64) == zero) (Vale.Math.Poly2_s.shift a2 (-64) == zero)))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask a1 64) (Vale.Math.Poly2.mask a2 64)) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyMulLow (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr)
false
true
Vale.AES.PPC64LE.PolyOps.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wp_VPolyMulLow (dst src1 src2: va_operand_vec_opr) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[]
Vale.AES.PPC64LE.PolyOps.va_wp_VPolyMulLow
{ "file_name": "obj/Vale.AES.PPC64LE.PolyOps.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.PPC64LE.Decls.va_operand_vec_opr -> src1: Vale.PPC64LE.Decls.va_operand_vec_opr -> src2: Vale.PPC64LE.Decls.va_operand_vec_opr -> va_s0: Vale.PPC64LE.Decls.va_state -> va_k: (_: Vale.PPC64LE.Decls.va_state -> _: Prims.unit -> Type0) -> Type0
{ "end_col": 84, "end_line": 219, "start_col": 2, "start_line": 209 }
Prims.Tot
val va_wp_VPolyMulHigh (dst src1 src2: va_operand_vec_opr) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[ { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_wp_VPolyMulHigh (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in l_or (Vale.Math.Poly2.mask a1 64 == zero) (Vale.Math.Poly2.mask a2 64 == zero)) /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift a1 (-64)) (Vale.Math.Poly2_s.shift a2 (-64))) ==> va_k va_sM (())))
val va_wp_VPolyMulHigh (dst src1 src2: va_operand_vec_opr) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 let va_wp_VPolyMulHigh (dst src1 src2: va_operand_vec_opr) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 =
false
null
false
(va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (let a1:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let a2:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in l_or (Vale.Math.Poly2.mask a1 64 == zero) (Vale.Math.Poly2.mask a2 64 == zero)) /\ (forall (va_x_dst: va_value_vec_opr). let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let a1:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let a2:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift a1 (- 64)) (Vale.Math.Poly2_s.shift a2 (- 64))) ==> va_k va_sM (())))
{ "checked_file": "Vale.AES.PPC64LE.PolyOps.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.QuickCodes.fsti.checked", "Vale.PPC64LE.QuickCode.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.InsVector.fsti.checked", "Vale.PPC64LE.InsMem.fsti.checked", "Vale.PPC64LE.InsBasic.fsti.checked", "Vale.PPC64LE.Decls.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Lemmas.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Math.Poly2.Bits.fsti.checked", "Vale.Math.Poly2.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GHash_BE.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.PPC64LE.PolyOps.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Decls.va_operand_vec_opr", "Vale.PPC64LE.Decls.va_state", "Prims.unit", "Prims.l_and", "Vale.PPC64LE.Decls.va_is_dst_vec_opr", "Vale.PPC64LE.Decls.va_is_src_vec_opr", "Prims.b2t", "Vale.PPC64LE.Decls.va_get_ok", "Prims.l_or", "Prims.eq2", "Vale.Math.Poly2_s.poly", "Vale.Math.Poly2.mask", "Vale.Math.Poly2_s.zero", "Vale.Math.Poly2.Bits_s.of_quad32", "Vale.PPC64LE.Decls.va_eval_vec_opr", "Prims.l_Forall", "Vale.PPC64LE.Decls.va_value_vec_opr", "Prims.l_imp", "Vale.Math.Poly2_s.mul", "Vale.Math.Poly2_s.shift", "Prims.op_Minus", "Vale.PPC64LE.Machine_s.state", "Vale.PPC64LE.Decls.va_upd_operand_vec_opr" ]
[]
module Vale.AES.PPC64LE.PolyOps open Vale.Def.Types_s open Vale.Arch.Types open Vale.Math.Poly2_s open Vale.Math.Poly2 open Vale.Math.Poly2.Bits_s open Vale.Math.Poly2.Bits open Vale.Math.Poly2.Lemmas open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.InsBasic open Vale.PPC64LE.InsMem open Vale.PPC64LE.InsVector open Vale.PPC64LE.QuickCode open Vale.PPC64LE.QuickCodes open Vale.AES.GHash_BE //-- VPolyAdd val va_code_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyAdd : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyAdd dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add a1 a2) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyAdd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add a1 a2) ==> va_k va_sM (()))) val va_wpProof_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyAdd dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyAdd dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyAdd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyAdd dst src1 src2)) = (va_QProc (va_code_VPolyAdd dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyAdd dst src1 src2) (va_wpProof_VPolyAdd dst src1 src2)) //-- //-- VPolyAnd val va_code_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyAnd : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyAnd dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.poly_and a1 a2) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyAnd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.poly_and a1 a2) ==> va_k va_sM (()))) val va_wpProof_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyAnd dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyAnd dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyAnd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyAnd dst src1 src2)) = (va_QProc (va_code_VPolyAnd dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyAnd dst src1 src2) (va_wpProof_VPolyAnd dst src1 src2)) //-- //-- VSwap val va_code_VSwap : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> Tot va_code val va_codegen_success_VSwap : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> Tot va_pbool val va_lemma_VSwap : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VSwap dst src) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.swap a 64) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VSwap (dst:va_operand_vec_opr) (src:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.swap a 64) ==> va_k va_sM (()))) val va_wpProof_VSwap : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VSwap dst src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VSwap dst src) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VSwap (dst:va_operand_vec_opr) (src:va_operand_vec_opr) : (va_quickCode unit (va_code_VSwap dst src)) = (va_QProc (va_code_VSwap dst src) ([va_mod_vec_opr dst]) (va_wp_VSwap dst src) (va_wpProof_VSwap dst src)) //-- //-- VPolyMul val va_code_VPolyMul : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyMul : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyMul : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyMul dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask a1 64) (Vale.Math.Poly2.mask a2 64)) (Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift a1 (-64)) (Vale.Math.Poly2_s.shift a2 (-64)))) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyMul (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask a1 64) (Vale.Math.Poly2.mask a2 64)) (Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift a1 (-64)) (Vale.Math.Poly2_s.shift a2 (-64)))) ==> va_k va_sM (()))) val va_wpProof_VPolyMul : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyMul dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyMul dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyMul (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyMul dst src1 src2)) = (va_QProc (va_code_VPolyMul dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyMul dst src1 src2) (va_wpProof_VPolyMul dst src1 src2)) //-- //-- VPolyMulLow val va_code_VPolyMulLow : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyMulLow : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyMulLow : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyMulLow dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in l_or (Vale.Math.Poly2_s.shift a1 (-64) == zero) (Vale.Math.Poly2_s.shift a2 (-64) == zero)))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask a1 64) (Vale.Math.Poly2.mask a2 64)) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyMulLow (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in l_or (Vale.Math.Poly2_s.shift a1 (-64) == zero) (Vale.Math.Poly2_s.shift a2 (-64) == zero)) /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask a1 64) (Vale.Math.Poly2.mask a2 64)) ==> va_k va_sM (()))) val va_wpProof_VPolyMulLow : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyMulLow dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyMulLow dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyMulLow (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyMulLow dst src1 src2)) = (va_QProc (va_code_VPolyMulLow dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyMulLow dst src1 src2) (va_wpProof_VPolyMulLow dst src1 src2)) //-- //-- VPolyMulHigh val va_code_VPolyMulHigh : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyMulHigh : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyMulHigh : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyMulHigh dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in l_or (Vale.Math.Poly2.mask a1 64 == zero) (Vale.Math.Poly2.mask a2 64 == zero)))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift a1 (-64)) (Vale.Math.Poly2_s.shift a2 (-64))) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyMulHigh (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr)
false
true
Vale.AES.PPC64LE.PolyOps.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wp_VPolyMulHigh (dst src1 src2: va_operand_vec_opr) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[]
Vale.AES.PPC64LE.PolyOps.va_wp_VPolyMulHigh
{ "file_name": "obj/Vale.AES.PPC64LE.PolyOps.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.PPC64LE.Decls.va_operand_vec_opr -> src1: Vale.PPC64LE.Decls.va_operand_vec_opr -> src2: Vale.PPC64LE.Decls.va_operand_vec_opr -> va_s0: Vale.PPC64LE.Decls.va_state -> va_k: (_: Vale.PPC64LE.Decls.va_state -> _: Prims.unit -> Type0) -> Type0
{ "end_col": 96, "end_line": 267, "start_col": 2, "start_line": 258 }
Prims.Tot
val va_quick_VPolyAdd (dst src1 src2: va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyAdd dst src1 src2))
[ { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_quick_VPolyAdd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyAdd dst src1 src2)) = (va_QProc (va_code_VPolyAdd dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyAdd dst src1 src2) (va_wpProof_VPolyAdd dst src1 src2))
val va_quick_VPolyAdd (dst src1 src2: va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyAdd dst src1 src2)) let va_quick_VPolyAdd (dst src1 src2: va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyAdd dst src1 src2)) =
false
null
false
(va_QProc (va_code_VPolyAdd dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyAdd dst src1 src2) (va_wpProof_VPolyAdd dst src1 src2))
{ "checked_file": "Vale.AES.PPC64LE.PolyOps.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.QuickCodes.fsti.checked", "Vale.PPC64LE.QuickCode.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.InsVector.fsti.checked", "Vale.PPC64LE.InsMem.fsti.checked", "Vale.PPC64LE.InsBasic.fsti.checked", "Vale.PPC64LE.Decls.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Lemmas.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Math.Poly2.Bits.fsti.checked", "Vale.Math.Poly2.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GHash_BE.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.PPC64LE.PolyOps.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Decls.va_operand_vec_opr", "Vale.PPC64LE.QuickCode.va_QProc", "Prims.unit", "Vale.AES.PPC64LE.PolyOps.va_code_VPolyAdd", "Prims.Cons", "Vale.PPC64LE.QuickCode.mod_t", "Vale.PPC64LE.QuickCode.va_mod_vec_opr", "Prims.Nil", "Vale.AES.PPC64LE.PolyOps.va_wp_VPolyAdd", "Vale.AES.PPC64LE.PolyOps.va_wpProof_VPolyAdd", "Vale.PPC64LE.QuickCode.va_quickCode" ]
[]
module Vale.AES.PPC64LE.PolyOps open Vale.Def.Types_s open Vale.Arch.Types open Vale.Math.Poly2_s open Vale.Math.Poly2 open Vale.Math.Poly2.Bits_s open Vale.Math.Poly2.Bits open Vale.Math.Poly2.Lemmas open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.InsBasic open Vale.PPC64LE.InsMem open Vale.PPC64LE.InsVector open Vale.PPC64LE.QuickCode open Vale.PPC64LE.QuickCodes open Vale.AES.GHash_BE //-- VPolyAdd val va_code_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyAdd : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyAdd dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add a1 a2) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyAdd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add a1 a2) ==> va_k va_sM (()))) val va_wpProof_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyAdd dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyAdd dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyAdd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr)
false
false
Vale.AES.PPC64LE.PolyOps.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_quick_VPolyAdd (dst src1 src2: va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyAdd dst src1 src2))
[]
Vale.AES.PPC64LE.PolyOps.va_quick_VPolyAdd
{ "file_name": "obj/Vale.AES.PPC64LE.PolyOps.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.PPC64LE.Decls.va_operand_vec_opr -> src1: Vale.PPC64LE.Decls.va_operand_vec_opr -> src2: Vale.PPC64LE.Decls.va_operand_vec_opr -> Vale.PPC64LE.QuickCode.va_quickCode Prims.unit (Vale.AES.PPC64LE.PolyOps.va_code_VPolyAdd dst src1 src2)
{ "end_col": 40, "end_line": 58, "start_col": 2, "start_line": 57 }
Prims.Tot
val va_quick_VPolyMul (dst src1 src2: va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyMul dst src1 src2))
[ { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_quick_VPolyMul (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyMul dst src1 src2)) = (va_QProc (va_code_VPolyMul dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyMul dst src1 src2) (va_wpProof_VPolyMul dst src1 src2))
val va_quick_VPolyMul (dst src1 src2: va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyMul dst src1 src2)) let va_quick_VPolyMul (dst src1 src2: va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyMul dst src1 src2)) =
false
null
false
(va_QProc (va_code_VPolyMul dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyMul dst src1 src2) (va_wpProof_VPolyMul dst src1 src2))
{ "checked_file": "Vale.AES.PPC64LE.PolyOps.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.QuickCodes.fsti.checked", "Vale.PPC64LE.QuickCode.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.InsVector.fsti.checked", "Vale.PPC64LE.InsMem.fsti.checked", "Vale.PPC64LE.InsBasic.fsti.checked", "Vale.PPC64LE.Decls.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Lemmas.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Math.Poly2.Bits.fsti.checked", "Vale.Math.Poly2.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GHash_BE.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.PPC64LE.PolyOps.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Decls.va_operand_vec_opr", "Vale.PPC64LE.QuickCode.va_QProc", "Prims.unit", "Vale.AES.PPC64LE.PolyOps.va_code_VPolyMul", "Prims.Cons", "Vale.PPC64LE.QuickCode.mod_t", "Vale.PPC64LE.QuickCode.va_mod_vec_opr", "Prims.Nil", "Vale.AES.PPC64LE.PolyOps.va_wp_VPolyMul", "Vale.AES.PPC64LE.PolyOps.va_wpProof_VPolyMul", "Vale.PPC64LE.QuickCode.va_quickCode" ]
[]
module Vale.AES.PPC64LE.PolyOps open Vale.Def.Types_s open Vale.Arch.Types open Vale.Math.Poly2_s open Vale.Math.Poly2 open Vale.Math.Poly2.Bits_s open Vale.Math.Poly2.Bits open Vale.Math.Poly2.Lemmas open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.InsBasic open Vale.PPC64LE.InsMem open Vale.PPC64LE.InsVector open Vale.PPC64LE.QuickCode open Vale.PPC64LE.QuickCodes open Vale.AES.GHash_BE //-- VPolyAdd val va_code_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyAdd : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyAdd dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add a1 a2) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyAdd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add a1 a2) ==> va_k va_sM (()))) val va_wpProof_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyAdd dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyAdd dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyAdd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyAdd dst src1 src2)) = (va_QProc (va_code_VPolyAdd dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyAdd dst src1 src2) (va_wpProof_VPolyAdd dst src1 src2)) //-- //-- VPolyAnd val va_code_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyAnd : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyAnd dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.poly_and a1 a2) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyAnd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.poly_and a1 a2) ==> va_k va_sM (()))) val va_wpProof_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyAnd dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyAnd dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyAnd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyAnd dst src1 src2)) = (va_QProc (va_code_VPolyAnd dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyAnd dst src1 src2) (va_wpProof_VPolyAnd dst src1 src2)) //-- //-- VSwap val va_code_VSwap : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> Tot va_code val va_codegen_success_VSwap : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> Tot va_pbool val va_lemma_VSwap : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VSwap dst src) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.swap a 64) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VSwap (dst:va_operand_vec_opr) (src:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.swap a 64) ==> va_k va_sM (()))) val va_wpProof_VSwap : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VSwap dst src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VSwap dst src) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VSwap (dst:va_operand_vec_opr) (src:va_operand_vec_opr) : (va_quickCode unit (va_code_VSwap dst src)) = (va_QProc (va_code_VSwap dst src) ([va_mod_vec_opr dst]) (va_wp_VSwap dst src) (va_wpProof_VSwap dst src)) //-- //-- VPolyMul val va_code_VPolyMul : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyMul : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyMul : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyMul dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask a1 64) (Vale.Math.Poly2.mask a2 64)) (Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift a1 (-64)) (Vale.Math.Poly2_s.shift a2 (-64)))) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyMul (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask a1 64) (Vale.Math.Poly2.mask a2 64)) (Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift a1 (-64)) (Vale.Math.Poly2_s.shift a2 (-64)))) ==> va_k va_sM (()))) val va_wpProof_VPolyMul : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyMul dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyMul dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyMul (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr)
false
false
Vale.AES.PPC64LE.PolyOps.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_quick_VPolyMul (dst src1 src2: va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyMul dst src1 src2))
[]
Vale.AES.PPC64LE.PolyOps.va_quick_VPolyMul
{ "file_name": "obj/Vale.AES.PPC64LE.PolyOps.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.PPC64LE.Decls.va_operand_vec_opr -> src1: Vale.PPC64LE.Decls.va_operand_vec_opr -> src2: Vale.PPC64LE.Decls.va_operand_vec_opr -> Vale.PPC64LE.QuickCode.va_quickCode Prims.unit (Vale.AES.PPC64LE.PolyOps.va_code_VPolyMul dst src1 src2)
{ "end_col": 40, "end_line": 181, "start_col": 2, "start_line": 180 }
Prims.Tot
val va_quick_VSwap (dst src: va_operand_vec_opr) : (va_quickCode unit (va_code_VSwap dst src))
[ { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_quick_VSwap (dst:va_operand_vec_opr) (src:va_operand_vec_opr) : (va_quickCode unit (va_code_VSwap dst src)) = (va_QProc (va_code_VSwap dst src) ([va_mod_vec_opr dst]) (va_wp_VSwap dst src) (va_wpProof_VSwap dst src))
val va_quick_VSwap (dst src: va_operand_vec_opr) : (va_quickCode unit (va_code_VSwap dst src)) let va_quick_VSwap (dst src: va_operand_vec_opr) : (va_quickCode unit (va_code_VSwap dst src)) =
false
null
false
(va_QProc (va_code_VSwap dst src) ([va_mod_vec_opr dst]) (va_wp_VSwap dst src) (va_wpProof_VSwap dst src))
{ "checked_file": "Vale.AES.PPC64LE.PolyOps.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.QuickCodes.fsti.checked", "Vale.PPC64LE.QuickCode.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.InsVector.fsti.checked", "Vale.PPC64LE.InsMem.fsti.checked", "Vale.PPC64LE.InsBasic.fsti.checked", "Vale.PPC64LE.Decls.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Lemmas.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Math.Poly2.Bits.fsti.checked", "Vale.Math.Poly2.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GHash_BE.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.PPC64LE.PolyOps.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Decls.va_operand_vec_opr", "Vale.PPC64LE.QuickCode.va_QProc", "Prims.unit", "Vale.AES.PPC64LE.PolyOps.va_code_VSwap", "Prims.Cons", "Vale.PPC64LE.QuickCode.mod_t", "Vale.PPC64LE.QuickCode.va_mod_vec_opr", "Prims.Nil", "Vale.AES.PPC64LE.PolyOps.va_wp_VSwap", "Vale.AES.PPC64LE.PolyOps.va_wpProof_VSwap", "Vale.PPC64LE.QuickCode.va_quickCode" ]
[]
module Vale.AES.PPC64LE.PolyOps open Vale.Def.Types_s open Vale.Arch.Types open Vale.Math.Poly2_s open Vale.Math.Poly2 open Vale.Math.Poly2.Bits_s open Vale.Math.Poly2.Bits open Vale.Math.Poly2.Lemmas open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.InsBasic open Vale.PPC64LE.InsMem open Vale.PPC64LE.InsVector open Vale.PPC64LE.QuickCode open Vale.PPC64LE.QuickCodes open Vale.AES.GHash_BE //-- VPolyAdd val va_code_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyAdd : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyAdd dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add a1 a2) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyAdd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add a1 a2) ==> va_k va_sM (()))) val va_wpProof_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyAdd dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyAdd dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyAdd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyAdd dst src1 src2)) = (va_QProc (va_code_VPolyAdd dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyAdd dst src1 src2) (va_wpProof_VPolyAdd dst src1 src2)) //-- //-- VPolyAnd val va_code_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyAnd : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyAnd dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.poly_and a1 a2) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyAnd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.poly_and a1 a2) ==> va_k va_sM (()))) val va_wpProof_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyAnd dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyAnd dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyAnd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyAnd dst src1 src2)) = (va_QProc (va_code_VPolyAnd dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyAnd dst src1 src2) (va_wpProof_VPolyAnd dst src1 src2)) //-- //-- VSwap val va_code_VSwap : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> Tot va_code val va_codegen_success_VSwap : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> Tot va_pbool val va_lemma_VSwap : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VSwap dst src) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.swap a 64) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VSwap (dst:va_operand_vec_opr) (src:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.swap a 64) ==> va_k va_sM (()))) val va_wpProof_VSwap : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VSwap dst src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VSwap dst src) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VSwap (dst:va_operand_vec_opr) (src:va_operand_vec_opr) : (va_quickCode unit
false
false
Vale.AES.PPC64LE.PolyOps.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_quick_VSwap (dst src: va_operand_vec_opr) : (va_quickCode unit (va_code_VSwap dst src))
[]
Vale.AES.PPC64LE.PolyOps.va_quick_VSwap
{ "file_name": "obj/Vale.AES.PPC64LE.PolyOps.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.PPC64LE.Decls.va_operand_vec_opr -> src: Vale.PPC64LE.Decls.va_operand_vec_opr -> Vale.PPC64LE.QuickCode.va_quickCode Prims.unit (Vale.AES.PPC64LE.PolyOps.va_code_VSwap dst src)
{ "end_col": 13, "end_line": 136, "start_col": 2, "start_line": 135 }
Prims.Tot
val va_quick_VPolyMulLow (dst src1 src2: va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyMulLow dst src1 src2))
[ { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_quick_VPolyMulLow (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyMulLow dst src1 src2)) = (va_QProc (va_code_VPolyMulLow dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyMulLow dst src1 src2) (va_wpProof_VPolyMulLow dst src1 src2))
val va_quick_VPolyMulLow (dst src1 src2: va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyMulLow dst src1 src2)) let va_quick_VPolyMulLow (dst src1 src2: va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyMulLow dst src1 src2)) =
false
null
false
(va_QProc (va_code_VPolyMulLow dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyMulLow dst src1 src2) (va_wpProof_VPolyMulLow dst src1 src2))
{ "checked_file": "Vale.AES.PPC64LE.PolyOps.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.QuickCodes.fsti.checked", "Vale.PPC64LE.QuickCode.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.InsVector.fsti.checked", "Vale.PPC64LE.InsMem.fsti.checked", "Vale.PPC64LE.InsBasic.fsti.checked", "Vale.PPC64LE.Decls.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Lemmas.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Math.Poly2.Bits.fsti.checked", "Vale.Math.Poly2.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GHash_BE.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.PPC64LE.PolyOps.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Decls.va_operand_vec_opr", "Vale.PPC64LE.QuickCode.va_QProc", "Prims.unit", "Vale.AES.PPC64LE.PolyOps.va_code_VPolyMulLow", "Prims.Cons", "Vale.PPC64LE.QuickCode.mod_t", "Vale.PPC64LE.QuickCode.va_mod_vec_opr", "Prims.Nil", "Vale.AES.PPC64LE.PolyOps.va_wp_VPolyMulLow", "Vale.AES.PPC64LE.PolyOps.va_wpProof_VPolyMulLow", "Vale.PPC64LE.QuickCode.va_quickCode" ]
[]
module Vale.AES.PPC64LE.PolyOps open Vale.Def.Types_s open Vale.Arch.Types open Vale.Math.Poly2_s open Vale.Math.Poly2 open Vale.Math.Poly2.Bits_s open Vale.Math.Poly2.Bits open Vale.Math.Poly2.Lemmas open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.InsBasic open Vale.PPC64LE.InsMem open Vale.PPC64LE.InsVector open Vale.PPC64LE.QuickCode open Vale.PPC64LE.QuickCodes open Vale.AES.GHash_BE //-- VPolyAdd val va_code_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyAdd : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyAdd dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add a1 a2) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyAdd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add a1 a2) ==> va_k va_sM (()))) val va_wpProof_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyAdd dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyAdd dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyAdd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyAdd dst src1 src2)) = (va_QProc (va_code_VPolyAdd dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyAdd dst src1 src2) (va_wpProof_VPolyAdd dst src1 src2)) //-- //-- VPolyAnd val va_code_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyAnd : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyAnd dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.poly_and a1 a2) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyAnd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.poly_and a1 a2) ==> va_k va_sM (()))) val va_wpProof_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyAnd dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyAnd dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyAnd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyAnd dst src1 src2)) = (va_QProc (va_code_VPolyAnd dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyAnd dst src1 src2) (va_wpProof_VPolyAnd dst src1 src2)) //-- //-- VSwap val va_code_VSwap : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> Tot va_code val va_codegen_success_VSwap : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> Tot va_pbool val va_lemma_VSwap : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VSwap dst src) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.swap a 64) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VSwap (dst:va_operand_vec_opr) (src:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.swap a 64) ==> va_k va_sM (()))) val va_wpProof_VSwap : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VSwap dst src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VSwap dst src) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VSwap (dst:va_operand_vec_opr) (src:va_operand_vec_opr) : (va_quickCode unit (va_code_VSwap dst src)) = (va_QProc (va_code_VSwap dst src) ([va_mod_vec_opr dst]) (va_wp_VSwap dst src) (va_wpProof_VSwap dst src)) //-- //-- VPolyMul val va_code_VPolyMul : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyMul : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyMul : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyMul dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask a1 64) (Vale.Math.Poly2.mask a2 64)) (Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift a1 (-64)) (Vale.Math.Poly2_s.shift a2 (-64)))) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyMul (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask a1 64) (Vale.Math.Poly2.mask a2 64)) (Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift a1 (-64)) (Vale.Math.Poly2_s.shift a2 (-64)))) ==> va_k va_sM (()))) val va_wpProof_VPolyMul : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyMul dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyMul dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyMul (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyMul dst src1 src2)) = (va_QProc (va_code_VPolyMul dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyMul dst src1 src2) (va_wpProof_VPolyMul dst src1 src2)) //-- //-- VPolyMulLow val va_code_VPolyMulLow : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyMulLow : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyMulLow : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyMulLow dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in l_or (Vale.Math.Poly2_s.shift a1 (-64) == zero) (Vale.Math.Poly2_s.shift a2 (-64) == zero)))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask a1 64) (Vale.Math.Poly2.mask a2 64)) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyMulLow (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in l_or (Vale.Math.Poly2_s.shift a1 (-64) == zero) (Vale.Math.Poly2_s.shift a2 (-64) == zero)) /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask a1 64) (Vale.Math.Poly2.mask a2 64)) ==> va_k va_sM (()))) val va_wpProof_VPolyMulLow : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyMulLow dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyMulLow dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyMulLow (dst:va_operand_vec_opr) (src1:va_operand_vec_opr)
false
false
Vale.AES.PPC64LE.PolyOps.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_quick_VPolyMulLow (dst src1 src2: va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyMulLow dst src1 src2))
[]
Vale.AES.PPC64LE.PolyOps.va_quick_VPolyMulLow
{ "file_name": "obj/Vale.AES.PPC64LE.PolyOps.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.PPC64LE.Decls.va_operand_vec_opr -> src1: Vale.PPC64LE.Decls.va_operand_vec_opr -> src2: Vale.PPC64LE.Decls.va_operand_vec_opr -> Vale.PPC64LE.QuickCode.va_quickCode Prims.unit (Vale.AES.PPC64LE.PolyOps.va_code_VPolyMulLow dst src1 src2)
{ "end_col": 49, "end_line": 231, "start_col": 2, "start_line": 230 }
Prims.Tot
val va_quick_VPolyAnd (dst src1 src2: va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyAnd dst src1 src2))
[ { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_quick_VPolyAnd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyAnd dst src1 src2)) = (va_QProc (va_code_VPolyAnd dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyAnd dst src1 src2) (va_wpProof_VPolyAnd dst src1 src2))
val va_quick_VPolyAnd (dst src1 src2: va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyAnd dst src1 src2)) let va_quick_VPolyAnd (dst src1 src2: va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyAnd dst src1 src2)) =
false
null
false
(va_QProc (va_code_VPolyAnd dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyAnd dst src1 src2) (va_wpProof_VPolyAnd dst src1 src2))
{ "checked_file": "Vale.AES.PPC64LE.PolyOps.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.QuickCodes.fsti.checked", "Vale.PPC64LE.QuickCode.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.InsVector.fsti.checked", "Vale.PPC64LE.InsMem.fsti.checked", "Vale.PPC64LE.InsBasic.fsti.checked", "Vale.PPC64LE.Decls.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Lemmas.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Math.Poly2.Bits.fsti.checked", "Vale.Math.Poly2.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GHash_BE.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.PPC64LE.PolyOps.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Decls.va_operand_vec_opr", "Vale.PPC64LE.QuickCode.va_QProc", "Prims.unit", "Vale.AES.PPC64LE.PolyOps.va_code_VPolyAnd", "Prims.Cons", "Vale.PPC64LE.QuickCode.mod_t", "Vale.PPC64LE.QuickCode.va_mod_vec_opr", "Prims.Nil", "Vale.AES.PPC64LE.PolyOps.va_wp_VPolyAnd", "Vale.AES.PPC64LE.PolyOps.va_wpProof_VPolyAnd", "Vale.PPC64LE.QuickCode.va_quickCode" ]
[]
module Vale.AES.PPC64LE.PolyOps open Vale.Def.Types_s open Vale.Arch.Types open Vale.Math.Poly2_s open Vale.Math.Poly2 open Vale.Math.Poly2.Bits_s open Vale.Math.Poly2.Bits open Vale.Math.Poly2.Lemmas open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.InsBasic open Vale.PPC64LE.InsMem open Vale.PPC64LE.InsVector open Vale.PPC64LE.QuickCode open Vale.PPC64LE.QuickCodes open Vale.AES.GHash_BE //-- VPolyAdd val va_code_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyAdd : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyAdd dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add a1 a2) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyAdd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add a1 a2) ==> va_k va_sM (()))) val va_wpProof_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyAdd dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyAdd dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyAdd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyAdd dst src1 src2)) = (va_QProc (va_code_VPolyAdd dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyAdd dst src1 src2) (va_wpProof_VPolyAdd dst src1 src2)) //-- //-- VPolyAnd val va_code_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyAnd : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyAnd dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.poly_and a1 a2) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyAnd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.poly_and a1 a2) ==> va_k va_sM (()))) val va_wpProof_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyAnd dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyAnd dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyAnd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr)
false
false
Vale.AES.PPC64LE.PolyOps.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_quick_VPolyAnd (dst src1 src2: va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyAnd dst src1 src2))
[]
Vale.AES.PPC64LE.PolyOps.va_quick_VPolyAnd
{ "file_name": "obj/Vale.AES.PPC64LE.PolyOps.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.PPC64LE.Decls.va_operand_vec_opr -> src1: Vale.PPC64LE.Decls.va_operand_vec_opr -> src2: Vale.PPC64LE.Decls.va_operand_vec_opr -> Vale.PPC64LE.QuickCode.va_quickCode Prims.unit (Vale.AES.PPC64LE.PolyOps.va_code_VPolyAnd dst src1 src2)
{ "end_col": 40, "end_line": 100, "start_col": 2, "start_line": 99 }
Prims.Tot
val va_quick_VPolyMulHigh (dst src1 src2: va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyMulHigh dst src1 src2))
[ { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_quick_VPolyMulHigh (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyMulHigh dst src1 src2)) = (va_QProc (va_code_VPolyMulHigh dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyMulHigh dst src1 src2) (va_wpProof_VPolyMulHigh dst src1 src2))
val va_quick_VPolyMulHigh (dst src1 src2: va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyMulHigh dst src1 src2)) let va_quick_VPolyMulHigh (dst src1 src2: va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyMulHigh dst src1 src2)) =
false
null
false
(va_QProc (va_code_VPolyMulHigh dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyMulHigh dst src1 src2) (va_wpProof_VPolyMulHigh dst src1 src2))
{ "checked_file": "Vale.AES.PPC64LE.PolyOps.fsti.checked", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.QuickCodes.fsti.checked", "Vale.PPC64LE.QuickCode.fst.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.InsVector.fsti.checked", "Vale.PPC64LE.InsMem.fsti.checked", "Vale.PPC64LE.InsBasic.fsti.checked", "Vale.PPC64LE.Decls.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Lemmas.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Math.Poly2.Bits.fsti.checked", "Vale.Math.Poly2.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GHash_BE.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.PPC64LE.PolyOps.fsti" }
[ "total" ]
[ "Vale.PPC64LE.Decls.va_operand_vec_opr", "Vale.PPC64LE.QuickCode.va_QProc", "Prims.unit", "Vale.AES.PPC64LE.PolyOps.va_code_VPolyMulHigh", "Prims.Cons", "Vale.PPC64LE.QuickCode.mod_t", "Vale.PPC64LE.QuickCode.va_mod_vec_opr", "Prims.Nil", "Vale.AES.PPC64LE.PolyOps.va_wp_VPolyMulHigh", "Vale.AES.PPC64LE.PolyOps.va_wpProof_VPolyMulHigh", "Vale.PPC64LE.QuickCode.va_quickCode" ]
[]
module Vale.AES.PPC64LE.PolyOps open Vale.Def.Types_s open Vale.Arch.Types open Vale.Math.Poly2_s open Vale.Math.Poly2 open Vale.Math.Poly2.Bits_s open Vale.Math.Poly2.Bits open Vale.Math.Poly2.Lemmas open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.InsBasic open Vale.PPC64LE.InsMem open Vale.PPC64LE.InsVector open Vale.PPC64LE.QuickCode open Vale.PPC64LE.QuickCodes open Vale.AES.GHash_BE //-- VPolyAdd val va_code_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyAdd : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyAdd dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add a1 a2) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyAdd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add a1 a2) ==> va_k va_sM (()))) val va_wpProof_VPolyAdd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyAdd dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyAdd dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyAdd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyAdd dst src1 src2)) = (va_QProc (va_code_VPolyAdd dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyAdd dst src1 src2) (va_wpProof_VPolyAdd dst src1 src2)) //-- //-- VPolyAnd val va_code_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyAnd : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyAnd dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.poly_and a1 a2) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyAnd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.poly_and a1 a2) ==> va_k va_sM (()))) val va_wpProof_VPolyAnd : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyAnd dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyAnd dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyAnd (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyAnd dst src1 src2)) = (va_QProc (va_code_VPolyAnd dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyAnd dst src1 src2) (va_wpProof_VPolyAnd dst src1 src2)) //-- //-- VSwap val va_code_VSwap : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> Tot va_code val va_codegen_success_VSwap : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> Tot va_pbool val va_lemma_VSwap : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VSwap dst src) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.swap a 64) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VSwap (dst:va_operand_vec_opr) (src:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2.swap a 64) ==> va_k va_sM (()))) val va_wpProof_VSwap : dst:va_operand_vec_opr -> src:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VSwap dst src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VSwap dst src) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VSwap (dst:va_operand_vec_opr) (src:va_operand_vec_opr) : (va_quickCode unit (va_code_VSwap dst src)) = (va_QProc (va_code_VSwap dst src) ([va_mod_vec_opr dst]) (va_wp_VSwap dst src) (va_wpProof_VSwap dst src)) //-- //-- VPolyMul val va_code_VPolyMul : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyMul : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyMul : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyMul dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask a1 64) (Vale.Math.Poly2.mask a2 64)) (Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift a1 (-64)) (Vale.Math.Poly2_s.shift a2 (-64)))) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyMul (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.add (Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask a1 64) (Vale.Math.Poly2.mask a2 64)) (Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift a1 (-64)) (Vale.Math.Poly2_s.shift a2 (-64)))) ==> va_k va_sM (()))) val va_wpProof_VPolyMul : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyMul dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyMul dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyMul (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyMul dst src1 src2)) = (va_QProc (va_code_VPolyMul dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyMul dst src1 src2) (va_wpProof_VPolyMul dst src1 src2)) //-- //-- VPolyMulLow val va_code_VPolyMulLow : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyMulLow : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyMulLow : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyMulLow dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in l_or (Vale.Math.Poly2_s.shift a1 (-64) == zero) (Vale.Math.Poly2_s.shift a2 (-64) == zero)))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask a1 64) (Vale.Math.Poly2.mask a2 64)) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyMulLow (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in l_or (Vale.Math.Poly2_s.shift a1 (-64) == zero) (Vale.Math.Poly2_s.shift a2 (-64) == zero)) /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask a1 64) (Vale.Math.Poly2.mask a2 64)) ==> va_k va_sM (()))) val va_wpProof_VPolyMulLow : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyMulLow dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyMulLow dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyMulLow (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyMulLow dst src1 src2)) = (va_QProc (va_code_VPolyMulLow dst src1 src2) ([va_mod_vec_opr dst]) (va_wp_VPolyMulLow dst src1 src2) (va_wpProof_VPolyMulLow dst src1 src2)) //-- //-- VPolyMulHigh val va_code_VPolyMulHigh : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_code val va_codegen_success_VPolyMulHigh : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Tot va_pbool val va_lemma_VPolyMulHigh : va_b0:va_code -> va_s0:va_state -> dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_VPolyMulHigh dst src1 src2) va_s0 /\ va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in l_or (Vale.Math.Poly2.mask a1 64 == zero) (Vale.Math.Poly2.mask a2 64 == zero)))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift a1 (-64)) (Vale.Math.Poly2_s.shift a2 (-64))) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_vec_opr dst va_sM va_s0)))) [@ va_qattr] let va_wp_VPolyMulHigh (dst:va_operand_vec_opr) (src1:va_operand_vec_opr) (src2:va_operand_vec_opr) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_vec_opr dst va_s0 /\ va_is_src_vec_opr src1 va_s0 /\ va_is_src_vec_opr src2 va_s0 /\ va_get_ok va_s0 /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in l_or (Vale.Math.Poly2.mask a1 64 == zero) (Vale.Math.Poly2.mask a2 64 == zero)) /\ (forall (va_x_dst:va_value_vec_opr) . let va_sM = va_upd_operand_vec_opr dst va_x_dst va_s0 in va_get_ok va_sM /\ (let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src1) in let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_s0 src2) in Vale.Math.Poly2.Bits_s.of_quad32 (va_eval_vec_opr va_sM dst) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift a1 (-64)) (Vale.Math.Poly2_s.shift a2 (-64))) ==> va_k va_sM (()))) val va_wpProof_VPolyMulHigh : dst:va_operand_vec_opr -> src1:va_operand_vec_opr -> src2:va_operand_vec_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_VPolyMulHigh dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_VPolyMulHigh dst src1 src2) ([va_mod_vec_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_VPolyMulHigh (dst:va_operand_vec_opr) (src1:va_operand_vec_opr)
false
false
Vale.AES.PPC64LE.PolyOps.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_quick_VPolyMulHigh (dst src1 src2: va_operand_vec_opr) : (va_quickCode unit (va_code_VPolyMulHigh dst src1 src2))
[]
Vale.AES.PPC64LE.PolyOps.va_quick_VPolyMulHigh
{ "file_name": "obj/Vale.AES.PPC64LE.PolyOps.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.PPC64LE.Decls.va_operand_vec_opr -> src1: Vale.PPC64LE.Decls.va_operand_vec_opr -> src2: Vale.PPC64LE.Decls.va_operand_vec_opr -> Vale.PPC64LE.QuickCode.va_quickCode Prims.unit (Vale.AES.PPC64LE.PolyOps.va_code_VPolyMulHigh dst src1 src2)
{ "end_col": 55, "end_line": 279, "start_col": 2, "start_line": 278 }
Prims.Tot
val sel (#a: Type) (m: map16 a) (n: int) : a
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sel (#a:Type) (m:map16 a) (n:int) : a = sel16 m n
val sel (#a: Type) (m: map16 a) (n: int) : a let sel (#a: Type) (m: map16 a) (n: int) : a =
false
null
false
sel16 m n
{ "checked_file": "Vale.Lib.Map16.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Lib.Map16.fsti" }
[ "total" ]
[ "Vale.Lib.Map16.map16", "Prims.int", "Vale.Lib.Map16.sel16" ]
[]
module Vale.Lib.Map16 open FStar.Mul open Vale.X64.Machine_s type map2 (a:Type) = a & a type map4 (a:Type) = map2 a & map2 a type map8 (a:Type) = map4 a & map4 a type map16 (a:Type) = map8 a & map8 a [@va_qattr] let sel2 (#a:Type) (m:map2 a) (n:int) : a = match m with (m0, m1) -> match n < 1 with true -> m0 | false -> m1 [@va_qattr] let sel4 (#a:Type) (m:map4 a) (n:int) : a = match m with (m0, m1) -> match n < 2 with true -> sel2 m0 n | false -> sel2 m1 (n - 2) [@va_qattr] let sel8 (#a:Type) (m:map8 a) (n:int) : a = match m with (m0, m1) -> match n < 4 with true -> sel4 m0 n | false -> sel4 m1 (n - 4) [@va_qattr] let sel16 (#a:Type) (m:map16 a) (n:int) : a = match m with (m0, m1) -> match n < 8 with true -> sel8 m0 n | false -> sel8 m1 (n - 8) [@va_qattr] let upd2 (#a:Type) (m:map2 a) (n:int) (v:a) : map2 a = match m with (m0, m1) -> match n < 1 with true -> (v, m1) | false -> (m0, v) [@va_qattr] let upd4 (#a:Type) (m:map4 a) (n:int) (v:a) : map4 a = match m with (m0, m1) -> match n < 2 with true -> (upd2 m0 n v, m1) | false -> (m0, upd2 m1 (n - 2) v) [@va_qattr] let upd8 (#a:Type) (m:map8 a) (n:int) (v:a) : map8 a = match m with (m0, m1) -> match n < 4 with true -> (upd4 m0 n v, m1) | false -> (m0, upd4 m1 (n - 4) v) [@va_qattr] let upd16 (#a:Type) (m:map16 a) (n:int) (v:a) : map16 a = match m with (m0, m1) -> match n < 8 with true -> (upd8 m0 n v, m1) | false -> (m0, upd8 m1 (n - 8) v) val lemma_self16 (#a:Type) (m:map16 a) (n:int) (v:a) : Lemma (requires 0 <= n /\ n < 16) (ensures sel16 (upd16 m n v) n == v) val lemma_other16 (#a:Type) (m:map16 a) (n1 n2:int) (v:a) : Lemma (requires 0 <= n1 /\ n1 < 16 /\ 0 <= n2 /\ n2 < 16 /\ n1 =!= n2) (ensures sel16 (upd16 m n1 v) n2 == sel16 m n2) val lemma_equal16 (#a:Type) (m1 m2:map16 a) : Lemma (requires (forall (i:int).{:pattern (sel16 m1 i) \/ (sel16 m2 i)} 0 <= i /\ i < 16 ==> sel16 m1 i == sel16 m2 i)) (ensures m1 == m2) //[@"uninterpreted_by_smt"] //let map = map16 [@va_qattr "opaque_to_smt"]
false
false
Vale.Lib.Map16.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sel (#a: Type) (m: map16 a) (n: int) : a
[]
Vale.Lib.Map16.sel
{ "file_name": "vale/code/lib/collections/Vale.Lib.Map16.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
m: Vale.Lib.Map16.map16 a -> n: Prims.int -> a
{ "end_col": 11, "end_line": 67, "start_col": 2, "start_line": 67 }
Prims.Tot
val upd (#a: Type) (m: map16 a) (n: int) (v: a) : map16 a
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let upd (#a:Type) (m:map16 a) (n:int) (v:a) : map16 a = upd16 m n v
val upd (#a: Type) (m: map16 a) (n: int) (v: a) : map16 a let upd (#a: Type) (m: map16 a) (n: int) (v: a) : map16 a =
false
null
false
upd16 m n v
{ "checked_file": "Vale.Lib.Map16.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Lib.Map16.fsti" }
[ "total" ]
[ "Vale.Lib.Map16.map16", "Prims.int", "Vale.Lib.Map16.upd16" ]
[]
module Vale.Lib.Map16 open FStar.Mul open Vale.X64.Machine_s type map2 (a:Type) = a & a type map4 (a:Type) = map2 a & map2 a type map8 (a:Type) = map4 a & map4 a type map16 (a:Type) = map8 a & map8 a [@va_qattr] let sel2 (#a:Type) (m:map2 a) (n:int) : a = match m with (m0, m1) -> match n < 1 with true -> m0 | false -> m1 [@va_qattr] let sel4 (#a:Type) (m:map4 a) (n:int) : a = match m with (m0, m1) -> match n < 2 with true -> sel2 m0 n | false -> sel2 m1 (n - 2) [@va_qattr] let sel8 (#a:Type) (m:map8 a) (n:int) : a = match m with (m0, m1) -> match n < 4 with true -> sel4 m0 n | false -> sel4 m1 (n - 4) [@va_qattr] let sel16 (#a:Type) (m:map16 a) (n:int) : a = match m with (m0, m1) -> match n < 8 with true -> sel8 m0 n | false -> sel8 m1 (n - 8) [@va_qattr] let upd2 (#a:Type) (m:map2 a) (n:int) (v:a) : map2 a = match m with (m0, m1) -> match n < 1 with true -> (v, m1) | false -> (m0, v) [@va_qattr] let upd4 (#a:Type) (m:map4 a) (n:int) (v:a) : map4 a = match m with (m0, m1) -> match n < 2 with true -> (upd2 m0 n v, m1) | false -> (m0, upd2 m1 (n - 2) v) [@va_qattr] let upd8 (#a:Type) (m:map8 a) (n:int) (v:a) : map8 a = match m with (m0, m1) -> match n < 4 with true -> (upd4 m0 n v, m1) | false -> (m0, upd4 m1 (n - 4) v) [@va_qattr] let upd16 (#a:Type) (m:map16 a) (n:int) (v:a) : map16 a = match m with (m0, m1) -> match n < 8 with true -> (upd8 m0 n v, m1) | false -> (m0, upd8 m1 (n - 8) v) val lemma_self16 (#a:Type) (m:map16 a) (n:int) (v:a) : Lemma (requires 0 <= n /\ n < 16) (ensures sel16 (upd16 m n v) n == v) val lemma_other16 (#a:Type) (m:map16 a) (n1 n2:int) (v:a) : Lemma (requires 0 <= n1 /\ n1 < 16 /\ 0 <= n2 /\ n2 < 16 /\ n1 =!= n2) (ensures sel16 (upd16 m n1 v) n2 == sel16 m n2) val lemma_equal16 (#a:Type) (m1 m2:map16 a) : Lemma (requires (forall (i:int).{:pattern (sel16 m1 i) \/ (sel16 m2 i)} 0 <= i /\ i < 16 ==> sel16 m1 i == sel16 m2 i)) (ensures m1 == m2) //[@"uninterpreted_by_smt"] //let map = map16 [@va_qattr "opaque_to_smt"] let sel (#a:Type) (m:map16 a) (n:int) : a = sel16 m n [@va_qattr "opaque_to_smt"]
false
false
Vale.Lib.Map16.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val upd (#a: Type) (m: map16 a) (n: int) (v: a) : map16 a
[]
Vale.Lib.Map16.upd
{ "file_name": "vale/code/lib/collections/Vale.Lib.Map16.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
m: Vale.Lib.Map16.map16 a -> n: Prims.int -> v: a -> Vale.Lib.Map16.map16 a
{ "end_col": 13, "end_line": 71, "start_col": 2, "start_line": 71 }
Prims.Tot
val get (#a: Type) (m: map16 a) (n: int) : a
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let get (#a:Type) (m:map16 a) (n:int) : a = sel m n
val get (#a: Type) (m: map16 a) (n: int) : a let get (#a: Type) (m: map16 a) (n: int) : a =
false
null
false
sel m n
{ "checked_file": "Vale.Lib.Map16.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Lib.Map16.fsti" }
[ "total" ]
[ "Vale.Lib.Map16.map16", "Prims.int", "Vale.Lib.Map16.sel" ]
[]
module Vale.Lib.Map16 open FStar.Mul open Vale.X64.Machine_s type map2 (a:Type) = a & a type map4 (a:Type) = map2 a & map2 a type map8 (a:Type) = map4 a & map4 a type map16 (a:Type) = map8 a & map8 a [@va_qattr] let sel2 (#a:Type) (m:map2 a) (n:int) : a = match m with (m0, m1) -> match n < 1 with true -> m0 | false -> m1 [@va_qattr] let sel4 (#a:Type) (m:map4 a) (n:int) : a = match m with (m0, m1) -> match n < 2 with true -> sel2 m0 n | false -> sel2 m1 (n - 2) [@va_qattr] let sel8 (#a:Type) (m:map8 a) (n:int) : a = match m with (m0, m1) -> match n < 4 with true -> sel4 m0 n | false -> sel4 m1 (n - 4) [@va_qattr] let sel16 (#a:Type) (m:map16 a) (n:int) : a = match m with (m0, m1) -> match n < 8 with true -> sel8 m0 n | false -> sel8 m1 (n - 8) [@va_qattr] let upd2 (#a:Type) (m:map2 a) (n:int) (v:a) : map2 a = match m with (m0, m1) -> match n < 1 with true -> (v, m1) | false -> (m0, v) [@va_qattr] let upd4 (#a:Type) (m:map4 a) (n:int) (v:a) : map4 a = match m with (m0, m1) -> match n < 2 with true -> (upd2 m0 n v, m1) | false -> (m0, upd2 m1 (n - 2) v) [@va_qattr] let upd8 (#a:Type) (m:map8 a) (n:int) (v:a) : map8 a = match m with (m0, m1) -> match n < 4 with true -> (upd4 m0 n v, m1) | false -> (m0, upd4 m1 (n - 4) v) [@va_qattr] let upd16 (#a:Type) (m:map16 a) (n:int) (v:a) : map16 a = match m with (m0, m1) -> match n < 8 with true -> (upd8 m0 n v, m1) | false -> (m0, upd8 m1 (n - 8) v) val lemma_self16 (#a:Type) (m:map16 a) (n:int) (v:a) : Lemma (requires 0 <= n /\ n < 16) (ensures sel16 (upd16 m n v) n == v) val lemma_other16 (#a:Type) (m:map16 a) (n1 n2:int) (v:a) : Lemma (requires 0 <= n1 /\ n1 < 16 /\ 0 <= n2 /\ n2 < 16 /\ n1 =!= n2) (ensures sel16 (upd16 m n1 v) n2 == sel16 m n2) val lemma_equal16 (#a:Type) (m1 m2:map16 a) : Lemma (requires (forall (i:int).{:pattern (sel16 m1 i) \/ (sel16 m2 i)} 0 <= i /\ i < 16 ==> sel16 m1 i == sel16 m2 i)) (ensures m1 == m2) //[@"uninterpreted_by_smt"] //let map = map16 [@va_qattr "opaque_to_smt"] let sel (#a:Type) (m:map16 a) (n:int) : a = sel16 m n [@va_qattr "opaque_to_smt"] let upd (#a:Type) (m:map16 a) (n:int) (v:a) : map16 a = upd16 m n v
false
false
Vale.Lib.Map16.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get (#a: Type) (m: map16 a) (n: int) : a
[]
Vale.Lib.Map16.get
{ "file_name": "vale/code/lib/collections/Vale.Lib.Map16.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
m: Vale.Lib.Map16.map16 a -> n: Prims.int -> a
{ "end_col": 9, "end_line": 74, "start_col": 2, "start_line": 74 }
Prims.Tot
val eta (#a: Type) (m: map16 a) : map16 a
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eta (#a:Type) (m:map16 a) : map16 a = eta16 m
val eta (#a: Type) (m: map16 a) : map16 a let eta (#a: Type) (m: map16 a) : map16 a =
false
null
false
eta16 m
{ "checked_file": "Vale.Lib.Map16.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Lib.Map16.fsti" }
[ "total" ]
[ "Vale.Lib.Map16.map16", "Vale.Lib.Map16.eta16" ]
[]
module Vale.Lib.Map16 open FStar.Mul open Vale.X64.Machine_s type map2 (a:Type) = a & a type map4 (a:Type) = map2 a & map2 a type map8 (a:Type) = map4 a & map4 a type map16 (a:Type) = map8 a & map8 a [@va_qattr] let sel2 (#a:Type) (m:map2 a) (n:int) : a = match m with (m0, m1) -> match n < 1 with true -> m0 | false -> m1 [@va_qattr] let sel4 (#a:Type) (m:map4 a) (n:int) : a = match m with (m0, m1) -> match n < 2 with true -> sel2 m0 n | false -> sel2 m1 (n - 2) [@va_qattr] let sel8 (#a:Type) (m:map8 a) (n:int) : a = match m with (m0, m1) -> match n < 4 with true -> sel4 m0 n | false -> sel4 m1 (n - 4) [@va_qattr] let sel16 (#a:Type) (m:map16 a) (n:int) : a = match m with (m0, m1) -> match n < 8 with true -> sel8 m0 n | false -> sel8 m1 (n - 8) [@va_qattr] let upd2 (#a:Type) (m:map2 a) (n:int) (v:a) : map2 a = match m with (m0, m1) -> match n < 1 with true -> (v, m1) | false -> (m0, v) [@va_qattr] let upd4 (#a:Type) (m:map4 a) (n:int) (v:a) : map4 a = match m with (m0, m1) -> match n < 2 with true -> (upd2 m0 n v, m1) | false -> (m0, upd2 m1 (n - 2) v) [@va_qattr] let upd8 (#a:Type) (m:map8 a) (n:int) (v:a) : map8 a = match m with (m0, m1) -> match n < 4 with true -> (upd4 m0 n v, m1) | false -> (m0, upd4 m1 (n - 4) v) [@va_qattr] let upd16 (#a:Type) (m:map16 a) (n:int) (v:a) : map16 a = match m with (m0, m1) -> match n < 8 with true -> (upd8 m0 n v, m1) | false -> (m0, upd8 m1 (n - 8) v) val lemma_self16 (#a:Type) (m:map16 a) (n:int) (v:a) : Lemma (requires 0 <= n /\ n < 16) (ensures sel16 (upd16 m n v) n == v) val lemma_other16 (#a:Type) (m:map16 a) (n1 n2:int) (v:a) : Lemma (requires 0 <= n1 /\ n1 < 16 /\ 0 <= n2 /\ n2 < 16 /\ n1 =!= n2) (ensures sel16 (upd16 m n1 v) n2 == sel16 m n2) val lemma_equal16 (#a:Type) (m1 m2:map16 a) : Lemma (requires (forall (i:int).{:pattern (sel16 m1 i) \/ (sel16 m2 i)} 0 <= i /\ i < 16 ==> sel16 m1 i == sel16 m2 i)) (ensures m1 == m2) //[@"uninterpreted_by_smt"] //let map = map16 [@va_qattr "opaque_to_smt"] let sel (#a:Type) (m:map16 a) (n:int) : a = sel16 m n [@va_qattr "opaque_to_smt"] let upd (#a:Type) (m:map16 a) (n:int) (v:a) : map16 a = upd16 m n v let get (#a:Type) (m:map16 a) (n:int) : a = sel m n [@va_qattr] let eta16 (#a:Type) (m:map16 a) : map16 a = let m0_3 = ((get m 0, get m 1), (get m 2, get m 3)) in let m4_7 = ((get m 4, get m 5), (get m 6, get m 7)) in let m8_11 = ((get m 8, get m 9), (get m 10, get m 11)) in let m12_15 = ((get m 12, get m 13), (get m 14, get m 15)) in ((m0_3, m4_7), (m8_11, m12_15)) [@va_qattr "opaque_to_smt"]
false
false
Vale.Lib.Map16.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eta (#a: Type) (m: map16 a) : map16 a
[]
Vale.Lib.Map16.eta
{ "file_name": "vale/code/lib/collections/Vale.Lib.Map16.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
m: Vale.Lib.Map16.map16 a -> Vale.Lib.Map16.map16 a
{ "end_col": 9, "end_line": 86, "start_col": 2, "start_line": 86 }
Prims.Tot
val eta16 (#a: Type) (m: map16 a) : map16 a
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eta16 (#a:Type) (m:map16 a) : map16 a = let m0_3 = ((get m 0, get m 1), (get m 2, get m 3)) in let m4_7 = ((get m 4, get m 5), (get m 6, get m 7)) in let m8_11 = ((get m 8, get m 9), (get m 10, get m 11)) in let m12_15 = ((get m 12, get m 13), (get m 14, get m 15)) in ((m0_3, m4_7), (m8_11, m12_15))
val eta16 (#a: Type) (m: map16 a) : map16 a let eta16 (#a: Type) (m: map16 a) : map16 a =
false
null
false
let m0_3 = ((get m 0, get m 1), (get m 2, get m 3)) in let m4_7 = ((get m 4, get m 5), (get m 6, get m 7)) in let m8_11 = ((get m 8, get m 9), (get m 10, get m 11)) in let m12_15 = ((get m 12, get m 13), (get m 14, get m 15)) in ((m0_3, m4_7), (m8_11, m12_15))
{ "checked_file": "Vale.Lib.Map16.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Lib.Map16.fsti" }
[ "total" ]
[ "Vale.Lib.Map16.map16", "FStar.Pervasives.Native.Mktuple2", "Vale.Lib.Map16.map8", "Vale.Lib.Map16.map4", "FStar.Pervasives.Native.tuple2", "Vale.Lib.Map16.map2", "Vale.Lib.Map16.get" ]
[]
module Vale.Lib.Map16 open FStar.Mul open Vale.X64.Machine_s type map2 (a:Type) = a & a type map4 (a:Type) = map2 a & map2 a type map8 (a:Type) = map4 a & map4 a type map16 (a:Type) = map8 a & map8 a [@va_qattr] let sel2 (#a:Type) (m:map2 a) (n:int) : a = match m with (m0, m1) -> match n < 1 with true -> m0 | false -> m1 [@va_qattr] let sel4 (#a:Type) (m:map4 a) (n:int) : a = match m with (m0, m1) -> match n < 2 with true -> sel2 m0 n | false -> sel2 m1 (n - 2) [@va_qattr] let sel8 (#a:Type) (m:map8 a) (n:int) : a = match m with (m0, m1) -> match n < 4 with true -> sel4 m0 n | false -> sel4 m1 (n - 4) [@va_qattr] let sel16 (#a:Type) (m:map16 a) (n:int) : a = match m with (m0, m1) -> match n < 8 with true -> sel8 m0 n | false -> sel8 m1 (n - 8) [@va_qattr] let upd2 (#a:Type) (m:map2 a) (n:int) (v:a) : map2 a = match m with (m0, m1) -> match n < 1 with true -> (v, m1) | false -> (m0, v) [@va_qattr] let upd4 (#a:Type) (m:map4 a) (n:int) (v:a) : map4 a = match m with (m0, m1) -> match n < 2 with true -> (upd2 m0 n v, m1) | false -> (m0, upd2 m1 (n - 2) v) [@va_qattr] let upd8 (#a:Type) (m:map8 a) (n:int) (v:a) : map8 a = match m with (m0, m1) -> match n < 4 with true -> (upd4 m0 n v, m1) | false -> (m0, upd4 m1 (n - 4) v) [@va_qattr] let upd16 (#a:Type) (m:map16 a) (n:int) (v:a) : map16 a = match m with (m0, m1) -> match n < 8 with true -> (upd8 m0 n v, m1) | false -> (m0, upd8 m1 (n - 8) v) val lemma_self16 (#a:Type) (m:map16 a) (n:int) (v:a) : Lemma (requires 0 <= n /\ n < 16) (ensures sel16 (upd16 m n v) n == v) val lemma_other16 (#a:Type) (m:map16 a) (n1 n2:int) (v:a) : Lemma (requires 0 <= n1 /\ n1 < 16 /\ 0 <= n2 /\ n2 < 16 /\ n1 =!= n2) (ensures sel16 (upd16 m n1 v) n2 == sel16 m n2) val lemma_equal16 (#a:Type) (m1 m2:map16 a) : Lemma (requires (forall (i:int).{:pattern (sel16 m1 i) \/ (sel16 m2 i)} 0 <= i /\ i < 16 ==> sel16 m1 i == sel16 m2 i)) (ensures m1 == m2) //[@"uninterpreted_by_smt"] //let map = map16 [@va_qattr "opaque_to_smt"] let sel (#a:Type) (m:map16 a) (n:int) : a = sel16 m n [@va_qattr "opaque_to_smt"] let upd (#a:Type) (m:map16 a) (n:int) (v:a) : map16 a = upd16 m n v let get (#a:Type) (m:map16 a) (n:int) : a = sel m n
false
false
Vale.Lib.Map16.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eta16 (#a: Type) (m: map16 a) : map16 a
[]
Vale.Lib.Map16.eta16
{ "file_name": "vale/code/lib/collections/Vale.Lib.Map16.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
m: Vale.Lib.Map16.map16 a -> Vale.Lib.Map16.map16 a
{ "end_col": 33, "end_line": 82, "start_col": 43, "start_line": 77 }
Prims.Tot
val sel16 (#a: Type) (m: map16 a) (n: int) : a
[ { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sel16 (#a:Type) (m:map16 a) (n:int) : a = match m with (m0, m1) -> match n < 8 with true -> sel8 m0 n | false -> sel8 m1 (n - 8)
val sel16 (#a: Type) (m: map16 a) (n: int) : a let sel16 (#a: Type) (m: map16 a) (n: int) : a =
false
null
false
match m with | m0, m1 -> match n < 8 with | true -> sel8 m0 n | false -> sel8 m1 (n - 8)
{ "checked_file": "Vale.Lib.Map16.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Lib.Map16.fsti" }
[ "total" ]
[ "Vale.Lib.Map16.map16", "Prims.int", "Vale.Lib.Map16.map8", "Prims.op_LessThan", "Vale.Lib.Map16.sel8", "Prims.op_Subtraction" ]
[]
module Vale.Lib.Map16 open FStar.Mul open Vale.X64.Machine_s type map2 (a:Type) = a & a type map4 (a:Type) = map2 a & map2 a type map8 (a:Type) = map4 a & map4 a type map16 (a:Type) = map8 a & map8 a [@va_qattr] let sel2 (#a:Type) (m:map2 a) (n:int) : a = match m with (m0, m1) -> match n < 1 with true -> m0 | false -> m1 [@va_qattr] let sel4 (#a:Type) (m:map4 a) (n:int) : a = match m with (m0, m1) -> match n < 2 with true -> sel2 m0 n | false -> sel2 m1 (n - 2) [@va_qattr] let sel8 (#a:Type) (m:map8 a) (n:int) : a = match m with (m0, m1) -> match n < 4 with true -> sel4 m0 n | false -> sel4 m1 (n - 4) [@va_qattr]
false
false
Vale.Lib.Map16.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sel16 (#a: Type) (m: map16 a) (n: int) : a
[]
Vale.Lib.Map16.sel16
{ "file_name": "vale/code/lib/collections/Vale.Lib.Map16.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
m: Vale.Lib.Map16.map16 a -> n: Prims.int -> a
{ "end_col": 63, "end_line": 28, "start_col": 2, "start_line": 27 }
Prims.Tot
val sel8 (#a: Type) (m: map8 a) (n: int) : a
[ { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sel8 (#a:Type) (m:map8 a) (n:int) : a = match m with (m0, m1) -> match n < 4 with true -> sel4 m0 n | false -> sel4 m1 (n - 4)
val sel8 (#a: Type) (m: map8 a) (n: int) : a let sel8 (#a: Type) (m: map8 a) (n: int) : a =
false
null
false
match m with | m0, m1 -> match n < 4 with | true -> sel4 m0 n | false -> sel4 m1 (n - 4)
{ "checked_file": "Vale.Lib.Map16.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Lib.Map16.fsti" }
[ "total" ]
[ "Vale.Lib.Map16.map8", "Prims.int", "Vale.Lib.Map16.map4", "Prims.op_LessThan", "Vale.Lib.Map16.sel4", "Prims.op_Subtraction" ]
[]
module Vale.Lib.Map16 open FStar.Mul open Vale.X64.Machine_s type map2 (a:Type) = a & a type map4 (a:Type) = map2 a & map2 a type map8 (a:Type) = map4 a & map4 a type map16 (a:Type) = map8 a & map8 a [@va_qattr] let sel2 (#a:Type) (m:map2 a) (n:int) : a = match m with (m0, m1) -> match n < 1 with true -> m0 | false -> m1 [@va_qattr] let sel4 (#a:Type) (m:map4 a) (n:int) : a = match m with (m0, m1) -> match n < 2 with true -> sel2 m0 n | false -> sel2 m1 (n - 2) [@va_qattr]
false
false
Vale.Lib.Map16.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sel8 (#a: Type) (m: map8 a) (n: int) : a
[]
Vale.Lib.Map16.sel8
{ "file_name": "vale/code/lib/collections/Vale.Lib.Map16.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
m: Vale.Lib.Map16.map8 a -> n: Prims.int -> a
{ "end_col": 63, "end_line": 23, "start_col": 2, "start_line": 22 }
Prims.Tot
val upd2 (#a: Type) (m: map2 a) (n: int) (v: a) : map2 a
[ { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let upd2 (#a:Type) (m:map2 a) (n:int) (v:a) : map2 a = match m with (m0, m1) -> match n < 1 with true -> (v, m1) | false -> (m0, v)
val upd2 (#a: Type) (m: map2 a) (n: int) (v: a) : map2 a let upd2 (#a: Type) (m: map2 a) (n: int) (v: a) : map2 a =
false
null
false
match m with | m0, m1 -> match n < 1 with | true -> (v, m1) | false -> (m0, v)
{ "checked_file": "Vale.Lib.Map16.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Lib.Map16.fsti" }
[ "total" ]
[ "Vale.Lib.Map16.map2", "Prims.int", "Prims.op_LessThan", "FStar.Pervasives.Native.Mktuple2" ]
[]
module Vale.Lib.Map16 open FStar.Mul open Vale.X64.Machine_s type map2 (a:Type) = a & a type map4 (a:Type) = map2 a & map2 a type map8 (a:Type) = map4 a & map4 a type map16 (a:Type) = map8 a & map8 a [@va_qattr] let sel2 (#a:Type) (m:map2 a) (n:int) : a = match m with (m0, m1) -> match n < 1 with true -> m0 | false -> m1 [@va_qattr] let sel4 (#a:Type) (m:map4 a) (n:int) : a = match m with (m0, m1) -> match n < 2 with true -> sel2 m0 n | false -> sel2 m1 (n - 2) [@va_qattr] let sel8 (#a:Type) (m:map8 a) (n:int) : a = match m with (m0, m1) -> match n < 4 with true -> sel4 m0 n | false -> sel4 m1 (n - 4) [@va_qattr] let sel16 (#a:Type) (m:map16 a) (n:int) : a = match m with (m0, m1) -> match n < 8 with true -> sel8 m0 n | false -> sel8 m1 (n - 8) [@va_qattr]
false
false
Vale.Lib.Map16.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val upd2 (#a: Type) (m: map2 a) (n: int) (v: a) : map2 a
[]
Vale.Lib.Map16.upd2
{ "file_name": "vale/code/lib/collections/Vale.Lib.Map16.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
m: Vale.Lib.Map16.map2 a -> n: Prims.int -> v: a -> Vale.Lib.Map16.map2 a
{ "end_col": 53, "end_line": 33, "start_col": 2, "start_line": 32 }
Prims.Tot
val sel4 (#a: Type) (m: map4 a) (n: int) : a
[ { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sel4 (#a:Type) (m:map4 a) (n:int) : a = match m with (m0, m1) -> match n < 2 with true -> sel2 m0 n | false -> sel2 m1 (n - 2)
val sel4 (#a: Type) (m: map4 a) (n: int) : a let sel4 (#a: Type) (m: map4 a) (n: int) : a =
false
null
false
match m with | m0, m1 -> match n < 2 with | true -> sel2 m0 n | false -> sel2 m1 (n - 2)
{ "checked_file": "Vale.Lib.Map16.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Lib.Map16.fsti" }
[ "total" ]
[ "Vale.Lib.Map16.map4", "Prims.int", "Vale.Lib.Map16.map2", "Prims.op_LessThan", "Vale.Lib.Map16.sel2", "Prims.op_Subtraction" ]
[]
module Vale.Lib.Map16 open FStar.Mul open Vale.X64.Machine_s type map2 (a:Type) = a & a type map4 (a:Type) = map2 a & map2 a type map8 (a:Type) = map4 a & map4 a type map16 (a:Type) = map8 a & map8 a [@va_qattr] let sel2 (#a:Type) (m:map2 a) (n:int) : a = match m with (m0, m1) -> match n < 1 with true -> m0 | false -> m1 [@va_qattr]
false
false
Vale.Lib.Map16.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sel4 (#a: Type) (m: map4 a) (n: int) : a
[]
Vale.Lib.Map16.sel4
{ "file_name": "vale/code/lib/collections/Vale.Lib.Map16.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
m: Vale.Lib.Map16.map4 a -> n: Prims.int -> a
{ "end_col": 63, "end_line": 18, "start_col": 2, "start_line": 17 }
Prims.Tot
val sel2 (#a: Type) (m: map2 a) (n: int) : a
[ { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sel2 (#a:Type) (m:map2 a) (n:int) : a = match m with (m0, m1) -> match n < 1 with true -> m0 | false -> m1
val sel2 (#a: Type) (m: map2 a) (n: int) : a let sel2 (#a: Type) (m: map2 a) (n: int) : a =
false
null
false
match m with | m0, m1 -> match n < 1 with | true -> m0 | false -> m1
{ "checked_file": "Vale.Lib.Map16.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Lib.Map16.fsti" }
[ "total" ]
[ "Vale.Lib.Map16.map2", "Prims.int", "Prims.op_LessThan" ]
[]
module Vale.Lib.Map16 open FStar.Mul open Vale.X64.Machine_s type map2 (a:Type) = a & a type map4 (a:Type) = map2 a & map2 a type map8 (a:Type) = map4 a & map4 a type map16 (a:Type) = map8 a & map8 a [@va_qattr]
false
false
Vale.Lib.Map16.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sel2 (#a: Type) (m: map2 a) (n: int) : a
[]
Vale.Lib.Map16.sel2
{ "file_name": "vale/code/lib/collections/Vale.Lib.Map16.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
m: Vale.Lib.Map16.map2 a -> n: Prims.int -> a
{ "end_col": 43, "end_line": 13, "start_col": 2, "start_line": 12 }
Prims.Tot
val upd8 (#a: Type) (m: map8 a) (n: int) (v: a) : map8 a
[ { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let upd8 (#a:Type) (m:map8 a) (n:int) (v:a) : map8 a = match m with (m0, m1) -> match n < 4 with true -> (upd4 m0 n v, m1) | false -> (m0, upd4 m1 (n - 4) v)
val upd8 (#a: Type) (m: map8 a) (n: int) (v: a) : map8 a let upd8 (#a: Type) (m: map8 a) (n: int) (v: a) : map8 a =
false
null
false
match m with | m0, m1 -> match n < 4 with | true -> (upd4 m0 n v, m1) | false -> (m0, upd4 m1 (n - 4) v)
{ "checked_file": "Vale.Lib.Map16.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Lib.Map16.fsti" }
[ "total" ]
[ "Vale.Lib.Map16.map8", "Prims.int", "Vale.Lib.Map16.map4", "Prims.op_LessThan", "FStar.Pervasives.Native.Mktuple2", "Vale.Lib.Map16.upd4", "Prims.op_Subtraction" ]
[]
module Vale.Lib.Map16 open FStar.Mul open Vale.X64.Machine_s type map2 (a:Type) = a & a type map4 (a:Type) = map2 a & map2 a type map8 (a:Type) = map4 a & map4 a type map16 (a:Type) = map8 a & map8 a [@va_qattr] let sel2 (#a:Type) (m:map2 a) (n:int) : a = match m with (m0, m1) -> match n < 1 with true -> m0 | false -> m1 [@va_qattr] let sel4 (#a:Type) (m:map4 a) (n:int) : a = match m with (m0, m1) -> match n < 2 with true -> sel2 m0 n | false -> sel2 m1 (n - 2) [@va_qattr] let sel8 (#a:Type) (m:map8 a) (n:int) : a = match m with (m0, m1) -> match n < 4 with true -> sel4 m0 n | false -> sel4 m1 (n - 4) [@va_qattr] let sel16 (#a:Type) (m:map16 a) (n:int) : a = match m with (m0, m1) -> match n < 8 with true -> sel8 m0 n | false -> sel8 m1 (n - 8) [@va_qattr] let upd2 (#a:Type) (m:map2 a) (n:int) (v:a) : map2 a = match m with (m0, m1) -> match n < 1 with true -> (v, m1) | false -> (m0, v) [@va_qattr] let upd4 (#a:Type) (m:map4 a) (n:int) (v:a) : map4 a = match m with (m0, m1) -> match n < 2 with true -> (upd2 m0 n v, m1) | false -> (m0, upd2 m1 (n - 2) v) [@va_qattr]
false
false
Vale.Lib.Map16.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val upd8 (#a: Type) (m: map8 a) (n: int) (v: a) : map8 a
[]
Vale.Lib.Map16.upd8
{ "file_name": "vale/code/lib/collections/Vale.Lib.Map16.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
m: Vale.Lib.Map16.map8 a -> n: Prims.int -> v: a -> Vale.Lib.Map16.map8 a
{ "end_col": 79, "end_line": 43, "start_col": 2, "start_line": 42 }
Prims.Tot
val upd4 (#a: Type) (m: map4 a) (n: int) (v: a) : map4 a
[ { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let upd4 (#a:Type) (m:map4 a) (n:int) (v:a) : map4 a = match m with (m0, m1) -> match n < 2 with true -> (upd2 m0 n v, m1) | false -> (m0, upd2 m1 (n - 2) v)
val upd4 (#a: Type) (m: map4 a) (n: int) (v: a) : map4 a let upd4 (#a: Type) (m: map4 a) (n: int) (v: a) : map4 a =
false
null
false
match m with | m0, m1 -> match n < 2 with | true -> (upd2 m0 n v, m1) | false -> (m0, upd2 m1 (n - 2) v)
{ "checked_file": "Vale.Lib.Map16.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Lib.Map16.fsti" }
[ "total" ]
[ "Vale.Lib.Map16.map4", "Prims.int", "Vale.Lib.Map16.map2", "Prims.op_LessThan", "FStar.Pervasives.Native.Mktuple2", "Vale.Lib.Map16.upd2", "Prims.op_Subtraction" ]
[]
module Vale.Lib.Map16 open FStar.Mul open Vale.X64.Machine_s type map2 (a:Type) = a & a type map4 (a:Type) = map2 a & map2 a type map8 (a:Type) = map4 a & map4 a type map16 (a:Type) = map8 a & map8 a [@va_qattr] let sel2 (#a:Type) (m:map2 a) (n:int) : a = match m with (m0, m1) -> match n < 1 with true -> m0 | false -> m1 [@va_qattr] let sel4 (#a:Type) (m:map4 a) (n:int) : a = match m with (m0, m1) -> match n < 2 with true -> sel2 m0 n | false -> sel2 m1 (n - 2) [@va_qattr] let sel8 (#a:Type) (m:map8 a) (n:int) : a = match m with (m0, m1) -> match n < 4 with true -> sel4 m0 n | false -> sel4 m1 (n - 4) [@va_qattr] let sel16 (#a:Type) (m:map16 a) (n:int) : a = match m with (m0, m1) -> match n < 8 with true -> sel8 m0 n | false -> sel8 m1 (n - 8) [@va_qattr] let upd2 (#a:Type) (m:map2 a) (n:int) (v:a) : map2 a = match m with (m0, m1) -> match n < 1 with true -> (v, m1) | false -> (m0, v) [@va_qattr]
false
false
Vale.Lib.Map16.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val upd4 (#a: Type) (m: map4 a) (n: int) (v: a) : map4 a
[]
Vale.Lib.Map16.upd4
{ "file_name": "vale/code/lib/collections/Vale.Lib.Map16.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
m: Vale.Lib.Map16.map4 a -> n: Prims.int -> v: a -> Vale.Lib.Map16.map4 a
{ "end_col": 79, "end_line": 38, "start_col": 2, "start_line": 37 }
Prims.Tot
val upd16 (#a: Type) (m: map16 a) (n: int) (v: a) : map16 a
[ { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let upd16 (#a:Type) (m:map16 a) (n:int) (v:a) : map16 a = match m with (m0, m1) -> match n < 8 with true -> (upd8 m0 n v, m1) | false -> (m0, upd8 m1 (n - 8) v)
val upd16 (#a: Type) (m: map16 a) (n: int) (v: a) : map16 a let upd16 (#a: Type) (m: map16 a) (n: int) (v: a) : map16 a =
false
null
false
match m with | m0, m1 -> match n < 8 with | true -> (upd8 m0 n v, m1) | false -> (m0, upd8 m1 (n - 8) v)
{ "checked_file": "Vale.Lib.Map16.fsti.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Lib.Map16.fsti" }
[ "total" ]
[ "Vale.Lib.Map16.map16", "Prims.int", "Vale.Lib.Map16.map8", "Prims.op_LessThan", "FStar.Pervasives.Native.Mktuple2", "Vale.Lib.Map16.upd8", "Prims.op_Subtraction" ]
[]
module Vale.Lib.Map16 open FStar.Mul open Vale.X64.Machine_s type map2 (a:Type) = a & a type map4 (a:Type) = map2 a & map2 a type map8 (a:Type) = map4 a & map4 a type map16 (a:Type) = map8 a & map8 a [@va_qattr] let sel2 (#a:Type) (m:map2 a) (n:int) : a = match m with (m0, m1) -> match n < 1 with true -> m0 | false -> m1 [@va_qattr] let sel4 (#a:Type) (m:map4 a) (n:int) : a = match m with (m0, m1) -> match n < 2 with true -> sel2 m0 n | false -> sel2 m1 (n - 2) [@va_qattr] let sel8 (#a:Type) (m:map8 a) (n:int) : a = match m with (m0, m1) -> match n < 4 with true -> sel4 m0 n | false -> sel4 m1 (n - 4) [@va_qattr] let sel16 (#a:Type) (m:map16 a) (n:int) : a = match m with (m0, m1) -> match n < 8 with true -> sel8 m0 n | false -> sel8 m1 (n - 8) [@va_qattr] let upd2 (#a:Type) (m:map2 a) (n:int) (v:a) : map2 a = match m with (m0, m1) -> match n < 1 with true -> (v, m1) | false -> (m0, v) [@va_qattr] let upd4 (#a:Type) (m:map4 a) (n:int) (v:a) : map4 a = match m with (m0, m1) -> match n < 2 with true -> (upd2 m0 n v, m1) | false -> (m0, upd2 m1 (n - 2) v) [@va_qattr] let upd8 (#a:Type) (m:map8 a) (n:int) (v:a) : map8 a = match m with (m0, m1) -> match n < 4 with true -> (upd4 m0 n v, m1) | false -> (m0, upd4 m1 (n - 4) v) [@va_qattr]
false
false
Vale.Lib.Map16.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val upd16 (#a: Type) (m: map16 a) (n: int) (v: a) : map16 a
[]
Vale.Lib.Map16.upd16
{ "file_name": "vale/code/lib/collections/Vale.Lib.Map16.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
m: Vale.Lib.Map16.map16 a -> n: Prims.int -> v: a -> Vale.Lib.Map16.map16 a
{ "end_col": 79, "end_line": 48, "start_col": 2, "start_line": 47 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let length s = strlen s
let length s =
false
null
false
strlen s
{ "checked_file": "FStar.String.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Char.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "FStar.String.fsti" }
[ "total" ]
[ "Prims.string", "FStar.String.strlen", "Prims.nat" ]
[]
(* Copyright 2008-2019 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.String open FStar.List.Tot (* String is a primitive type in F*. Most of the functions in this interface have a special status in that they are: 1. All the total functions in this module are handled by F*'s normalizers and can be reduced during typechecking 2. All the total functions, plus two functions in the ML effect, have native OCaml implementations in FStar_String.ml These functions are, however, not suitable for use in Low* code, since many of them incur implicit allocations that must be garbage collected. For strings in Low*, see LowStar.String, LowStar.Literal etc. *) type char = FStar.Char.char /// `list_of_string` and `string_of_list`: A pair of coercions to /// expose and pack a string as a list of characters val list_of_string : string -> Tot (list char) val string_of_list : list char -> Tot string /// A pair val string_of_list_of_string (s:string) : Lemma (string_of_list (list_of_string s) == s) val list_of_string_of_list (l:list char) : Lemma (list_of_string (string_of_list l) == l) /// `strlen s` counts the number of utf8 values in a string /// It is not the byte length of a string let strlen s = List.length (list_of_string s) /// `length`, an alias for `strlen`
false
true
FStar.String.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val length : s: Prims.string -> Prims.nat
[]
FStar.String.length
{ "file_name": "ulib/FStar.String.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s: Prims.string -> Prims.nat
{ "end_col": 23, "end_line": 55, "start_col": 15, "start_line": 55 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let maxlen s n = b2t (normalize_term (strlen s <= n)) \/ strlen s <= n
let maxlen s n =
false
null
false
b2t (normalize_term (strlen s <= n)) \/ strlen s <= n
{ "checked_file": "FStar.String.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Char.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "FStar.String.fsti" }
[ "total" ]
[ "Prims.string", "Prims.int", "Prims.l_or", "Prims.b2t", "FStar.Pervasives.normalize_term", "Prims.bool", "Prims.op_LessThanOrEqual", "FStar.String.strlen", "Prims.logical" ]
[]
(* Copyright 2008-2019 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.String open FStar.List.Tot (* String is a primitive type in F*. Most of the functions in this interface have a special status in that they are: 1. All the total functions in this module are handled by F*'s normalizers and can be reduced during typechecking 2. All the total functions, plus two functions in the ML effect, have native OCaml implementations in FStar_String.ml These functions are, however, not suitable for use in Low* code, since many of them incur implicit allocations that must be garbage collected. For strings in Low*, see LowStar.String, LowStar.Literal etc. *) type char = FStar.Char.char /// `list_of_string` and `string_of_list`: A pair of coercions to /// expose and pack a string as a list of characters val list_of_string : string -> Tot (list char) val string_of_list : list char -> Tot string /// A pair val string_of_list_of_string (s:string) : Lemma (string_of_list (list_of_string s) == s) val list_of_string_of_list (l:list char) : Lemma (list_of_string (string_of_list l) == l) /// `strlen s` counts the number of utf8 values in a string /// It is not the byte length of a string let strlen s = List.length (list_of_string s) /// `length`, an alias for `strlen` unfold let length s = strlen s /// `maxlen`: When applied to a literal s of less than n characters, /// `maxlen s n` reduces to `True` before going to the SMT solver. /// Otherwise, the left disjunct reduces partially but the right /// disjunct remains as is, allowing to keep `strlen s <= n` in the /// context.
false
true
FStar.String.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val maxlen : s: Prims.string -> n: Prims.int -> Prims.logical
[]
FStar.String.maxlen
{ "file_name": "ulib/FStar.String.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s: Prims.string -> n: Prims.int -> Prims.logical
{ "end_col": 70, "end_line": 63, "start_col": 17, "start_line": 63 }
Prims.Tot
val string_of_char (c: char) : Tot string
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let string_of_char (c:char) : Tot string = make 1 c
val string_of_char (c: char) : Tot string let string_of_char (c: char) : Tot string =
false
null
false
make 1 c
{ "checked_file": "FStar.String.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Char.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "FStar.String.fsti" }
[ "total" ]
[ "FStar.String.char", "FStar.String.make", "Prims.string" ]
[]
(* Copyright 2008-2019 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.String open FStar.List.Tot (* String is a primitive type in F*. Most of the functions in this interface have a special status in that they are: 1. All the total functions in this module are handled by F*'s normalizers and can be reduced during typechecking 2. All the total functions, plus two functions in the ML effect, have native OCaml implementations in FStar_String.ml These functions are, however, not suitable for use in Low* code, since many of them incur implicit allocations that must be garbage collected. For strings in Low*, see LowStar.String, LowStar.Literal etc. *) type char = FStar.Char.char /// `list_of_string` and `string_of_list`: A pair of coercions to /// expose and pack a string as a list of characters val list_of_string : string -> Tot (list char) val string_of_list : list char -> Tot string /// A pair val string_of_list_of_string (s:string) : Lemma (string_of_list (list_of_string s) == s) val list_of_string_of_list (l:list char) : Lemma (list_of_string (string_of_list l) == l) /// `strlen s` counts the number of utf8 values in a string /// It is not the byte length of a string let strlen s = List.length (list_of_string s) /// `length`, an alias for `strlen` unfold let length s = strlen s /// `maxlen`: When applied to a literal s of less than n characters, /// `maxlen s n` reduces to `True` before going to the SMT solver. /// Otherwise, the left disjunct reduces partially but the right /// disjunct remains as is, allowing to keep `strlen s <= n` in the /// context. unfold let maxlen s n = b2t (normalize_term (strlen s <= n)) \/ strlen s <= n /// `make l c`: builds a string of length `l` with each character set /// to `c` val make: l:nat -> char -> Tot (s:string {length s = l})
false
true
FStar.String.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val string_of_char (c: char) : Tot string
[]
FStar.String.string_of_char
{ "file_name": "ulib/FStar.String.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
c: FStar.String.char -> Prims.string
{ "end_col": 51, "end_line": 70, "start_col": 43, "start_line": 70 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let strlen s = List.length (list_of_string s)
let strlen s =
false
null
false
List.length (list_of_string s)
{ "checked_file": "FStar.String.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Char.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "FStar.String.fsti" }
[ "total" ]
[ "Prims.string", "FStar.List.Tot.Base.length", "FStar.String.char", "FStar.String.list_of_string", "Prims.nat" ]
[]
(* Copyright 2008-2019 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.String open FStar.List.Tot (* String is a primitive type in F*. Most of the functions in this interface have a special status in that they are: 1. All the total functions in this module are handled by F*'s normalizers and can be reduced during typechecking 2. All the total functions, plus two functions in the ML effect, have native OCaml implementations in FStar_String.ml These functions are, however, not suitable for use in Low* code, since many of them incur implicit allocations that must be garbage collected. For strings in Low*, see LowStar.String, LowStar.Literal etc. *) type char = FStar.Char.char /// `list_of_string` and `string_of_list`: A pair of coercions to /// expose and pack a string as a list of characters val list_of_string : string -> Tot (list char) val string_of_list : list char -> Tot string /// A pair val string_of_list_of_string (s:string) : Lemma (string_of_list (list_of_string s) == s) val list_of_string_of_list (l:list char) : Lemma (list_of_string (string_of_list l) == l) /// `strlen s` counts the number of utf8 values in a string
false
true
FStar.String.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val strlen : s: Prims.string -> Prims.nat
[]
FStar.String.strlen
{ "file_name": "ulib/FStar.String.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s: Prims.string -> Prims.nat
{ "end_col": 45, "end_line": 51, "start_col": 15, "start_line": 51 }
FStar.Pervasives.Lemma
val concat_injective (s0 s0' s1 s1': string) : Lemma (s0 ^ s1 == s0' ^ s1' /\ (length s0 == length s0' \/ length s1 == length s1') ==> s0 == s0' /\ s1 == s1')
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let concat_injective (s0 s0':string) (s1 s1':string) : Lemma (s0 ^ s1 == s0' ^ s1' /\ (length s0 == length s0' \/ length s1 == length s1') ==> s0 == s0' /\ s1 == s1') = list_of_concat s0 s1; list_of_concat s0' s1'; append_injective (list_of_string s0) (list_of_string s0') (list_of_string s1) (list_of_string s1'); string_of_list_of_string s0; string_of_list_of_string s0'; string_of_list_of_string s1; string_of_list_of_string s1'
val concat_injective (s0 s0' s1 s1': string) : Lemma (s0 ^ s1 == s0' ^ s1' /\ (length s0 == length s0' \/ length s1 == length s1') ==> s0 == s0' /\ s1 == s1') let concat_injective (s0 s0' s1 s1': string) : Lemma (s0 ^ s1 == s0' ^ s1' /\ (length s0 == length s0' \/ length s1 == length s1') ==> s0 == s0' /\ s1 == s1') =
false
null
true
list_of_concat s0 s1; list_of_concat s0' s1'; append_injective (list_of_string s0) (list_of_string s0') (list_of_string s1) (list_of_string s1'); string_of_list_of_string s0; string_of_list_of_string s0'; string_of_list_of_string s1; string_of_list_of_string s1'
{ "checked_file": "FStar.String.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Char.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "FStar.String.fsti" }
[ "lemma" ]
[ "Prims.string", "FStar.String.string_of_list_of_string", "Prims.unit", "FStar.List.Tot.Properties.append_injective", "FStar.String.char", "FStar.String.list_of_string", "FStar.String.list_of_concat", "Prims.l_True", "Prims.squash", "Prims.l_imp", "Prims.l_and", "Prims.eq2", "Prims.op_Hat", "Prims.l_or", "Prims.nat", "FStar.String.length", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2019 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.String open FStar.List.Tot (* String is a primitive type in F*. Most of the functions in this interface have a special status in that they are: 1. All the total functions in this module are handled by F*'s normalizers and can be reduced during typechecking 2. All the total functions, plus two functions in the ML effect, have native OCaml implementations in FStar_String.ml These functions are, however, not suitable for use in Low* code, since many of them incur implicit allocations that must be garbage collected. For strings in Low*, see LowStar.String, LowStar.Literal etc. *) type char = FStar.Char.char /// `list_of_string` and `string_of_list`: A pair of coercions to /// expose and pack a string as a list of characters val list_of_string : string -> Tot (list char) val string_of_list : list char -> Tot string /// A pair val string_of_list_of_string (s:string) : Lemma (string_of_list (list_of_string s) == s) val list_of_string_of_list (l:list char) : Lemma (list_of_string (string_of_list l) == l) /// `strlen s` counts the number of utf8 values in a string /// It is not the byte length of a string let strlen s = List.length (list_of_string s) /// `length`, an alias for `strlen` unfold let length s = strlen s /// `maxlen`: When applied to a literal s of less than n characters, /// `maxlen s n` reduces to `True` before going to the SMT solver. /// Otherwise, the left disjunct reduces partially but the right /// disjunct remains as is, allowing to keep `strlen s <= n` in the /// context. unfold let maxlen s n = b2t (normalize_term (strlen s <= n)) \/ strlen s <= n /// `make l c`: builds a string of length `l` with each character set /// to `c` val make: l:nat -> char -> Tot (s:string {length s = l}) /// `string_of_char`: A convenient abbreviation for `make 1 c` let string_of_char (c:char) : Tot string = make 1 c /// `split cs s`: splits the string by delimiters in `cs` val split: list char -> string -> Tot (list string) /// `concat s l` concatentates the strings in `l` delimited by `s` val concat: string -> list string -> Tot string /// `compare s0 s1`: lexicographic ordering on strings val compare: string -> string -> Tot int /// `lowercase`: transform each character to its lowercase variant val lowercase: string -> Tot string /// `uppercase`: transform each character to its uppercase variant val uppercase: string -> Tot string /// `index s n`: returns the nth character in `s` val index: s:string -> n:nat {n < length s} -> Tot char /// `index_of s c`: /// The first index of `c` in `s` /// returns -1 if the char is not found, for compatibility with C val index_of: string -> char -> Tot int /// `sub s i len` /// Second argument is a length, not an index. /// Returns a substring of length `len` beginning at `i` val sub: s:string -> i:nat -> l:nat{i + l <= length s} -> Tot (r: string {length r = l}) /// `collect f s`: maps `f` over each character of `s` /// from left to right, appending and flattening the result [@@(deprecated "FStar.String.collect can be defined using list_of_string and List.collect")] val collect: (char -> FStar.All.ML string) -> string -> FStar.All.ML string /// `substring s i len` /// A partial variant of `sub s i len` without bounds checks. /// May fail with index out of bounds val substring: string -> int -> int -> Ex string /// `get s i`: Similar to `index` except it may fail /// if `i` is out of bounds val get: string -> int -> Ex char /// Some lemmas (admitted for now as we don't have a model) val concat_length (s1 s2: string): Lemma (ensures length (s1 ^ s2) = length s1 + length s2) val list_of_concat (s1 s2: string): Lemma (ensures list_of_string (s1 ^ s2) == list_of_string s1 @ list_of_string s2) val index_string_of_list (l:list char) (i : nat{i < List.Tot.length l}) : Lemma ( (**) list_of_string_of_list l; // necessary to get equality between the lengths index (string_of_list l) i == List.Tot.index l i) let index_list_of_string (s:string) (i : nat{i < length s}) : Lemma (List.Tot.index (list_of_string s) i == index s i) = index_string_of_list (list_of_string s) i; string_of_list_of_string s let concat_injective (s0 s0':string) (s1 s1':string) : Lemma (s0 ^ s1 == s0' ^ s1' /\ (length s0 == length s0' \/ length s1 == length s1') ==>
false
false
FStar.String.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val concat_injective (s0 s0' s1 s1': string) : Lemma (s0 ^ s1 == s0' ^ s1' /\ (length s0 == length s0' \/ length s1 == length s1') ==> s0 == s0' /\ s1 == s1')
[]
FStar.String.concat_injective
{ "file_name": "ulib/FStar.String.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s0: Prims.string -> s0': Prims.string -> s1: Prims.string -> s1': Prims.string -> FStar.Pervasives.Lemma (ensures s0 ^ s1 == s0' ^ s1' /\ (FStar.String.length s0 == FStar.String.length s0' \/ FStar.String.length s1 == FStar.String.length s1') ==> s0 == s0' /\ s1 == s1')
{ "end_col": 32, "end_line": 148, "start_col": 4, "start_line": 139 }
FStar.Pervasives.Lemma
val index_list_of_string (s: string) (i: nat{i < length s}) : Lemma (List.Tot.index (list_of_string s) i == index s i)
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let index_list_of_string (s:string) (i : nat{i < length s}) : Lemma (List.Tot.index (list_of_string s) i == index s i) = index_string_of_list (list_of_string s) i; string_of_list_of_string s
val index_list_of_string (s: string) (i: nat{i < length s}) : Lemma (List.Tot.index (list_of_string s) i == index s i) let index_list_of_string (s: string) (i: nat{i < length s}) : Lemma (List.Tot.index (list_of_string s) i == index s i) =
false
null
true
index_string_of_list (list_of_string s) i; string_of_list_of_string s
{ "checked_file": "FStar.String.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Char.fsti.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "FStar.String.fsti" }
[ "lemma" ]
[ "Prims.string", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.String.length", "FStar.String.string_of_list_of_string", "Prims.unit", "FStar.String.index_string_of_list", "FStar.String.list_of_string", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.String.char", "FStar.List.Tot.Base.index", "FStar.String.index", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2019 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.String open FStar.List.Tot (* String is a primitive type in F*. Most of the functions in this interface have a special status in that they are: 1. All the total functions in this module are handled by F*'s normalizers and can be reduced during typechecking 2. All the total functions, plus two functions in the ML effect, have native OCaml implementations in FStar_String.ml These functions are, however, not suitable for use in Low* code, since many of them incur implicit allocations that must be garbage collected. For strings in Low*, see LowStar.String, LowStar.Literal etc. *) type char = FStar.Char.char /// `list_of_string` and `string_of_list`: A pair of coercions to /// expose and pack a string as a list of characters val list_of_string : string -> Tot (list char) val string_of_list : list char -> Tot string /// A pair val string_of_list_of_string (s:string) : Lemma (string_of_list (list_of_string s) == s) val list_of_string_of_list (l:list char) : Lemma (list_of_string (string_of_list l) == l) /// `strlen s` counts the number of utf8 values in a string /// It is not the byte length of a string let strlen s = List.length (list_of_string s) /// `length`, an alias for `strlen` unfold let length s = strlen s /// `maxlen`: When applied to a literal s of less than n characters, /// `maxlen s n` reduces to `True` before going to the SMT solver. /// Otherwise, the left disjunct reduces partially but the right /// disjunct remains as is, allowing to keep `strlen s <= n` in the /// context. unfold let maxlen s n = b2t (normalize_term (strlen s <= n)) \/ strlen s <= n /// `make l c`: builds a string of length `l` with each character set /// to `c` val make: l:nat -> char -> Tot (s:string {length s = l}) /// `string_of_char`: A convenient abbreviation for `make 1 c` let string_of_char (c:char) : Tot string = make 1 c /// `split cs s`: splits the string by delimiters in `cs` val split: list char -> string -> Tot (list string) /// `concat s l` concatentates the strings in `l` delimited by `s` val concat: string -> list string -> Tot string /// `compare s0 s1`: lexicographic ordering on strings val compare: string -> string -> Tot int /// `lowercase`: transform each character to its lowercase variant val lowercase: string -> Tot string /// `uppercase`: transform each character to its uppercase variant val uppercase: string -> Tot string /// `index s n`: returns the nth character in `s` val index: s:string -> n:nat {n < length s} -> Tot char /// `index_of s c`: /// The first index of `c` in `s` /// returns -1 if the char is not found, for compatibility with C val index_of: string -> char -> Tot int /// `sub s i len` /// Second argument is a length, not an index. /// Returns a substring of length `len` beginning at `i` val sub: s:string -> i:nat -> l:nat{i + l <= length s} -> Tot (r: string {length r = l}) /// `collect f s`: maps `f` over each character of `s` /// from left to right, appending and flattening the result [@@(deprecated "FStar.String.collect can be defined using list_of_string and List.collect")] val collect: (char -> FStar.All.ML string) -> string -> FStar.All.ML string /// `substring s i len` /// A partial variant of `sub s i len` without bounds checks. /// May fail with index out of bounds val substring: string -> int -> int -> Ex string /// `get s i`: Similar to `index` except it may fail /// if `i` is out of bounds val get: string -> int -> Ex char /// Some lemmas (admitted for now as we don't have a model) val concat_length (s1 s2: string): Lemma (ensures length (s1 ^ s2) = length s1 + length s2) val list_of_concat (s1 s2: string): Lemma (ensures list_of_string (s1 ^ s2) == list_of_string s1 @ list_of_string s2) val index_string_of_list (l:list char) (i : nat{i < List.Tot.length l}) : Lemma ( (**) list_of_string_of_list l; // necessary to get equality between the lengths index (string_of_list l) i == List.Tot.index l i) let index_list_of_string (s:string) (i : nat{i < length s}) :
false
false
FStar.String.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val index_list_of_string (s: string) (i: nat{i < length s}) : Lemma (List.Tot.index (list_of_string s) i == index s i)
[]
FStar.String.index_list_of_string
{ "file_name": "ulib/FStar.String.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s: Prims.string -> i: Prims.nat{i < FStar.String.length s} -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.index (FStar.String.list_of_string s) i == FStar.String.index s i)
{ "end_col": 28, "end_line": 130, "start_col": 2, "start_line": 129 }
Prims.Tot
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "LB" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let fragments = list fragment
let fragments =
false
null
false
list fragment
{ "checked_file": "LowStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked", "FStar.BigOps.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Printf.fst" }
[ "total" ]
[ "Prims.list", "LowStar.Printf.fragment" ]
[]
(* 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 LowStar.Printf /// This module provides imperative printing functions for several /// primitive Low* types, including /// -- booleans (%b) /// -- characters (%c) /// -- strings (%s) /// -- machine integers /// (UInt8.t as %uy, UInt16.t as %us, UInt32.t as %ul, and UInt64.t as %uL; /// Int8.t as %y, Int16.t as %i, Int32.t as %l , and Int64.t as %L) /// -- and arrays (aka buffers) of these base types formatted /// as %xN, where N is the format specifier for the array element type /// e.g., %xuy for buffers of UInt8.t /// The main function of this module is `printf` /// There are a few main differences relative to C printf /// -- The format specifiers are different (see above) /// /// -- For technical reasons explained below, an extra dummy /// argument `done` has to be provided at the end for the /// computation to have any effect. /// /// E.g., one must write /// `printf "%b %c" true 'c' done` /// rather than just /// `printf "%b %c" true 'c'` /// /// -- When printing arrays, two arguments must be passed; the /// length of the array fragment to be formatted and the array /// itself /// /// -- When extracted, rather than producing a C `printf` (which /// does not, e.g., support printing of dynamically sized /// arrays), our `printf` is specialized to a sequence of calls /// to primitive printers for each supported type /// /// Before diving into the technical details of how this module works, /// you might want to see a sample usage at the very end of this file. open FStar.Char open FStar.String open FStar.HyperStack.ST module L = FStar.List.Tot module LB = LowStar.Monotonic.Buffer /// `lmbuffer a r s l` is /// - a monotonic buffer of `a` /// - governed by preorders `r` and `s` /// - with length `l` let lmbuffer a r s l = b:LB.mbuffer a r s{ LB.len b == l } /// `StTrivial`: A effect abbreviation for a stateful computation /// with no precondition, and which does not change the state effect StTrivial (a:Type) = Stack a (requires fun h -> True) (ensures fun h0 _ h1 -> h0==h1) /// `StBuf a b`: A effect abbreviation for a stateful computation /// that may read `b` does not change the state effect StBuf (a:Type) #t #r #s #l (b:lmbuffer t r s l) = Stack a (requires fun h -> LB.live h b) (ensures (fun h0 _ h1 -> h0 == h1)) /// Primitive printers for all the types supported by this module assume val print_string: string -> StTrivial unit assume val print_char : char -> StTrivial unit assume val print_u8 : UInt8.t -> StTrivial unit assume val print_u16 : UInt16.t -> StTrivial unit assume val print_u32 : UInt32.t -> StTrivial unit assume val print_u64 : UInt64.t -> StTrivial unit assume val print_i8 : Int8.t -> StTrivial unit assume val print_i16 : Int16.t -> StTrivial unit assume val print_i32 : Int32.t -> StTrivial unit assume val print_i64 : Int64.t -> StTrivial unit assume val print_bool : bool -> StTrivial unit assume val print_lmbuffer_bool (l:_) (#r:_) (#s:_) (b:lmbuffer bool r s l) : StBuf unit b assume val print_lmbuffer_char (l:_) (#r:_) (#s:_) (b:lmbuffer char r s l) : StBuf unit b assume val print_lmbuffer_string (l:_) (#r:_) (#s:_) (b:lmbuffer string r s l) : StBuf unit b assume val print_lmbuffer_u8 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt8.t r s l) : StBuf unit b assume val print_lmbuffer_u16 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt16.t r s l) : StBuf unit b assume val print_lmbuffer_u32 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt32.t r s l) : StBuf unit b assume val print_lmbuffer_u64 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt64.t r s l) : StBuf unit b assume val print_lmbuffer_i8 (l:_) (#r:_) (#s:_) (b:lmbuffer Int8.t r s l) : StBuf unit b assume val print_lmbuffer_i16 (l:_) (#r:_) (#s:_) (b:lmbuffer Int16.t r s l) : StBuf unit b assume val print_lmbuffer_i32 (l:_) (#r:_) (#s:_) (b:lmbuffer Int32.t r s l) : StBuf unit b assume val print_lmbuffer_i64 (l:_) (#r:_) (#s:_) (b:lmbuffer Int64.t r s l) : StBuf unit b /// An attribute to control reduction noextract irreducible let __reduce__ = unit /// Base types supported so far noextract type base_typ = | Bool | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 /// Argument types are base types and arrays thereof /// Or polymorphic arguments specified by "%a" noextract type arg = | Base of base_typ | Array of base_typ | Any /// Interpreting a `base_typ` as a type [@@__reduce__] noextract let base_typ_as_type (b:base_typ) : Type0 = match b with | Bool -> bool | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t /// `fragment`: A format string is parsed into a list of fragments of /// string literals and other arguments that need to be spliced in /// (interpolated) noextract type fragment = | Frag of string | Interpolate of arg
false
true
LowStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val fragments : Type0
[]
LowStar.Printf.fragments
{ "file_name": "ulib/LowStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Type0
{ "end_col": 29, "end_line": 162, "start_col": 16, "start_line": 162 }
Prims.Tot
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "LB" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lmbuffer a r s l = b:LB.mbuffer a r s{ LB.len b == l }
let lmbuffer a r s l =
false
null
false
b: LB.mbuffer a r s {LB.len b == l}
{ "checked_file": "LowStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked", "FStar.BigOps.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Printf.fst" }
[ "total" ]
[ "LowStar.Monotonic.Buffer.srel", "FStar.UInt32.t", "LowStar.Monotonic.Buffer.mbuffer", "Prims.eq2", "LowStar.Monotonic.Buffer.len" ]
[]
(* 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 LowStar.Printf /// This module provides imperative printing functions for several /// primitive Low* types, including /// -- booleans (%b) /// -- characters (%c) /// -- strings (%s) /// -- machine integers /// (UInt8.t as %uy, UInt16.t as %us, UInt32.t as %ul, and UInt64.t as %uL; /// Int8.t as %y, Int16.t as %i, Int32.t as %l , and Int64.t as %L) /// -- and arrays (aka buffers) of these base types formatted /// as %xN, where N is the format specifier for the array element type /// e.g., %xuy for buffers of UInt8.t /// The main function of this module is `printf` /// There are a few main differences relative to C printf /// -- The format specifiers are different (see above) /// /// -- For technical reasons explained below, an extra dummy /// argument `done` has to be provided at the end for the /// computation to have any effect. /// /// E.g., one must write /// `printf "%b %c" true 'c' done` /// rather than just /// `printf "%b %c" true 'c'` /// /// -- When printing arrays, two arguments must be passed; the /// length of the array fragment to be formatted and the array /// itself /// /// -- When extracted, rather than producing a C `printf` (which /// does not, e.g., support printing of dynamically sized /// arrays), our `printf` is specialized to a sequence of calls /// to primitive printers for each supported type /// /// Before diving into the technical details of how this module works, /// you might want to see a sample usage at the very end of this file. open FStar.Char open FStar.String open FStar.HyperStack.ST module L = FStar.List.Tot module LB = LowStar.Monotonic.Buffer /// `lmbuffer a r s l` is /// - a monotonic buffer of `a` /// - governed by preorders `r` and `s` /// - with length `l`
false
false
LowStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lmbuffer : a: Type0 -> r: LowStar.Monotonic.Buffer.srel a -> s: LowStar.Monotonic.Buffer.srel a -> l: FStar.UInt32.t -> Type0
[]
LowStar.Printf.lmbuffer
{ "file_name": "ulib/LowStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: Type0 -> r: LowStar.Monotonic.Buffer.srel a -> s: LowStar.Monotonic.Buffer.srel a -> l: FStar.UInt32.t -> Type0
{ "end_col": 5, "end_line": 68, "start_col": 4, "start_line": 66 }
Prims.Tot
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "LB" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let fragment_printer = (acc:list frag_t) -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1)
let fragment_printer =
false
null
false
acc: list frag_t -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1)
{ "checked_file": "LowStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked", "FStar.BigOps.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Printf.fst" }
[ "total" ]
[ "Prims.list", "LowStar.Printf.frag_t", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "LowStar.Printf.live_frags", "Prims.eq2" ]
[]
(* 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 LowStar.Printf /// This module provides imperative printing functions for several /// primitive Low* types, including /// -- booleans (%b) /// -- characters (%c) /// -- strings (%s) /// -- machine integers /// (UInt8.t as %uy, UInt16.t as %us, UInt32.t as %ul, and UInt64.t as %uL; /// Int8.t as %y, Int16.t as %i, Int32.t as %l , and Int64.t as %L) /// -- and arrays (aka buffers) of these base types formatted /// as %xN, where N is the format specifier for the array element type /// e.g., %xuy for buffers of UInt8.t /// The main function of this module is `printf` /// There are a few main differences relative to C printf /// -- The format specifiers are different (see above) /// /// -- For technical reasons explained below, an extra dummy /// argument `done` has to be provided at the end for the /// computation to have any effect. /// /// E.g., one must write /// `printf "%b %c" true 'c' done` /// rather than just /// `printf "%b %c" true 'c'` /// /// -- When printing arrays, two arguments must be passed; the /// length of the array fragment to be formatted and the array /// itself /// /// -- When extracted, rather than producing a C `printf` (which /// does not, e.g., support printing of dynamically sized /// arrays), our `printf` is specialized to a sequence of calls /// to primitive printers for each supported type /// /// Before diving into the technical details of how this module works, /// you might want to see a sample usage at the very end of this file. open FStar.Char open FStar.String open FStar.HyperStack.ST module L = FStar.List.Tot module LB = LowStar.Monotonic.Buffer /// `lmbuffer a r s l` is /// - a monotonic buffer of `a` /// - governed by preorders `r` and `s` /// - with length `l` let lmbuffer a r s l = b:LB.mbuffer a r s{ LB.len b == l } /// `StTrivial`: A effect abbreviation for a stateful computation /// with no precondition, and which does not change the state effect StTrivial (a:Type) = Stack a (requires fun h -> True) (ensures fun h0 _ h1 -> h0==h1) /// `StBuf a b`: A effect abbreviation for a stateful computation /// that may read `b` does not change the state effect StBuf (a:Type) #t #r #s #l (b:lmbuffer t r s l) = Stack a (requires fun h -> LB.live h b) (ensures (fun h0 _ h1 -> h0 == h1)) /// Primitive printers for all the types supported by this module assume val print_string: string -> StTrivial unit assume val print_char : char -> StTrivial unit assume val print_u8 : UInt8.t -> StTrivial unit assume val print_u16 : UInt16.t -> StTrivial unit assume val print_u32 : UInt32.t -> StTrivial unit assume val print_u64 : UInt64.t -> StTrivial unit assume val print_i8 : Int8.t -> StTrivial unit assume val print_i16 : Int16.t -> StTrivial unit assume val print_i32 : Int32.t -> StTrivial unit assume val print_i64 : Int64.t -> StTrivial unit assume val print_bool : bool -> StTrivial unit assume val print_lmbuffer_bool (l:_) (#r:_) (#s:_) (b:lmbuffer bool r s l) : StBuf unit b assume val print_lmbuffer_char (l:_) (#r:_) (#s:_) (b:lmbuffer char r s l) : StBuf unit b assume val print_lmbuffer_string (l:_) (#r:_) (#s:_) (b:lmbuffer string r s l) : StBuf unit b assume val print_lmbuffer_u8 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt8.t r s l) : StBuf unit b assume val print_lmbuffer_u16 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt16.t r s l) : StBuf unit b assume val print_lmbuffer_u32 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt32.t r s l) : StBuf unit b assume val print_lmbuffer_u64 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt64.t r s l) : StBuf unit b assume val print_lmbuffer_i8 (l:_) (#r:_) (#s:_) (b:lmbuffer Int8.t r s l) : StBuf unit b assume val print_lmbuffer_i16 (l:_) (#r:_) (#s:_) (b:lmbuffer Int16.t r s l) : StBuf unit b assume val print_lmbuffer_i32 (l:_) (#r:_) (#s:_) (b:lmbuffer Int32.t r s l) : StBuf unit b assume val print_lmbuffer_i64 (l:_) (#r:_) (#s:_) (b:lmbuffer Int64.t r s l) : StBuf unit b /// An attribute to control reduction noextract irreducible let __reduce__ = unit /// Base types supported so far noextract type base_typ = | Bool | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 /// Argument types are base types and arrays thereof /// Or polymorphic arguments specified by "%a" noextract type arg = | Base of base_typ | Array of base_typ | Any /// Interpreting a `base_typ` as a type [@@__reduce__] noextract let base_typ_as_type (b:base_typ) : Type0 = match b with | Bool -> bool | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t /// `fragment`: A format string is parsed into a list of fragments of /// string literals and other arguments that need to be spliced in /// (interpolated) noextract type fragment = | Frag of string | Interpolate of arg noextract let fragments = list fragment /// `parse_format s`: /// Parses a list of characters in a format string into a list of fragments /// Or None, in case the format string is invalid [@@__reduce__] noextract inline_for_extraction let rec parse_format (s:list char) : Tot (option fragments) (decreases (L.length s)) = let add_dir (d:arg) (ods : option fragments) = match ods with | None -> None | Some ds -> Some (Interpolate d::ds) in let head_buffer (ods:option fragments) = match ods with | Some (Interpolate (Base t) :: rest) -> Some (Interpolate (Array t) :: rest) | _ -> None in let cons_frag (c:char) (ods:option fragments) = match ods with | Some (Frag s::rest) -> Some (Frag (string_of_list (c :: list_of_string s)) :: rest) | Some rest -> Some (Frag (string_of_list [c]) :: rest) | _ -> None in match s with | [] -> Some [] | ['%'] -> None // %a... polymorphic arguments and preceded by their printers | '%' :: 'a' :: s' -> add_dir Any (parse_format s') // %x... arrays of base types | '%' :: 'x' :: s' -> head_buffer (parse_format ('%' :: s')) // %u ... Unsigned integers | '%' :: 'u' :: s' -> begin match s' with | 'y' :: s'' -> add_dir (Base U8) (parse_format s'') | 's' :: s'' -> add_dir (Base U16) (parse_format s'') | 'l' :: s'' -> add_dir (Base U32) (parse_format s'') | 'L' :: s'' -> add_dir (Base U64) (parse_format s'') | _ -> None end | '%' :: c :: s' -> begin match c with | '%' -> cons_frag '%' (parse_format s') | 'b' -> add_dir (Base Bool) (parse_format s') | 'c' -> add_dir (Base Char) (parse_format s') | 's' -> add_dir (Base String) (parse_format s') | 'y' -> add_dir (Base I8) (parse_format s') | 'i' -> add_dir (Base I16) (parse_format s') | 'l' -> add_dir (Base I32) (parse_format s') | 'L' -> add_dir (Base I64) (parse_format s') | _ -> None end | c :: s' -> cons_frag c (parse_format s') /// `parse_format_string`: a wrapper around `parse_format` [@@__reduce__] noextract inline_for_extraction let parse_format_string (s:string) : option fragments = parse_format (list_of_string s) /// `lift a` lifts the type `a` to a higher universe noextract type lift (a:Type u#a) : Type u#(max a b) = | Lift : a -> lift a /// `done` is a `unit` in universe 1 noextract let done : lift unit = Lift u#0 u#1 () /// `arg_t`: interpreting an argument as a type /// (in universe 1) since it is polymorphic in the preorders of a buffer /// GM: Somehow, this needs to be a `let rec` (even if it not really recursive) /// or print_frags fails to verify. I don't know why; the generated /// VC and its encoding seem identical (modulo hash consing in the /// latter). [@@__reduce__] noextract let rec arg_t (a:arg) : Type u#1 = match a with | Base t -> lift (base_typ_as_type t) | Array t -> (l:UInt32.t & r:_ & s:_ & lmbuffer (base_typ_as_type t) r s l) | Any -> (a:Type0 & (a -> StTrivial unit) & a) /// `frag_t`: a fragment is either a string literal or a argument to be interpolated noextract let frag_t = either string (a:arg & arg_t a) /// `live_frags h l` is a liveness predicate on all the buffers in `l` [@@__reduce__] noextract let rec live_frags (h:_) (l:list frag_t) : prop = match l with | [] -> True | Inl _ :: rest -> live_frags h rest | Inr a :: rest -> (match a with | (| Base _, _ |) -> live_frags h rest | (| Any, _ |) -> live_frags h rest | (| Array _, (| _, _, _, b |) |) -> LB.live h b /\ live_frags h rest) /// `interpret_frags` interprets a list of fragments as a Low* function type /// Note `l` is the fragments in L-to-R order (i.e., parsing order) /// `acc` accumulates the fragment values in reverse order [@@__reduce__] noextract let rec interpret_frags (l:fragments) (acc:list frag_t) : Type u#1 = match l with | [] -> // Always a dummy argument at the end // Ensures that all cases of this match // have the same universe, i.e., u#1 lift u#0 u#1 unit -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) | Interpolate (Base t) :: args -> // Base types are simple: we just take one more argument x:base_typ_as_type t -> interpret_frags args (Inr (| Base t, Lift x |) :: acc) | Interpolate (Array t) :: args -> // Arrays are implicitly polymorphic in their preorders `r` and `s` // which is what forces us to be in universe 1 // Note, the length `l` is explicit l:UInt32.t -> #r:LB.srel (base_typ_as_type t) -> #s:LB.srel (base_typ_as_type t) -> b:lmbuffer (base_typ_as_type t) r s l -> interpret_frags args (Inr (| Array t, (| l, r, s, b |) |) :: acc) | Interpolate Any :: args -> #a:Type0 -> p:(a -> StTrivial unit) -> x:a -> interpret_frags args (Inr (| Any, (| a, p, x |) |) :: acc) | Frag s :: args -> // Literal fragments do not incur an additional argument // We just accumulate them and recur interpret_frags args (Inl s :: acc) /// `normal` A normalization marker with very specific steps enabled noextract unfold let normal (#a:Type) (x:a) : a = FStar.Pervasives.norm [iota; zeta; delta_attr [`%__reduce__; `%BigOps.__reduce__]; delta_only [`%Base?; `%Array?; `%Some?; `%Some?.v; `%list_of_string]; primops; simplify] x /// `coerce`: A utility to trigger extensional equality of types noextract let coerce (x:'a{'a == 'b}) : 'b = x /// `fragment_printer`: The type of a printer of fragments noextract
false
true
LowStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val fragment_printer : Type
[]
LowStar.Printf.fragment_printer
{ "file_name": "ulib/LowStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Type
{ "end_col": 37, "end_line": 342, "start_col": 2, "start_line": 339 }
Prims.Tot
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "LB" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let frag_t = either string (a:arg & arg_t a)
let frag_t =
false
null
false
either string (a: arg & arg_t a)
{ "checked_file": "LowStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked", "FStar.BigOps.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Printf.fst" }
[ "total" ]
[ "FStar.Pervasives.either", "Prims.string", "Prims.dtuple2", "LowStar.Printf.arg", "LowStar.Printf.arg_t" ]
[]
(* 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 LowStar.Printf /// This module provides imperative printing functions for several /// primitive Low* types, including /// -- booleans (%b) /// -- characters (%c) /// -- strings (%s) /// -- machine integers /// (UInt8.t as %uy, UInt16.t as %us, UInt32.t as %ul, and UInt64.t as %uL; /// Int8.t as %y, Int16.t as %i, Int32.t as %l , and Int64.t as %L) /// -- and arrays (aka buffers) of these base types formatted /// as %xN, where N is the format specifier for the array element type /// e.g., %xuy for buffers of UInt8.t /// The main function of this module is `printf` /// There are a few main differences relative to C printf /// -- The format specifiers are different (see above) /// /// -- For technical reasons explained below, an extra dummy /// argument `done` has to be provided at the end for the /// computation to have any effect. /// /// E.g., one must write /// `printf "%b %c" true 'c' done` /// rather than just /// `printf "%b %c" true 'c'` /// /// -- When printing arrays, two arguments must be passed; the /// length of the array fragment to be formatted and the array /// itself /// /// -- When extracted, rather than producing a C `printf` (which /// does not, e.g., support printing of dynamically sized /// arrays), our `printf` is specialized to a sequence of calls /// to primitive printers for each supported type /// /// Before diving into the technical details of how this module works, /// you might want to see a sample usage at the very end of this file. open FStar.Char open FStar.String open FStar.HyperStack.ST module L = FStar.List.Tot module LB = LowStar.Monotonic.Buffer /// `lmbuffer a r s l` is /// - a monotonic buffer of `a` /// - governed by preorders `r` and `s` /// - with length `l` let lmbuffer a r s l = b:LB.mbuffer a r s{ LB.len b == l } /// `StTrivial`: A effect abbreviation for a stateful computation /// with no precondition, and which does not change the state effect StTrivial (a:Type) = Stack a (requires fun h -> True) (ensures fun h0 _ h1 -> h0==h1) /// `StBuf a b`: A effect abbreviation for a stateful computation /// that may read `b` does not change the state effect StBuf (a:Type) #t #r #s #l (b:lmbuffer t r s l) = Stack a (requires fun h -> LB.live h b) (ensures (fun h0 _ h1 -> h0 == h1)) /// Primitive printers for all the types supported by this module assume val print_string: string -> StTrivial unit assume val print_char : char -> StTrivial unit assume val print_u8 : UInt8.t -> StTrivial unit assume val print_u16 : UInt16.t -> StTrivial unit assume val print_u32 : UInt32.t -> StTrivial unit assume val print_u64 : UInt64.t -> StTrivial unit assume val print_i8 : Int8.t -> StTrivial unit assume val print_i16 : Int16.t -> StTrivial unit assume val print_i32 : Int32.t -> StTrivial unit assume val print_i64 : Int64.t -> StTrivial unit assume val print_bool : bool -> StTrivial unit assume val print_lmbuffer_bool (l:_) (#r:_) (#s:_) (b:lmbuffer bool r s l) : StBuf unit b assume val print_lmbuffer_char (l:_) (#r:_) (#s:_) (b:lmbuffer char r s l) : StBuf unit b assume val print_lmbuffer_string (l:_) (#r:_) (#s:_) (b:lmbuffer string r s l) : StBuf unit b assume val print_lmbuffer_u8 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt8.t r s l) : StBuf unit b assume val print_lmbuffer_u16 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt16.t r s l) : StBuf unit b assume val print_lmbuffer_u32 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt32.t r s l) : StBuf unit b assume val print_lmbuffer_u64 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt64.t r s l) : StBuf unit b assume val print_lmbuffer_i8 (l:_) (#r:_) (#s:_) (b:lmbuffer Int8.t r s l) : StBuf unit b assume val print_lmbuffer_i16 (l:_) (#r:_) (#s:_) (b:lmbuffer Int16.t r s l) : StBuf unit b assume val print_lmbuffer_i32 (l:_) (#r:_) (#s:_) (b:lmbuffer Int32.t r s l) : StBuf unit b assume val print_lmbuffer_i64 (l:_) (#r:_) (#s:_) (b:lmbuffer Int64.t r s l) : StBuf unit b /// An attribute to control reduction noextract irreducible let __reduce__ = unit /// Base types supported so far noextract type base_typ = | Bool | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 /// Argument types are base types and arrays thereof /// Or polymorphic arguments specified by "%a" noextract type arg = | Base of base_typ | Array of base_typ | Any /// Interpreting a `base_typ` as a type [@@__reduce__] noextract let base_typ_as_type (b:base_typ) : Type0 = match b with | Bool -> bool | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t /// `fragment`: A format string is parsed into a list of fragments of /// string literals and other arguments that need to be spliced in /// (interpolated) noextract type fragment = | Frag of string | Interpolate of arg noextract let fragments = list fragment /// `parse_format s`: /// Parses a list of characters in a format string into a list of fragments /// Or None, in case the format string is invalid [@@__reduce__] noextract inline_for_extraction let rec parse_format (s:list char) : Tot (option fragments) (decreases (L.length s)) = let add_dir (d:arg) (ods : option fragments) = match ods with | None -> None | Some ds -> Some (Interpolate d::ds) in let head_buffer (ods:option fragments) = match ods with | Some (Interpolate (Base t) :: rest) -> Some (Interpolate (Array t) :: rest) | _ -> None in let cons_frag (c:char) (ods:option fragments) = match ods with | Some (Frag s::rest) -> Some (Frag (string_of_list (c :: list_of_string s)) :: rest) | Some rest -> Some (Frag (string_of_list [c]) :: rest) | _ -> None in match s with | [] -> Some [] | ['%'] -> None // %a... polymorphic arguments and preceded by their printers | '%' :: 'a' :: s' -> add_dir Any (parse_format s') // %x... arrays of base types | '%' :: 'x' :: s' -> head_buffer (parse_format ('%' :: s')) // %u ... Unsigned integers | '%' :: 'u' :: s' -> begin match s' with | 'y' :: s'' -> add_dir (Base U8) (parse_format s'') | 's' :: s'' -> add_dir (Base U16) (parse_format s'') | 'l' :: s'' -> add_dir (Base U32) (parse_format s'') | 'L' :: s'' -> add_dir (Base U64) (parse_format s'') | _ -> None end | '%' :: c :: s' -> begin match c with | '%' -> cons_frag '%' (parse_format s') | 'b' -> add_dir (Base Bool) (parse_format s') | 'c' -> add_dir (Base Char) (parse_format s') | 's' -> add_dir (Base String) (parse_format s') | 'y' -> add_dir (Base I8) (parse_format s') | 'i' -> add_dir (Base I16) (parse_format s') | 'l' -> add_dir (Base I32) (parse_format s') | 'L' -> add_dir (Base I64) (parse_format s') | _ -> None end | c :: s' -> cons_frag c (parse_format s') /// `parse_format_string`: a wrapper around `parse_format` [@@__reduce__] noextract inline_for_extraction let parse_format_string (s:string) : option fragments = parse_format (list_of_string s) /// `lift a` lifts the type `a` to a higher universe noextract type lift (a:Type u#a) : Type u#(max a b) = | Lift : a -> lift a /// `done` is a `unit` in universe 1 noextract let done : lift unit = Lift u#0 u#1 () /// `arg_t`: interpreting an argument as a type /// (in universe 1) since it is polymorphic in the preorders of a buffer /// GM: Somehow, this needs to be a `let rec` (even if it not really recursive) /// or print_frags fails to verify. I don't know why; the generated /// VC and its encoding seem identical (modulo hash consing in the /// latter). [@@__reduce__] noextract let rec arg_t (a:arg) : Type u#1 = match a with | Base t -> lift (base_typ_as_type t) | Array t -> (l:UInt32.t & r:_ & s:_ & lmbuffer (base_typ_as_type t) r s l) | Any -> (a:Type0 & (a -> StTrivial unit) & a) /// `frag_t`: a fragment is either a string literal or a argument to be interpolated
false
true
LowStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val frag_t : Type
[]
LowStar.Printf.frag_t
{ "file_name": "ulib/LowStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Type
{ "end_col": 44, "end_line": 261, "start_col": 13, "start_line": 261 }
Prims.Tot
val normal (#a: Type) (x: a) : a
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "LB" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let normal (#a:Type) (x:a) : a = FStar.Pervasives.norm [iota; zeta; delta_attr [`%__reduce__; `%BigOps.__reduce__]; delta_only [`%Base?; `%Array?; `%Some?; `%Some?.v; `%list_of_string]; primops; simplify] x
val normal (#a: Type) (x: a) : a let normal (#a: Type) (x: a) : a =
false
null
false
FStar.Pervasives.norm [ iota; zeta; delta_attr [`%__reduce__; `%BigOps.__reduce__]; delta_only [`%Base?; `%Array?; `%Some?; `%Some?.v; `%list_of_string]; primops; simplify ] x
{ "checked_file": "LowStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked", "FStar.BigOps.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Printf.fst" }
[ "total" ]
[ "FStar.Pervasives.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.iota", "FStar.Pervasives.zeta", "FStar.Pervasives.delta_attr", "Prims.string", "Prims.Nil", "FStar.Pervasives.delta_only", "FStar.Pervasives.primops", "FStar.Pervasives.simplify" ]
[]
(* 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 LowStar.Printf /// This module provides imperative printing functions for several /// primitive Low* types, including /// -- booleans (%b) /// -- characters (%c) /// -- strings (%s) /// -- machine integers /// (UInt8.t as %uy, UInt16.t as %us, UInt32.t as %ul, and UInt64.t as %uL; /// Int8.t as %y, Int16.t as %i, Int32.t as %l , and Int64.t as %L) /// -- and arrays (aka buffers) of these base types formatted /// as %xN, where N is the format specifier for the array element type /// e.g., %xuy for buffers of UInt8.t /// The main function of this module is `printf` /// There are a few main differences relative to C printf /// -- The format specifiers are different (see above) /// /// -- For technical reasons explained below, an extra dummy /// argument `done` has to be provided at the end for the /// computation to have any effect. /// /// E.g., one must write /// `printf "%b %c" true 'c' done` /// rather than just /// `printf "%b %c" true 'c'` /// /// -- When printing arrays, two arguments must be passed; the /// length of the array fragment to be formatted and the array /// itself /// /// -- When extracted, rather than producing a C `printf` (which /// does not, e.g., support printing of dynamically sized /// arrays), our `printf` is specialized to a sequence of calls /// to primitive printers for each supported type /// /// Before diving into the technical details of how this module works, /// you might want to see a sample usage at the very end of this file. open FStar.Char open FStar.String open FStar.HyperStack.ST module L = FStar.List.Tot module LB = LowStar.Monotonic.Buffer /// `lmbuffer a r s l` is /// - a monotonic buffer of `a` /// - governed by preorders `r` and `s` /// - with length `l` let lmbuffer a r s l = b:LB.mbuffer a r s{ LB.len b == l } /// `StTrivial`: A effect abbreviation for a stateful computation /// with no precondition, and which does not change the state effect StTrivial (a:Type) = Stack a (requires fun h -> True) (ensures fun h0 _ h1 -> h0==h1) /// `StBuf a b`: A effect abbreviation for a stateful computation /// that may read `b` does not change the state effect StBuf (a:Type) #t #r #s #l (b:lmbuffer t r s l) = Stack a (requires fun h -> LB.live h b) (ensures (fun h0 _ h1 -> h0 == h1)) /// Primitive printers for all the types supported by this module assume val print_string: string -> StTrivial unit assume val print_char : char -> StTrivial unit assume val print_u8 : UInt8.t -> StTrivial unit assume val print_u16 : UInt16.t -> StTrivial unit assume val print_u32 : UInt32.t -> StTrivial unit assume val print_u64 : UInt64.t -> StTrivial unit assume val print_i8 : Int8.t -> StTrivial unit assume val print_i16 : Int16.t -> StTrivial unit assume val print_i32 : Int32.t -> StTrivial unit assume val print_i64 : Int64.t -> StTrivial unit assume val print_bool : bool -> StTrivial unit assume val print_lmbuffer_bool (l:_) (#r:_) (#s:_) (b:lmbuffer bool r s l) : StBuf unit b assume val print_lmbuffer_char (l:_) (#r:_) (#s:_) (b:lmbuffer char r s l) : StBuf unit b assume val print_lmbuffer_string (l:_) (#r:_) (#s:_) (b:lmbuffer string r s l) : StBuf unit b assume val print_lmbuffer_u8 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt8.t r s l) : StBuf unit b assume val print_lmbuffer_u16 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt16.t r s l) : StBuf unit b assume val print_lmbuffer_u32 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt32.t r s l) : StBuf unit b assume val print_lmbuffer_u64 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt64.t r s l) : StBuf unit b assume val print_lmbuffer_i8 (l:_) (#r:_) (#s:_) (b:lmbuffer Int8.t r s l) : StBuf unit b assume val print_lmbuffer_i16 (l:_) (#r:_) (#s:_) (b:lmbuffer Int16.t r s l) : StBuf unit b assume val print_lmbuffer_i32 (l:_) (#r:_) (#s:_) (b:lmbuffer Int32.t r s l) : StBuf unit b assume val print_lmbuffer_i64 (l:_) (#r:_) (#s:_) (b:lmbuffer Int64.t r s l) : StBuf unit b /// An attribute to control reduction noextract irreducible let __reduce__ = unit /// Base types supported so far noextract type base_typ = | Bool | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 /// Argument types are base types and arrays thereof /// Or polymorphic arguments specified by "%a" noextract type arg = | Base of base_typ | Array of base_typ | Any /// Interpreting a `base_typ` as a type [@@__reduce__] noextract let base_typ_as_type (b:base_typ) : Type0 = match b with | Bool -> bool | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t /// `fragment`: A format string is parsed into a list of fragments of /// string literals and other arguments that need to be spliced in /// (interpolated) noextract type fragment = | Frag of string | Interpolate of arg noextract let fragments = list fragment /// `parse_format s`: /// Parses a list of characters in a format string into a list of fragments /// Or None, in case the format string is invalid [@@__reduce__] noextract inline_for_extraction let rec parse_format (s:list char) : Tot (option fragments) (decreases (L.length s)) = let add_dir (d:arg) (ods : option fragments) = match ods with | None -> None | Some ds -> Some (Interpolate d::ds) in let head_buffer (ods:option fragments) = match ods with | Some (Interpolate (Base t) :: rest) -> Some (Interpolate (Array t) :: rest) | _ -> None in let cons_frag (c:char) (ods:option fragments) = match ods with | Some (Frag s::rest) -> Some (Frag (string_of_list (c :: list_of_string s)) :: rest) | Some rest -> Some (Frag (string_of_list [c]) :: rest) | _ -> None in match s with | [] -> Some [] | ['%'] -> None // %a... polymorphic arguments and preceded by their printers | '%' :: 'a' :: s' -> add_dir Any (parse_format s') // %x... arrays of base types | '%' :: 'x' :: s' -> head_buffer (parse_format ('%' :: s')) // %u ... Unsigned integers | '%' :: 'u' :: s' -> begin match s' with | 'y' :: s'' -> add_dir (Base U8) (parse_format s'') | 's' :: s'' -> add_dir (Base U16) (parse_format s'') | 'l' :: s'' -> add_dir (Base U32) (parse_format s'') | 'L' :: s'' -> add_dir (Base U64) (parse_format s'') | _ -> None end | '%' :: c :: s' -> begin match c with | '%' -> cons_frag '%' (parse_format s') | 'b' -> add_dir (Base Bool) (parse_format s') | 'c' -> add_dir (Base Char) (parse_format s') | 's' -> add_dir (Base String) (parse_format s') | 'y' -> add_dir (Base I8) (parse_format s') | 'i' -> add_dir (Base I16) (parse_format s') | 'l' -> add_dir (Base I32) (parse_format s') | 'L' -> add_dir (Base I64) (parse_format s') | _ -> None end | c :: s' -> cons_frag c (parse_format s') /// `parse_format_string`: a wrapper around `parse_format` [@@__reduce__] noextract inline_for_extraction let parse_format_string (s:string) : option fragments = parse_format (list_of_string s) /// `lift a` lifts the type `a` to a higher universe noextract type lift (a:Type u#a) : Type u#(max a b) = | Lift : a -> lift a /// `done` is a `unit` in universe 1 noextract let done : lift unit = Lift u#0 u#1 () /// `arg_t`: interpreting an argument as a type /// (in universe 1) since it is polymorphic in the preorders of a buffer /// GM: Somehow, this needs to be a `let rec` (even if it not really recursive) /// or print_frags fails to verify. I don't know why; the generated /// VC and its encoding seem identical (modulo hash consing in the /// latter). [@@__reduce__] noextract let rec arg_t (a:arg) : Type u#1 = match a with | Base t -> lift (base_typ_as_type t) | Array t -> (l:UInt32.t & r:_ & s:_ & lmbuffer (base_typ_as_type t) r s l) | Any -> (a:Type0 & (a -> StTrivial unit) & a) /// `frag_t`: a fragment is either a string literal or a argument to be interpolated noextract let frag_t = either string (a:arg & arg_t a) /// `live_frags h l` is a liveness predicate on all the buffers in `l` [@@__reduce__] noextract let rec live_frags (h:_) (l:list frag_t) : prop = match l with | [] -> True | Inl _ :: rest -> live_frags h rest | Inr a :: rest -> (match a with | (| Base _, _ |) -> live_frags h rest | (| Any, _ |) -> live_frags h rest | (| Array _, (| _, _, _, b |) |) -> LB.live h b /\ live_frags h rest) /// `interpret_frags` interprets a list of fragments as a Low* function type /// Note `l` is the fragments in L-to-R order (i.e., parsing order) /// `acc` accumulates the fragment values in reverse order [@@__reduce__] noextract let rec interpret_frags (l:fragments) (acc:list frag_t) : Type u#1 = match l with | [] -> // Always a dummy argument at the end // Ensures that all cases of this match // have the same universe, i.e., u#1 lift u#0 u#1 unit -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) | Interpolate (Base t) :: args -> // Base types are simple: we just take one more argument x:base_typ_as_type t -> interpret_frags args (Inr (| Base t, Lift x |) :: acc) | Interpolate (Array t) :: args -> // Arrays are implicitly polymorphic in their preorders `r` and `s` // which is what forces us to be in universe 1 // Note, the length `l` is explicit l:UInt32.t -> #r:LB.srel (base_typ_as_type t) -> #s:LB.srel (base_typ_as_type t) -> b:lmbuffer (base_typ_as_type t) r s l -> interpret_frags args (Inr (| Array t, (| l, r, s, b |) |) :: acc) | Interpolate Any :: args -> #a:Type0 -> p:(a -> StTrivial unit) -> x:a -> interpret_frags args (Inr (| Any, (| a, p, x |) |) :: acc) | Frag s :: args -> // Literal fragments do not incur an additional argument // We just accumulate them and recur interpret_frags args (Inl s :: acc) /// `normal` A normalization marker with very specific steps enabled noextract unfold
false
false
LowStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val normal (#a: Type) (x: a) : a
[]
LowStar.Printf.normal
{ "file_name": "ulib/LowStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: a -> a
{ "end_col": 6, "end_line": 330, "start_col": 2, "start_line": 323 }
Prims.Tot
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "LB" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let format_string = s:string{normal #bool (Some? (parse_format_string s))}
let format_string =
false
null
false
s: string{normal #bool (Some? (parse_format_string s))}
{ "checked_file": "LowStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked", "FStar.BigOps.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Printf.fst" }
[ "total" ]
[ "Prims.string", "Prims.b2t", "LowStar.Printf.normal", "Prims.bool", "FStar.Pervasives.Native.uu___is_Some", "LowStar.Printf.fragments", "LowStar.Printf.parse_format_string" ]
[]
(* 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 LowStar.Printf /// This module provides imperative printing functions for several /// primitive Low* types, including /// -- booleans (%b) /// -- characters (%c) /// -- strings (%s) /// -- machine integers /// (UInt8.t as %uy, UInt16.t as %us, UInt32.t as %ul, and UInt64.t as %uL; /// Int8.t as %y, Int16.t as %i, Int32.t as %l , and Int64.t as %L) /// -- and arrays (aka buffers) of these base types formatted /// as %xN, where N is the format specifier for the array element type /// e.g., %xuy for buffers of UInt8.t /// The main function of this module is `printf` /// There are a few main differences relative to C printf /// -- The format specifiers are different (see above) /// /// -- For technical reasons explained below, an extra dummy /// argument `done` has to be provided at the end for the /// computation to have any effect. /// /// E.g., one must write /// `printf "%b %c" true 'c' done` /// rather than just /// `printf "%b %c" true 'c'` /// /// -- When printing arrays, two arguments must be passed; the /// length of the array fragment to be formatted and the array /// itself /// /// -- When extracted, rather than producing a C `printf` (which /// does not, e.g., support printing of dynamically sized /// arrays), our `printf` is specialized to a sequence of calls /// to primitive printers for each supported type /// /// Before diving into the technical details of how this module works, /// you might want to see a sample usage at the very end of this file. open FStar.Char open FStar.String open FStar.HyperStack.ST module L = FStar.List.Tot module LB = LowStar.Monotonic.Buffer /// `lmbuffer a r s l` is /// - a monotonic buffer of `a` /// - governed by preorders `r` and `s` /// - with length `l` let lmbuffer a r s l = b:LB.mbuffer a r s{ LB.len b == l } /// `StTrivial`: A effect abbreviation for a stateful computation /// with no precondition, and which does not change the state effect StTrivial (a:Type) = Stack a (requires fun h -> True) (ensures fun h0 _ h1 -> h0==h1) /// `StBuf a b`: A effect abbreviation for a stateful computation /// that may read `b` does not change the state effect StBuf (a:Type) #t #r #s #l (b:lmbuffer t r s l) = Stack a (requires fun h -> LB.live h b) (ensures (fun h0 _ h1 -> h0 == h1)) /// Primitive printers for all the types supported by this module assume val print_string: string -> StTrivial unit assume val print_char : char -> StTrivial unit assume val print_u8 : UInt8.t -> StTrivial unit assume val print_u16 : UInt16.t -> StTrivial unit assume val print_u32 : UInt32.t -> StTrivial unit assume val print_u64 : UInt64.t -> StTrivial unit assume val print_i8 : Int8.t -> StTrivial unit assume val print_i16 : Int16.t -> StTrivial unit assume val print_i32 : Int32.t -> StTrivial unit assume val print_i64 : Int64.t -> StTrivial unit assume val print_bool : bool -> StTrivial unit assume val print_lmbuffer_bool (l:_) (#r:_) (#s:_) (b:lmbuffer bool r s l) : StBuf unit b assume val print_lmbuffer_char (l:_) (#r:_) (#s:_) (b:lmbuffer char r s l) : StBuf unit b assume val print_lmbuffer_string (l:_) (#r:_) (#s:_) (b:lmbuffer string r s l) : StBuf unit b assume val print_lmbuffer_u8 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt8.t r s l) : StBuf unit b assume val print_lmbuffer_u16 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt16.t r s l) : StBuf unit b assume val print_lmbuffer_u32 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt32.t r s l) : StBuf unit b assume val print_lmbuffer_u64 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt64.t r s l) : StBuf unit b assume val print_lmbuffer_i8 (l:_) (#r:_) (#s:_) (b:lmbuffer Int8.t r s l) : StBuf unit b assume val print_lmbuffer_i16 (l:_) (#r:_) (#s:_) (b:lmbuffer Int16.t r s l) : StBuf unit b assume val print_lmbuffer_i32 (l:_) (#r:_) (#s:_) (b:lmbuffer Int32.t r s l) : StBuf unit b assume val print_lmbuffer_i64 (l:_) (#r:_) (#s:_) (b:lmbuffer Int64.t r s l) : StBuf unit b /// An attribute to control reduction noextract irreducible let __reduce__ = unit /// Base types supported so far noextract type base_typ = | Bool | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 /// Argument types are base types and arrays thereof /// Or polymorphic arguments specified by "%a" noextract type arg = | Base of base_typ | Array of base_typ | Any /// Interpreting a `base_typ` as a type [@@__reduce__] noextract let base_typ_as_type (b:base_typ) : Type0 = match b with | Bool -> bool | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t /// `fragment`: A format string is parsed into a list of fragments of /// string literals and other arguments that need to be spliced in /// (interpolated) noextract type fragment = | Frag of string | Interpolate of arg noextract let fragments = list fragment /// `parse_format s`: /// Parses a list of characters in a format string into a list of fragments /// Or None, in case the format string is invalid [@@__reduce__] noextract inline_for_extraction let rec parse_format (s:list char) : Tot (option fragments) (decreases (L.length s)) = let add_dir (d:arg) (ods : option fragments) = match ods with | None -> None | Some ds -> Some (Interpolate d::ds) in let head_buffer (ods:option fragments) = match ods with | Some (Interpolate (Base t) :: rest) -> Some (Interpolate (Array t) :: rest) | _ -> None in let cons_frag (c:char) (ods:option fragments) = match ods with | Some (Frag s::rest) -> Some (Frag (string_of_list (c :: list_of_string s)) :: rest) | Some rest -> Some (Frag (string_of_list [c]) :: rest) | _ -> None in match s with | [] -> Some [] | ['%'] -> None // %a... polymorphic arguments and preceded by their printers | '%' :: 'a' :: s' -> add_dir Any (parse_format s') // %x... arrays of base types | '%' :: 'x' :: s' -> head_buffer (parse_format ('%' :: s')) // %u ... Unsigned integers | '%' :: 'u' :: s' -> begin match s' with | 'y' :: s'' -> add_dir (Base U8) (parse_format s'') | 's' :: s'' -> add_dir (Base U16) (parse_format s'') | 'l' :: s'' -> add_dir (Base U32) (parse_format s'') | 'L' :: s'' -> add_dir (Base U64) (parse_format s'') | _ -> None end | '%' :: c :: s' -> begin match c with | '%' -> cons_frag '%' (parse_format s') | 'b' -> add_dir (Base Bool) (parse_format s') | 'c' -> add_dir (Base Char) (parse_format s') | 's' -> add_dir (Base String) (parse_format s') | 'y' -> add_dir (Base I8) (parse_format s') | 'i' -> add_dir (Base I16) (parse_format s') | 'l' -> add_dir (Base I32) (parse_format s') | 'L' -> add_dir (Base I64) (parse_format s') | _ -> None end | c :: s' -> cons_frag c (parse_format s') /// `parse_format_string`: a wrapper around `parse_format` [@@__reduce__] noextract inline_for_extraction let parse_format_string (s:string) : option fragments = parse_format (list_of_string s) /// `lift a` lifts the type `a` to a higher universe noextract type lift (a:Type u#a) : Type u#(max a b) = | Lift : a -> lift a /// `done` is a `unit` in universe 1 noextract let done : lift unit = Lift u#0 u#1 () /// `arg_t`: interpreting an argument as a type /// (in universe 1) since it is polymorphic in the preorders of a buffer /// GM: Somehow, this needs to be a `let rec` (even if it not really recursive) /// or print_frags fails to verify. I don't know why; the generated /// VC and its encoding seem identical (modulo hash consing in the /// latter). [@@__reduce__] noextract let rec arg_t (a:arg) : Type u#1 = match a with | Base t -> lift (base_typ_as_type t) | Array t -> (l:UInt32.t & r:_ & s:_ & lmbuffer (base_typ_as_type t) r s l) | Any -> (a:Type0 & (a -> StTrivial unit) & a) /// `frag_t`: a fragment is either a string literal or a argument to be interpolated noextract let frag_t = either string (a:arg & arg_t a) /// `live_frags h l` is a liveness predicate on all the buffers in `l` [@@__reduce__] noextract let rec live_frags (h:_) (l:list frag_t) : prop = match l with | [] -> True | Inl _ :: rest -> live_frags h rest | Inr a :: rest -> (match a with | (| Base _, _ |) -> live_frags h rest | (| Any, _ |) -> live_frags h rest | (| Array _, (| _, _, _, b |) |) -> LB.live h b /\ live_frags h rest) /// `interpret_frags` interprets a list of fragments as a Low* function type /// Note `l` is the fragments in L-to-R order (i.e., parsing order) /// `acc` accumulates the fragment values in reverse order [@@__reduce__] noextract let rec interpret_frags (l:fragments) (acc:list frag_t) : Type u#1 = match l with | [] -> // Always a dummy argument at the end // Ensures that all cases of this match // have the same universe, i.e., u#1 lift u#0 u#1 unit -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) | Interpolate (Base t) :: args -> // Base types are simple: we just take one more argument x:base_typ_as_type t -> interpret_frags args (Inr (| Base t, Lift x |) :: acc) | Interpolate (Array t) :: args -> // Arrays are implicitly polymorphic in their preorders `r` and `s` // which is what forces us to be in universe 1 // Note, the length `l` is explicit l:UInt32.t -> #r:LB.srel (base_typ_as_type t) -> #s:LB.srel (base_typ_as_type t) -> b:lmbuffer (base_typ_as_type t) r s l -> interpret_frags args (Inr (| Array t, (| l, r, s, b |) |) :: acc) | Interpolate Any :: args -> #a:Type0 -> p:(a -> StTrivial unit) -> x:a -> interpret_frags args (Inr (| Any, (| a, p, x |) |) :: acc) | Frag s :: args -> // Literal fragments do not incur an additional argument // We just accumulate them and recur interpret_frags args (Inl s :: acc) /// `normal` A normalization marker with very specific steps enabled noextract unfold let normal (#a:Type) (x:a) : a = FStar.Pervasives.norm [iota; zeta; delta_attr [`%__reduce__; `%BigOps.__reduce__]; delta_only [`%Base?; `%Array?; `%Some?; `%Some?.v; `%list_of_string]; primops; simplify] x /// `coerce`: A utility to trigger extensional equality of types noextract let coerce (x:'a{'a == 'b}) : 'b = x /// `fragment_printer`: The type of a printer of fragments noextract let fragment_printer = (acc:list frag_t) -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) /// `print_frags`: Having accumulated all the pieces of a format /// string and the arguments to the printed (i.e., the `list frag_t`), /// this function does the actual work of printing them all using the /// primitive printers noextract inline_for_extraction let rec print_frags (acc:list frag_t) : Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) = match acc with | [] -> () | hd::tl -> print_frags tl; (match hd with | Inl s -> print_string s | Inr (| Base t, Lift value |) -> (match t with | Bool -> print_bool value | Char -> print_char value | String -> print_string value | U8 -> print_u8 value | U16 -> print_u16 value | U32 -> print_u32 value | U64 -> print_u64 value | I8 -> print_i8 value | I16 -> print_i16 value | I32 -> print_i32 value | I64 -> print_i64 value) | Inr (| Array t, (| l, r, s, value |) |) -> (match t with | Bool -> print_lmbuffer_bool l value | Char -> print_lmbuffer_char l value | String -> print_lmbuffer_string l value | U8 -> print_lmbuffer_u8 l value | U16 -> print_lmbuffer_u16 l value | U32 -> print_lmbuffer_u32 l value | U64 -> print_lmbuffer_u64 l value | I8 -> print_lmbuffer_i8 l value | I16 -> print_lmbuffer_i16 l value | I32 -> print_lmbuffer_i32 l value | I64 -> print_lmbuffer_i64 l value) | Inr (| Any, (| _, printer, value |) |) -> printer value) [@@__reduce__] let no_inst #a (#b:a -> Type) (f: (#x:a -> b x)) : unit -> #x:a -> b x = fun () -> f [@@__reduce__] let elim_unit_arrow #t (f:unit -> t) : t = f () // let test2 (f: (#a:Type -> a -> a)) : id_t 0 = test f () // let coerce #a (#b: (a -> Type)) ($f: (#x:a -> b x)) (t:Type{norm t == (#x:a -> b x)}) /// `aux frags acc`: This is the main workhorse which interprets a /// parsed format string (`frags`) as a variadic, stateful function [@@__reduce__] noextract inline_for_extraction let rec aux (frags:fragments) (acc:list frag_t) (fp: fragment_printer) : interpret_frags frags acc = match frags with | [] -> let f (l:lift u#0 u#1 unit) : Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) = fp acc in (f <: interpret_frags [] acc) | Frag s :: rest -> coerce (aux rest (Inl s :: acc) fp) | Interpolate (Base t) :: args -> let f (x:base_typ_as_type t) : interpret_frags args (Inr (| Base t, Lift x |) :: acc) = aux args (Inr (| Base t, Lift x |) :: acc) fp in f | Interpolate (Array t) :: rest -> let f : l:UInt32.t -> #r:LB.srel (base_typ_as_type t) -> #s:LB.srel (base_typ_as_type t) -> b:lmbuffer (base_typ_as_type t) r s l -> interpret_frags rest (Inr (| Array t, (| l, r, s, b |) |) :: acc) = fun l #r #s b -> aux rest (Inr (| Array t, (| l, r, s, b |) |) :: acc) fp in f <: interpret_frags (Interpolate (Array t) :: rest) acc | Interpolate Any :: rest -> let f : unit -> #a:Type -> p:(a -> StTrivial unit) -> x:a -> interpret_frags rest (Inr (| Any, (| a, p, x |) |) :: acc) = fun () #a p x -> aux rest (Inr (| Any, (| a, p, x |) |) :: acc) fp in elim_unit_arrow (no_inst (f ()) <: (unit -> interpret_frags (Interpolate Any :: rest) acc)) /// `format_string` : A valid format string is one that can be successfully parsed [@@__reduce__]
false
true
LowStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val format_string : Type0
[]
LowStar.Printf.format_string
{ "file_name": "ulib/LowStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Type0
{ "end_col": 74, "end_line": 445, "start_col": 20, "start_line": 445 }
Prims.Tot
val elim_unit_arrow (#t: _) (f: (unit -> t)) : t
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "LB" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let elim_unit_arrow #t (f:unit -> t) : t = f ()
val elim_unit_arrow (#t: _) (f: (unit -> t)) : t let elim_unit_arrow #t (f: (unit -> t)) : t =
false
null
false
f ()
{ "checked_file": "LowStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked", "FStar.BigOps.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Printf.fst" }
[ "total" ]
[ "Prims.unit" ]
[]
(* 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 LowStar.Printf /// This module provides imperative printing functions for several /// primitive Low* types, including /// -- booleans (%b) /// -- characters (%c) /// -- strings (%s) /// -- machine integers /// (UInt8.t as %uy, UInt16.t as %us, UInt32.t as %ul, and UInt64.t as %uL; /// Int8.t as %y, Int16.t as %i, Int32.t as %l , and Int64.t as %L) /// -- and arrays (aka buffers) of these base types formatted /// as %xN, where N is the format specifier for the array element type /// e.g., %xuy for buffers of UInt8.t /// The main function of this module is `printf` /// There are a few main differences relative to C printf /// -- The format specifiers are different (see above) /// /// -- For technical reasons explained below, an extra dummy /// argument `done` has to be provided at the end for the /// computation to have any effect. /// /// E.g., one must write /// `printf "%b %c" true 'c' done` /// rather than just /// `printf "%b %c" true 'c'` /// /// -- When printing arrays, two arguments must be passed; the /// length of the array fragment to be formatted and the array /// itself /// /// -- When extracted, rather than producing a C `printf` (which /// does not, e.g., support printing of dynamically sized /// arrays), our `printf` is specialized to a sequence of calls /// to primitive printers for each supported type /// /// Before diving into the technical details of how this module works, /// you might want to see a sample usage at the very end of this file. open FStar.Char open FStar.String open FStar.HyperStack.ST module L = FStar.List.Tot module LB = LowStar.Monotonic.Buffer /// `lmbuffer a r s l` is /// - a monotonic buffer of `a` /// - governed by preorders `r` and `s` /// - with length `l` let lmbuffer a r s l = b:LB.mbuffer a r s{ LB.len b == l } /// `StTrivial`: A effect abbreviation for a stateful computation /// with no precondition, and which does not change the state effect StTrivial (a:Type) = Stack a (requires fun h -> True) (ensures fun h0 _ h1 -> h0==h1) /// `StBuf a b`: A effect abbreviation for a stateful computation /// that may read `b` does not change the state effect StBuf (a:Type) #t #r #s #l (b:lmbuffer t r s l) = Stack a (requires fun h -> LB.live h b) (ensures (fun h0 _ h1 -> h0 == h1)) /// Primitive printers for all the types supported by this module assume val print_string: string -> StTrivial unit assume val print_char : char -> StTrivial unit assume val print_u8 : UInt8.t -> StTrivial unit assume val print_u16 : UInt16.t -> StTrivial unit assume val print_u32 : UInt32.t -> StTrivial unit assume val print_u64 : UInt64.t -> StTrivial unit assume val print_i8 : Int8.t -> StTrivial unit assume val print_i16 : Int16.t -> StTrivial unit assume val print_i32 : Int32.t -> StTrivial unit assume val print_i64 : Int64.t -> StTrivial unit assume val print_bool : bool -> StTrivial unit assume val print_lmbuffer_bool (l:_) (#r:_) (#s:_) (b:lmbuffer bool r s l) : StBuf unit b assume val print_lmbuffer_char (l:_) (#r:_) (#s:_) (b:lmbuffer char r s l) : StBuf unit b assume val print_lmbuffer_string (l:_) (#r:_) (#s:_) (b:lmbuffer string r s l) : StBuf unit b assume val print_lmbuffer_u8 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt8.t r s l) : StBuf unit b assume val print_lmbuffer_u16 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt16.t r s l) : StBuf unit b assume val print_lmbuffer_u32 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt32.t r s l) : StBuf unit b assume val print_lmbuffer_u64 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt64.t r s l) : StBuf unit b assume val print_lmbuffer_i8 (l:_) (#r:_) (#s:_) (b:lmbuffer Int8.t r s l) : StBuf unit b assume val print_lmbuffer_i16 (l:_) (#r:_) (#s:_) (b:lmbuffer Int16.t r s l) : StBuf unit b assume val print_lmbuffer_i32 (l:_) (#r:_) (#s:_) (b:lmbuffer Int32.t r s l) : StBuf unit b assume val print_lmbuffer_i64 (l:_) (#r:_) (#s:_) (b:lmbuffer Int64.t r s l) : StBuf unit b /// An attribute to control reduction noextract irreducible let __reduce__ = unit /// Base types supported so far noextract type base_typ = | Bool | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 /// Argument types are base types and arrays thereof /// Or polymorphic arguments specified by "%a" noextract type arg = | Base of base_typ | Array of base_typ | Any /// Interpreting a `base_typ` as a type [@@__reduce__] noextract let base_typ_as_type (b:base_typ) : Type0 = match b with | Bool -> bool | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t /// `fragment`: A format string is parsed into a list of fragments of /// string literals and other arguments that need to be spliced in /// (interpolated) noextract type fragment = | Frag of string | Interpolate of arg noextract let fragments = list fragment /// `parse_format s`: /// Parses a list of characters in a format string into a list of fragments /// Or None, in case the format string is invalid [@@__reduce__] noextract inline_for_extraction let rec parse_format (s:list char) : Tot (option fragments) (decreases (L.length s)) = let add_dir (d:arg) (ods : option fragments) = match ods with | None -> None | Some ds -> Some (Interpolate d::ds) in let head_buffer (ods:option fragments) = match ods with | Some (Interpolate (Base t) :: rest) -> Some (Interpolate (Array t) :: rest) | _ -> None in let cons_frag (c:char) (ods:option fragments) = match ods with | Some (Frag s::rest) -> Some (Frag (string_of_list (c :: list_of_string s)) :: rest) | Some rest -> Some (Frag (string_of_list [c]) :: rest) | _ -> None in match s with | [] -> Some [] | ['%'] -> None // %a... polymorphic arguments and preceded by their printers | '%' :: 'a' :: s' -> add_dir Any (parse_format s') // %x... arrays of base types | '%' :: 'x' :: s' -> head_buffer (parse_format ('%' :: s')) // %u ... Unsigned integers | '%' :: 'u' :: s' -> begin match s' with | 'y' :: s'' -> add_dir (Base U8) (parse_format s'') | 's' :: s'' -> add_dir (Base U16) (parse_format s'') | 'l' :: s'' -> add_dir (Base U32) (parse_format s'') | 'L' :: s'' -> add_dir (Base U64) (parse_format s'') | _ -> None end | '%' :: c :: s' -> begin match c with | '%' -> cons_frag '%' (parse_format s') | 'b' -> add_dir (Base Bool) (parse_format s') | 'c' -> add_dir (Base Char) (parse_format s') | 's' -> add_dir (Base String) (parse_format s') | 'y' -> add_dir (Base I8) (parse_format s') | 'i' -> add_dir (Base I16) (parse_format s') | 'l' -> add_dir (Base I32) (parse_format s') | 'L' -> add_dir (Base I64) (parse_format s') | _ -> None end | c :: s' -> cons_frag c (parse_format s') /// `parse_format_string`: a wrapper around `parse_format` [@@__reduce__] noextract inline_for_extraction let parse_format_string (s:string) : option fragments = parse_format (list_of_string s) /// `lift a` lifts the type `a` to a higher universe noextract type lift (a:Type u#a) : Type u#(max a b) = | Lift : a -> lift a /// `done` is a `unit` in universe 1 noextract let done : lift unit = Lift u#0 u#1 () /// `arg_t`: interpreting an argument as a type /// (in universe 1) since it is polymorphic in the preorders of a buffer /// GM: Somehow, this needs to be a `let rec` (even if it not really recursive) /// or print_frags fails to verify. I don't know why; the generated /// VC and its encoding seem identical (modulo hash consing in the /// latter). [@@__reduce__] noextract let rec arg_t (a:arg) : Type u#1 = match a with | Base t -> lift (base_typ_as_type t) | Array t -> (l:UInt32.t & r:_ & s:_ & lmbuffer (base_typ_as_type t) r s l) | Any -> (a:Type0 & (a -> StTrivial unit) & a) /// `frag_t`: a fragment is either a string literal or a argument to be interpolated noextract let frag_t = either string (a:arg & arg_t a) /// `live_frags h l` is a liveness predicate on all the buffers in `l` [@@__reduce__] noextract let rec live_frags (h:_) (l:list frag_t) : prop = match l with | [] -> True | Inl _ :: rest -> live_frags h rest | Inr a :: rest -> (match a with | (| Base _, _ |) -> live_frags h rest | (| Any, _ |) -> live_frags h rest | (| Array _, (| _, _, _, b |) |) -> LB.live h b /\ live_frags h rest) /// `interpret_frags` interprets a list of fragments as a Low* function type /// Note `l` is the fragments in L-to-R order (i.e., parsing order) /// `acc` accumulates the fragment values in reverse order [@@__reduce__] noextract let rec interpret_frags (l:fragments) (acc:list frag_t) : Type u#1 = match l with | [] -> // Always a dummy argument at the end // Ensures that all cases of this match // have the same universe, i.e., u#1 lift u#0 u#1 unit -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) | Interpolate (Base t) :: args -> // Base types are simple: we just take one more argument x:base_typ_as_type t -> interpret_frags args (Inr (| Base t, Lift x |) :: acc) | Interpolate (Array t) :: args -> // Arrays are implicitly polymorphic in their preorders `r` and `s` // which is what forces us to be in universe 1 // Note, the length `l` is explicit l:UInt32.t -> #r:LB.srel (base_typ_as_type t) -> #s:LB.srel (base_typ_as_type t) -> b:lmbuffer (base_typ_as_type t) r s l -> interpret_frags args (Inr (| Array t, (| l, r, s, b |) |) :: acc) | Interpolate Any :: args -> #a:Type0 -> p:(a -> StTrivial unit) -> x:a -> interpret_frags args (Inr (| Any, (| a, p, x |) |) :: acc) | Frag s :: args -> // Literal fragments do not incur an additional argument // We just accumulate them and recur interpret_frags args (Inl s :: acc) /// `normal` A normalization marker with very specific steps enabled noextract unfold let normal (#a:Type) (x:a) : a = FStar.Pervasives.norm [iota; zeta; delta_attr [`%__reduce__; `%BigOps.__reduce__]; delta_only [`%Base?; `%Array?; `%Some?; `%Some?.v; `%list_of_string]; primops; simplify] x /// `coerce`: A utility to trigger extensional equality of types noextract let coerce (x:'a{'a == 'b}) : 'b = x /// `fragment_printer`: The type of a printer of fragments noextract let fragment_printer = (acc:list frag_t) -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) /// `print_frags`: Having accumulated all the pieces of a format /// string and the arguments to the printed (i.e., the `list frag_t`), /// this function does the actual work of printing them all using the /// primitive printers noextract inline_for_extraction let rec print_frags (acc:list frag_t) : Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) = match acc with | [] -> () | hd::tl -> print_frags tl; (match hd with | Inl s -> print_string s | Inr (| Base t, Lift value |) -> (match t with | Bool -> print_bool value | Char -> print_char value | String -> print_string value | U8 -> print_u8 value | U16 -> print_u16 value | U32 -> print_u32 value | U64 -> print_u64 value | I8 -> print_i8 value | I16 -> print_i16 value | I32 -> print_i32 value | I64 -> print_i64 value) | Inr (| Array t, (| l, r, s, value |) |) -> (match t with | Bool -> print_lmbuffer_bool l value | Char -> print_lmbuffer_char l value | String -> print_lmbuffer_string l value | U8 -> print_lmbuffer_u8 l value | U16 -> print_lmbuffer_u16 l value | U32 -> print_lmbuffer_u32 l value | U64 -> print_lmbuffer_u64 l value | I8 -> print_lmbuffer_i8 l value | I16 -> print_lmbuffer_i16 l value | I32 -> print_lmbuffer_i32 l value | I64 -> print_lmbuffer_i64 l value) | Inr (| Any, (| _, printer, value |) |) -> printer value) [@@__reduce__] let no_inst #a (#b:a -> Type) (f: (#x:a -> b x)) : unit -> #x:a -> b x = fun () -> f
false
false
LowStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val elim_unit_arrow (#t: _) (f: (unit -> t)) : t
[]
LowStar.Printf.elim_unit_arrow
{ "file_name": "ulib/LowStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: (_: Prims.unit -> t) -> t
{ "end_col": 47, "end_line": 391, "start_col": 43, "start_line": 391 }
Prims.Tot
val parse_format_string (s: string) : option fragments
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "LB" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse_format_string (s:string) : option fragments = parse_format (list_of_string s)
val parse_format_string (s: string) : option fragments let parse_format_string (s: string) : option fragments =
false
null
false
parse_format (list_of_string s)
{ "checked_file": "LowStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked", "FStar.BigOps.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Printf.fst" }
[ "total" ]
[ "Prims.string", "LowStar.Printf.parse_format", "FStar.String.list_of_string", "FStar.Pervasives.Native.option", "LowStar.Printf.fragments" ]
[]
(* 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 LowStar.Printf /// This module provides imperative printing functions for several /// primitive Low* types, including /// -- booleans (%b) /// -- characters (%c) /// -- strings (%s) /// -- machine integers /// (UInt8.t as %uy, UInt16.t as %us, UInt32.t as %ul, and UInt64.t as %uL; /// Int8.t as %y, Int16.t as %i, Int32.t as %l , and Int64.t as %L) /// -- and arrays (aka buffers) of these base types formatted /// as %xN, where N is the format specifier for the array element type /// e.g., %xuy for buffers of UInt8.t /// The main function of this module is `printf` /// There are a few main differences relative to C printf /// -- The format specifiers are different (see above) /// /// -- For technical reasons explained below, an extra dummy /// argument `done` has to be provided at the end for the /// computation to have any effect. /// /// E.g., one must write /// `printf "%b %c" true 'c' done` /// rather than just /// `printf "%b %c" true 'c'` /// /// -- When printing arrays, two arguments must be passed; the /// length of the array fragment to be formatted and the array /// itself /// /// -- When extracted, rather than producing a C `printf` (which /// does not, e.g., support printing of dynamically sized /// arrays), our `printf` is specialized to a sequence of calls /// to primitive printers for each supported type /// /// Before diving into the technical details of how this module works, /// you might want to see a sample usage at the very end of this file. open FStar.Char open FStar.String open FStar.HyperStack.ST module L = FStar.List.Tot module LB = LowStar.Monotonic.Buffer /// `lmbuffer a r s l` is /// - a monotonic buffer of `a` /// - governed by preorders `r` and `s` /// - with length `l` let lmbuffer a r s l = b:LB.mbuffer a r s{ LB.len b == l } /// `StTrivial`: A effect abbreviation for a stateful computation /// with no precondition, and which does not change the state effect StTrivial (a:Type) = Stack a (requires fun h -> True) (ensures fun h0 _ h1 -> h0==h1) /// `StBuf a b`: A effect abbreviation for a stateful computation /// that may read `b` does not change the state effect StBuf (a:Type) #t #r #s #l (b:lmbuffer t r s l) = Stack a (requires fun h -> LB.live h b) (ensures (fun h0 _ h1 -> h0 == h1)) /// Primitive printers for all the types supported by this module assume val print_string: string -> StTrivial unit assume val print_char : char -> StTrivial unit assume val print_u8 : UInt8.t -> StTrivial unit assume val print_u16 : UInt16.t -> StTrivial unit assume val print_u32 : UInt32.t -> StTrivial unit assume val print_u64 : UInt64.t -> StTrivial unit assume val print_i8 : Int8.t -> StTrivial unit assume val print_i16 : Int16.t -> StTrivial unit assume val print_i32 : Int32.t -> StTrivial unit assume val print_i64 : Int64.t -> StTrivial unit assume val print_bool : bool -> StTrivial unit assume val print_lmbuffer_bool (l:_) (#r:_) (#s:_) (b:lmbuffer bool r s l) : StBuf unit b assume val print_lmbuffer_char (l:_) (#r:_) (#s:_) (b:lmbuffer char r s l) : StBuf unit b assume val print_lmbuffer_string (l:_) (#r:_) (#s:_) (b:lmbuffer string r s l) : StBuf unit b assume val print_lmbuffer_u8 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt8.t r s l) : StBuf unit b assume val print_lmbuffer_u16 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt16.t r s l) : StBuf unit b assume val print_lmbuffer_u32 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt32.t r s l) : StBuf unit b assume val print_lmbuffer_u64 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt64.t r s l) : StBuf unit b assume val print_lmbuffer_i8 (l:_) (#r:_) (#s:_) (b:lmbuffer Int8.t r s l) : StBuf unit b assume val print_lmbuffer_i16 (l:_) (#r:_) (#s:_) (b:lmbuffer Int16.t r s l) : StBuf unit b assume val print_lmbuffer_i32 (l:_) (#r:_) (#s:_) (b:lmbuffer Int32.t r s l) : StBuf unit b assume val print_lmbuffer_i64 (l:_) (#r:_) (#s:_) (b:lmbuffer Int64.t r s l) : StBuf unit b /// An attribute to control reduction noextract irreducible let __reduce__ = unit /// Base types supported so far noextract type base_typ = | Bool | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 /// Argument types are base types and arrays thereof /// Or polymorphic arguments specified by "%a" noextract type arg = | Base of base_typ | Array of base_typ | Any /// Interpreting a `base_typ` as a type [@@__reduce__] noextract let base_typ_as_type (b:base_typ) : Type0 = match b with | Bool -> bool | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t /// `fragment`: A format string is parsed into a list of fragments of /// string literals and other arguments that need to be spliced in /// (interpolated) noextract type fragment = | Frag of string | Interpolate of arg noextract let fragments = list fragment /// `parse_format s`: /// Parses a list of characters in a format string into a list of fragments /// Or None, in case the format string is invalid [@@__reduce__] noextract inline_for_extraction let rec parse_format (s:list char) : Tot (option fragments) (decreases (L.length s)) = let add_dir (d:arg) (ods : option fragments) = match ods with | None -> None | Some ds -> Some (Interpolate d::ds) in let head_buffer (ods:option fragments) = match ods with | Some (Interpolate (Base t) :: rest) -> Some (Interpolate (Array t) :: rest) | _ -> None in let cons_frag (c:char) (ods:option fragments) = match ods with | Some (Frag s::rest) -> Some (Frag (string_of_list (c :: list_of_string s)) :: rest) | Some rest -> Some (Frag (string_of_list [c]) :: rest) | _ -> None in match s with | [] -> Some [] | ['%'] -> None // %a... polymorphic arguments and preceded by their printers | '%' :: 'a' :: s' -> add_dir Any (parse_format s') // %x... arrays of base types | '%' :: 'x' :: s' -> head_buffer (parse_format ('%' :: s')) // %u ... Unsigned integers | '%' :: 'u' :: s' -> begin match s' with | 'y' :: s'' -> add_dir (Base U8) (parse_format s'') | 's' :: s'' -> add_dir (Base U16) (parse_format s'') | 'l' :: s'' -> add_dir (Base U32) (parse_format s'') | 'L' :: s'' -> add_dir (Base U64) (parse_format s'') | _ -> None end | '%' :: c :: s' -> begin match c with | '%' -> cons_frag '%' (parse_format s') | 'b' -> add_dir (Base Bool) (parse_format s') | 'c' -> add_dir (Base Char) (parse_format s') | 's' -> add_dir (Base String) (parse_format s') | 'y' -> add_dir (Base I8) (parse_format s') | 'i' -> add_dir (Base I16) (parse_format s') | 'l' -> add_dir (Base I32) (parse_format s') | 'L' -> add_dir (Base I64) (parse_format s') | _ -> None end | c :: s' -> cons_frag c (parse_format s') /// `parse_format_string`: a wrapper around `parse_format` [@@__reduce__] noextract inline_for_extraction let parse_format_string (s:string)
false
true
LowStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse_format_string (s: string) : option fragments
[]
LowStar.Printf.parse_format_string
{ "file_name": "ulib/LowStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s: Prims.string -> FStar.Pervasives.Native.option LowStar.Printf.fragments
{ "end_col": 35, "end_line": 234, "start_col": 4, "start_line": 234 }
Prims.Tot
val no_inst: #a: _ -> #b: (a -> Type) -> f: (#x: a -> b x) -> unit -> #x: a -> b x
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "LB" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let no_inst #a (#b:a -> Type) (f: (#x:a -> b x)) : unit -> #x:a -> b x = fun () -> f
val no_inst: #a: _ -> #b: (a -> Type) -> f: (#x: a -> b x) -> unit -> #x: a -> b x let no_inst #a (#b: (a -> Type)) (f: (#x: a -> b x)) : unit -> #x: a -> b x =
false
null
false
fun () -> f
{ "checked_file": "LowStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked", "FStar.BigOps.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Printf.fst" }
[ "total" ]
[ "Prims.unit" ]
[]
(* 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 LowStar.Printf /// This module provides imperative printing functions for several /// primitive Low* types, including /// -- booleans (%b) /// -- characters (%c) /// -- strings (%s) /// -- machine integers /// (UInt8.t as %uy, UInt16.t as %us, UInt32.t as %ul, and UInt64.t as %uL; /// Int8.t as %y, Int16.t as %i, Int32.t as %l , and Int64.t as %L) /// -- and arrays (aka buffers) of these base types formatted /// as %xN, where N is the format specifier for the array element type /// e.g., %xuy for buffers of UInt8.t /// The main function of this module is `printf` /// There are a few main differences relative to C printf /// -- The format specifiers are different (see above) /// /// -- For technical reasons explained below, an extra dummy /// argument `done` has to be provided at the end for the /// computation to have any effect. /// /// E.g., one must write /// `printf "%b %c" true 'c' done` /// rather than just /// `printf "%b %c" true 'c'` /// /// -- When printing arrays, two arguments must be passed; the /// length of the array fragment to be formatted and the array /// itself /// /// -- When extracted, rather than producing a C `printf` (which /// does not, e.g., support printing of dynamically sized /// arrays), our `printf` is specialized to a sequence of calls /// to primitive printers for each supported type /// /// Before diving into the technical details of how this module works, /// you might want to see a sample usage at the very end of this file. open FStar.Char open FStar.String open FStar.HyperStack.ST module L = FStar.List.Tot module LB = LowStar.Monotonic.Buffer /// `lmbuffer a r s l` is /// - a monotonic buffer of `a` /// - governed by preorders `r` and `s` /// - with length `l` let lmbuffer a r s l = b:LB.mbuffer a r s{ LB.len b == l } /// `StTrivial`: A effect abbreviation for a stateful computation /// with no precondition, and which does not change the state effect StTrivial (a:Type) = Stack a (requires fun h -> True) (ensures fun h0 _ h1 -> h0==h1) /// `StBuf a b`: A effect abbreviation for a stateful computation /// that may read `b` does not change the state effect StBuf (a:Type) #t #r #s #l (b:lmbuffer t r s l) = Stack a (requires fun h -> LB.live h b) (ensures (fun h0 _ h1 -> h0 == h1)) /// Primitive printers for all the types supported by this module assume val print_string: string -> StTrivial unit assume val print_char : char -> StTrivial unit assume val print_u8 : UInt8.t -> StTrivial unit assume val print_u16 : UInt16.t -> StTrivial unit assume val print_u32 : UInt32.t -> StTrivial unit assume val print_u64 : UInt64.t -> StTrivial unit assume val print_i8 : Int8.t -> StTrivial unit assume val print_i16 : Int16.t -> StTrivial unit assume val print_i32 : Int32.t -> StTrivial unit assume val print_i64 : Int64.t -> StTrivial unit assume val print_bool : bool -> StTrivial unit assume val print_lmbuffer_bool (l:_) (#r:_) (#s:_) (b:lmbuffer bool r s l) : StBuf unit b assume val print_lmbuffer_char (l:_) (#r:_) (#s:_) (b:lmbuffer char r s l) : StBuf unit b assume val print_lmbuffer_string (l:_) (#r:_) (#s:_) (b:lmbuffer string r s l) : StBuf unit b assume val print_lmbuffer_u8 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt8.t r s l) : StBuf unit b assume val print_lmbuffer_u16 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt16.t r s l) : StBuf unit b assume val print_lmbuffer_u32 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt32.t r s l) : StBuf unit b assume val print_lmbuffer_u64 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt64.t r s l) : StBuf unit b assume val print_lmbuffer_i8 (l:_) (#r:_) (#s:_) (b:lmbuffer Int8.t r s l) : StBuf unit b assume val print_lmbuffer_i16 (l:_) (#r:_) (#s:_) (b:lmbuffer Int16.t r s l) : StBuf unit b assume val print_lmbuffer_i32 (l:_) (#r:_) (#s:_) (b:lmbuffer Int32.t r s l) : StBuf unit b assume val print_lmbuffer_i64 (l:_) (#r:_) (#s:_) (b:lmbuffer Int64.t r s l) : StBuf unit b /// An attribute to control reduction noextract irreducible let __reduce__ = unit /// Base types supported so far noextract type base_typ = | Bool | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 /// Argument types are base types and arrays thereof /// Or polymorphic arguments specified by "%a" noextract type arg = | Base of base_typ | Array of base_typ | Any /// Interpreting a `base_typ` as a type [@@__reduce__] noextract let base_typ_as_type (b:base_typ) : Type0 = match b with | Bool -> bool | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t /// `fragment`: A format string is parsed into a list of fragments of /// string literals and other arguments that need to be spliced in /// (interpolated) noextract type fragment = | Frag of string | Interpolate of arg noextract let fragments = list fragment /// `parse_format s`: /// Parses a list of characters in a format string into a list of fragments /// Or None, in case the format string is invalid [@@__reduce__] noextract inline_for_extraction let rec parse_format (s:list char) : Tot (option fragments) (decreases (L.length s)) = let add_dir (d:arg) (ods : option fragments) = match ods with | None -> None | Some ds -> Some (Interpolate d::ds) in let head_buffer (ods:option fragments) = match ods with | Some (Interpolate (Base t) :: rest) -> Some (Interpolate (Array t) :: rest) | _ -> None in let cons_frag (c:char) (ods:option fragments) = match ods with | Some (Frag s::rest) -> Some (Frag (string_of_list (c :: list_of_string s)) :: rest) | Some rest -> Some (Frag (string_of_list [c]) :: rest) | _ -> None in match s with | [] -> Some [] | ['%'] -> None // %a... polymorphic arguments and preceded by their printers | '%' :: 'a' :: s' -> add_dir Any (parse_format s') // %x... arrays of base types | '%' :: 'x' :: s' -> head_buffer (parse_format ('%' :: s')) // %u ... Unsigned integers | '%' :: 'u' :: s' -> begin match s' with | 'y' :: s'' -> add_dir (Base U8) (parse_format s'') | 's' :: s'' -> add_dir (Base U16) (parse_format s'') | 'l' :: s'' -> add_dir (Base U32) (parse_format s'') | 'L' :: s'' -> add_dir (Base U64) (parse_format s'') | _ -> None end | '%' :: c :: s' -> begin match c with | '%' -> cons_frag '%' (parse_format s') | 'b' -> add_dir (Base Bool) (parse_format s') | 'c' -> add_dir (Base Char) (parse_format s') | 's' -> add_dir (Base String) (parse_format s') | 'y' -> add_dir (Base I8) (parse_format s') | 'i' -> add_dir (Base I16) (parse_format s') | 'l' -> add_dir (Base I32) (parse_format s') | 'L' -> add_dir (Base I64) (parse_format s') | _ -> None end | c :: s' -> cons_frag c (parse_format s') /// `parse_format_string`: a wrapper around `parse_format` [@@__reduce__] noextract inline_for_extraction let parse_format_string (s:string) : option fragments = parse_format (list_of_string s) /// `lift a` lifts the type `a` to a higher universe noextract type lift (a:Type u#a) : Type u#(max a b) = | Lift : a -> lift a /// `done` is a `unit` in universe 1 noextract let done : lift unit = Lift u#0 u#1 () /// `arg_t`: interpreting an argument as a type /// (in universe 1) since it is polymorphic in the preorders of a buffer /// GM: Somehow, this needs to be a `let rec` (even if it not really recursive) /// or print_frags fails to verify. I don't know why; the generated /// VC and its encoding seem identical (modulo hash consing in the /// latter). [@@__reduce__] noextract let rec arg_t (a:arg) : Type u#1 = match a with | Base t -> lift (base_typ_as_type t) | Array t -> (l:UInt32.t & r:_ & s:_ & lmbuffer (base_typ_as_type t) r s l) | Any -> (a:Type0 & (a -> StTrivial unit) & a) /// `frag_t`: a fragment is either a string literal or a argument to be interpolated noextract let frag_t = either string (a:arg & arg_t a) /// `live_frags h l` is a liveness predicate on all the buffers in `l` [@@__reduce__] noextract let rec live_frags (h:_) (l:list frag_t) : prop = match l with | [] -> True | Inl _ :: rest -> live_frags h rest | Inr a :: rest -> (match a with | (| Base _, _ |) -> live_frags h rest | (| Any, _ |) -> live_frags h rest | (| Array _, (| _, _, _, b |) |) -> LB.live h b /\ live_frags h rest) /// `interpret_frags` interprets a list of fragments as a Low* function type /// Note `l` is the fragments in L-to-R order (i.e., parsing order) /// `acc` accumulates the fragment values in reverse order [@@__reduce__] noextract let rec interpret_frags (l:fragments) (acc:list frag_t) : Type u#1 = match l with | [] -> // Always a dummy argument at the end // Ensures that all cases of this match // have the same universe, i.e., u#1 lift u#0 u#1 unit -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) | Interpolate (Base t) :: args -> // Base types are simple: we just take one more argument x:base_typ_as_type t -> interpret_frags args (Inr (| Base t, Lift x |) :: acc) | Interpolate (Array t) :: args -> // Arrays are implicitly polymorphic in their preorders `r` and `s` // which is what forces us to be in universe 1 // Note, the length `l` is explicit l:UInt32.t -> #r:LB.srel (base_typ_as_type t) -> #s:LB.srel (base_typ_as_type t) -> b:lmbuffer (base_typ_as_type t) r s l -> interpret_frags args (Inr (| Array t, (| l, r, s, b |) |) :: acc) | Interpolate Any :: args -> #a:Type0 -> p:(a -> StTrivial unit) -> x:a -> interpret_frags args (Inr (| Any, (| a, p, x |) |) :: acc) | Frag s :: args -> // Literal fragments do not incur an additional argument // We just accumulate them and recur interpret_frags args (Inl s :: acc) /// `normal` A normalization marker with very specific steps enabled noextract unfold let normal (#a:Type) (x:a) : a = FStar.Pervasives.norm [iota; zeta; delta_attr [`%__reduce__; `%BigOps.__reduce__]; delta_only [`%Base?; `%Array?; `%Some?; `%Some?.v; `%list_of_string]; primops; simplify] x /// `coerce`: A utility to trigger extensional equality of types noextract let coerce (x:'a{'a == 'b}) : 'b = x /// `fragment_printer`: The type of a printer of fragments noextract let fragment_printer = (acc:list frag_t) -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) /// `print_frags`: Having accumulated all the pieces of a format /// string and the arguments to the printed (i.e., the `list frag_t`), /// this function does the actual work of printing them all using the /// primitive printers noextract inline_for_extraction let rec print_frags (acc:list frag_t) : Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) = match acc with | [] -> () | hd::tl -> print_frags tl; (match hd with | Inl s -> print_string s | Inr (| Base t, Lift value |) -> (match t with | Bool -> print_bool value | Char -> print_char value | String -> print_string value | U8 -> print_u8 value | U16 -> print_u16 value | U32 -> print_u32 value | U64 -> print_u64 value | I8 -> print_i8 value | I16 -> print_i16 value | I32 -> print_i32 value | I64 -> print_i64 value) | Inr (| Array t, (| l, r, s, value |) |) -> (match t with | Bool -> print_lmbuffer_bool l value | Char -> print_lmbuffer_char l value | String -> print_lmbuffer_string l value | U8 -> print_lmbuffer_u8 l value | U16 -> print_lmbuffer_u16 l value | U32 -> print_lmbuffer_u32 l value | U64 -> print_lmbuffer_u64 l value | I8 -> print_lmbuffer_i8 l value | I16 -> print_lmbuffer_i16 l value | I32 -> print_lmbuffer_i32 l value | I64 -> print_lmbuffer_i64 l value) | Inr (| Any, (| _, printer, value |) |) -> printer value)
false
false
LowStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val no_inst: #a: _ -> #b: (a -> Type) -> f: (#x: a -> b x) -> unit -> #x: a -> b x
[]
LowStar.Printf.no_inst
{ "file_name": "ulib/LowStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: b x -> _: Prims.unit -> b x
{ "end_col": 84, "end_line": 389, "start_col": 73, "start_line": 389 }
Prims.Tot
val printf : s:normal format_string -> normal (interpret_format_string s)
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "LB" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let printf = intro_normal_f #format_string interpret_format_string printf'
val printf : s:normal format_string -> normal (interpret_format_string s) let printf =
false
null
false
intro_normal_f #format_string interpret_format_string printf'
{ "checked_file": "LowStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked", "FStar.BigOps.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Printf.fst" }
[ "total" ]
[ "LowStar.Printf.intro_normal_f", "LowStar.Printf.format_string", "LowStar.Printf.interpret_format_string", "LowStar.Printf.printf'" ]
[]
(* 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 LowStar.Printf /// This module provides imperative printing functions for several /// primitive Low* types, including /// -- booleans (%b) /// -- characters (%c) /// -- strings (%s) /// -- machine integers /// (UInt8.t as %uy, UInt16.t as %us, UInt32.t as %ul, and UInt64.t as %uL; /// Int8.t as %y, Int16.t as %i, Int32.t as %l , and Int64.t as %L) /// -- and arrays (aka buffers) of these base types formatted /// as %xN, where N is the format specifier for the array element type /// e.g., %xuy for buffers of UInt8.t /// The main function of this module is `printf` /// There are a few main differences relative to C printf /// -- The format specifiers are different (see above) /// /// -- For technical reasons explained below, an extra dummy /// argument `done` has to be provided at the end for the /// computation to have any effect. /// /// E.g., one must write /// `printf "%b %c" true 'c' done` /// rather than just /// `printf "%b %c" true 'c'` /// /// -- When printing arrays, two arguments must be passed; the /// length of the array fragment to be formatted and the array /// itself /// /// -- When extracted, rather than producing a C `printf` (which /// does not, e.g., support printing of dynamically sized /// arrays), our `printf` is specialized to a sequence of calls /// to primitive printers for each supported type /// /// Before diving into the technical details of how this module works, /// you might want to see a sample usage at the very end of this file. open FStar.Char open FStar.String open FStar.HyperStack.ST module L = FStar.List.Tot module LB = LowStar.Monotonic.Buffer /// `lmbuffer a r s l` is /// - a monotonic buffer of `a` /// - governed by preorders `r` and `s` /// - with length `l` let lmbuffer a r s l = b:LB.mbuffer a r s{ LB.len b == l } /// `StTrivial`: A effect abbreviation for a stateful computation /// with no precondition, and which does not change the state effect StTrivial (a:Type) = Stack a (requires fun h -> True) (ensures fun h0 _ h1 -> h0==h1) /// `StBuf a b`: A effect abbreviation for a stateful computation /// that may read `b` does not change the state effect StBuf (a:Type) #t #r #s #l (b:lmbuffer t r s l) = Stack a (requires fun h -> LB.live h b) (ensures (fun h0 _ h1 -> h0 == h1)) /// Primitive printers for all the types supported by this module assume val print_string: string -> StTrivial unit assume val print_char : char -> StTrivial unit assume val print_u8 : UInt8.t -> StTrivial unit assume val print_u16 : UInt16.t -> StTrivial unit assume val print_u32 : UInt32.t -> StTrivial unit assume val print_u64 : UInt64.t -> StTrivial unit assume val print_i8 : Int8.t -> StTrivial unit assume val print_i16 : Int16.t -> StTrivial unit assume val print_i32 : Int32.t -> StTrivial unit assume val print_i64 : Int64.t -> StTrivial unit assume val print_bool : bool -> StTrivial unit assume val print_lmbuffer_bool (l:_) (#r:_) (#s:_) (b:lmbuffer bool r s l) : StBuf unit b assume val print_lmbuffer_char (l:_) (#r:_) (#s:_) (b:lmbuffer char r s l) : StBuf unit b assume val print_lmbuffer_string (l:_) (#r:_) (#s:_) (b:lmbuffer string r s l) : StBuf unit b assume val print_lmbuffer_u8 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt8.t r s l) : StBuf unit b assume val print_lmbuffer_u16 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt16.t r s l) : StBuf unit b assume val print_lmbuffer_u32 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt32.t r s l) : StBuf unit b assume val print_lmbuffer_u64 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt64.t r s l) : StBuf unit b assume val print_lmbuffer_i8 (l:_) (#r:_) (#s:_) (b:lmbuffer Int8.t r s l) : StBuf unit b assume val print_lmbuffer_i16 (l:_) (#r:_) (#s:_) (b:lmbuffer Int16.t r s l) : StBuf unit b assume val print_lmbuffer_i32 (l:_) (#r:_) (#s:_) (b:lmbuffer Int32.t r s l) : StBuf unit b assume val print_lmbuffer_i64 (l:_) (#r:_) (#s:_) (b:lmbuffer Int64.t r s l) : StBuf unit b /// An attribute to control reduction noextract irreducible let __reduce__ = unit /// Base types supported so far noextract type base_typ = | Bool | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 /// Argument types are base types and arrays thereof /// Or polymorphic arguments specified by "%a" noextract type arg = | Base of base_typ | Array of base_typ | Any /// Interpreting a `base_typ` as a type [@@__reduce__] noextract let base_typ_as_type (b:base_typ) : Type0 = match b with | Bool -> bool | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t /// `fragment`: A format string is parsed into a list of fragments of /// string literals and other arguments that need to be spliced in /// (interpolated) noextract type fragment = | Frag of string | Interpolate of arg noextract let fragments = list fragment /// `parse_format s`: /// Parses a list of characters in a format string into a list of fragments /// Or None, in case the format string is invalid [@@__reduce__] noextract inline_for_extraction let rec parse_format (s:list char) : Tot (option fragments) (decreases (L.length s)) = let add_dir (d:arg) (ods : option fragments) = match ods with | None -> None | Some ds -> Some (Interpolate d::ds) in let head_buffer (ods:option fragments) = match ods with | Some (Interpolate (Base t) :: rest) -> Some (Interpolate (Array t) :: rest) | _ -> None in let cons_frag (c:char) (ods:option fragments) = match ods with | Some (Frag s::rest) -> Some (Frag (string_of_list (c :: list_of_string s)) :: rest) | Some rest -> Some (Frag (string_of_list [c]) :: rest) | _ -> None in match s with | [] -> Some [] | ['%'] -> None // %a... polymorphic arguments and preceded by their printers | '%' :: 'a' :: s' -> add_dir Any (parse_format s') // %x... arrays of base types | '%' :: 'x' :: s' -> head_buffer (parse_format ('%' :: s')) // %u ... Unsigned integers | '%' :: 'u' :: s' -> begin match s' with | 'y' :: s'' -> add_dir (Base U8) (parse_format s'') | 's' :: s'' -> add_dir (Base U16) (parse_format s'') | 'l' :: s'' -> add_dir (Base U32) (parse_format s'') | 'L' :: s'' -> add_dir (Base U64) (parse_format s'') | _ -> None end | '%' :: c :: s' -> begin match c with | '%' -> cons_frag '%' (parse_format s') | 'b' -> add_dir (Base Bool) (parse_format s') | 'c' -> add_dir (Base Char) (parse_format s') | 's' -> add_dir (Base String) (parse_format s') | 'y' -> add_dir (Base I8) (parse_format s') | 'i' -> add_dir (Base I16) (parse_format s') | 'l' -> add_dir (Base I32) (parse_format s') | 'L' -> add_dir (Base I64) (parse_format s') | _ -> None end | c :: s' -> cons_frag c (parse_format s') /// `parse_format_string`: a wrapper around `parse_format` [@@__reduce__] noextract inline_for_extraction let parse_format_string (s:string) : option fragments = parse_format (list_of_string s) /// `lift a` lifts the type `a` to a higher universe noextract type lift (a:Type u#a) : Type u#(max a b) = | Lift : a -> lift a /// `done` is a `unit` in universe 1 noextract let done : lift unit = Lift u#0 u#1 () /// `arg_t`: interpreting an argument as a type /// (in universe 1) since it is polymorphic in the preorders of a buffer /// GM: Somehow, this needs to be a `let rec` (even if it not really recursive) /// or print_frags fails to verify. I don't know why; the generated /// VC and its encoding seem identical (modulo hash consing in the /// latter). [@@__reduce__] noextract let rec arg_t (a:arg) : Type u#1 = match a with | Base t -> lift (base_typ_as_type t) | Array t -> (l:UInt32.t & r:_ & s:_ & lmbuffer (base_typ_as_type t) r s l) | Any -> (a:Type0 & (a -> StTrivial unit) & a) /// `frag_t`: a fragment is either a string literal or a argument to be interpolated noextract let frag_t = either string (a:arg & arg_t a) /// `live_frags h l` is a liveness predicate on all the buffers in `l` [@@__reduce__] noextract let rec live_frags (h:_) (l:list frag_t) : prop = match l with | [] -> True | Inl _ :: rest -> live_frags h rest | Inr a :: rest -> (match a with | (| Base _, _ |) -> live_frags h rest | (| Any, _ |) -> live_frags h rest | (| Array _, (| _, _, _, b |) |) -> LB.live h b /\ live_frags h rest) /// `interpret_frags` interprets a list of fragments as a Low* function type /// Note `l` is the fragments in L-to-R order (i.e., parsing order) /// `acc` accumulates the fragment values in reverse order [@@__reduce__] noextract let rec interpret_frags (l:fragments) (acc:list frag_t) : Type u#1 = match l with | [] -> // Always a dummy argument at the end // Ensures that all cases of this match // have the same universe, i.e., u#1 lift u#0 u#1 unit -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) | Interpolate (Base t) :: args -> // Base types are simple: we just take one more argument x:base_typ_as_type t -> interpret_frags args (Inr (| Base t, Lift x |) :: acc) | Interpolate (Array t) :: args -> // Arrays are implicitly polymorphic in their preorders `r` and `s` // which is what forces us to be in universe 1 // Note, the length `l` is explicit l:UInt32.t -> #r:LB.srel (base_typ_as_type t) -> #s:LB.srel (base_typ_as_type t) -> b:lmbuffer (base_typ_as_type t) r s l -> interpret_frags args (Inr (| Array t, (| l, r, s, b |) |) :: acc) | Interpolate Any :: args -> #a:Type0 -> p:(a -> StTrivial unit) -> x:a -> interpret_frags args (Inr (| Any, (| a, p, x |) |) :: acc) | Frag s :: args -> // Literal fragments do not incur an additional argument // We just accumulate them and recur interpret_frags args (Inl s :: acc) /// `normal` A normalization marker with very specific steps enabled noextract unfold let normal (#a:Type) (x:a) : a = FStar.Pervasives.norm [iota; zeta; delta_attr [`%__reduce__; `%BigOps.__reduce__]; delta_only [`%Base?; `%Array?; `%Some?; `%Some?.v; `%list_of_string]; primops; simplify] x /// `coerce`: A utility to trigger extensional equality of types noextract let coerce (x:'a{'a == 'b}) : 'b = x /// `fragment_printer`: The type of a printer of fragments noextract let fragment_printer = (acc:list frag_t) -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) /// `print_frags`: Having accumulated all the pieces of a format /// string and the arguments to the printed (i.e., the `list frag_t`), /// this function does the actual work of printing them all using the /// primitive printers noextract inline_for_extraction let rec print_frags (acc:list frag_t) : Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) = match acc with | [] -> () | hd::tl -> print_frags tl; (match hd with | Inl s -> print_string s | Inr (| Base t, Lift value |) -> (match t with | Bool -> print_bool value | Char -> print_char value | String -> print_string value | U8 -> print_u8 value | U16 -> print_u16 value | U32 -> print_u32 value | U64 -> print_u64 value | I8 -> print_i8 value | I16 -> print_i16 value | I32 -> print_i32 value | I64 -> print_i64 value) | Inr (| Array t, (| l, r, s, value |) |) -> (match t with | Bool -> print_lmbuffer_bool l value | Char -> print_lmbuffer_char l value | String -> print_lmbuffer_string l value | U8 -> print_lmbuffer_u8 l value | U16 -> print_lmbuffer_u16 l value | U32 -> print_lmbuffer_u32 l value | U64 -> print_lmbuffer_u64 l value | I8 -> print_lmbuffer_i8 l value | I16 -> print_lmbuffer_i16 l value | I32 -> print_lmbuffer_i32 l value | I64 -> print_lmbuffer_i64 l value) | Inr (| Any, (| _, printer, value |) |) -> printer value) [@@__reduce__] let no_inst #a (#b:a -> Type) (f: (#x:a -> b x)) : unit -> #x:a -> b x = fun () -> f [@@__reduce__] let elim_unit_arrow #t (f:unit -> t) : t = f () // let test2 (f: (#a:Type -> a -> a)) : id_t 0 = test f () // let coerce #a (#b: (a -> Type)) ($f: (#x:a -> b x)) (t:Type{norm t == (#x:a -> b x)}) /// `aux frags acc`: This is the main workhorse which interprets a /// parsed format string (`frags`) as a variadic, stateful function [@@__reduce__] noextract inline_for_extraction let rec aux (frags:fragments) (acc:list frag_t) (fp: fragment_printer) : interpret_frags frags acc = match frags with | [] -> let f (l:lift u#0 u#1 unit) : Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) = fp acc in (f <: interpret_frags [] acc) | Frag s :: rest -> coerce (aux rest (Inl s :: acc) fp) | Interpolate (Base t) :: args -> let f (x:base_typ_as_type t) : interpret_frags args (Inr (| Base t, Lift x |) :: acc) = aux args (Inr (| Base t, Lift x |) :: acc) fp in f | Interpolate (Array t) :: rest -> let f : l:UInt32.t -> #r:LB.srel (base_typ_as_type t) -> #s:LB.srel (base_typ_as_type t) -> b:lmbuffer (base_typ_as_type t) r s l -> interpret_frags rest (Inr (| Array t, (| l, r, s, b |) |) :: acc) = fun l #r #s b -> aux rest (Inr (| Array t, (| l, r, s, b |) |) :: acc) fp in f <: interpret_frags (Interpolate (Array t) :: rest) acc | Interpolate Any :: rest -> let f : unit -> #a:Type -> p:(a -> StTrivial unit) -> x:a -> interpret_frags rest (Inr (| Any, (| a, p, x |) |) :: acc) = fun () #a p x -> aux rest (Inr (| Any, (| a, p, x |) |) :: acc) fp in elim_unit_arrow (no_inst (f ()) <: (unit -> interpret_frags (Interpolate Any :: rest) acc)) /// `format_string` : A valid format string is one that can be successfully parsed [@@__reduce__] noextract let format_string = s:string{normal #bool (Some? (parse_format_string s))} /// `interpret_format_string` parses a string into fragments and then /// interprets it as a type [@@__reduce__] noextract let interpret_format_string (s:format_string) : Type = interpret_frags (Some?.v (parse_format_string s)) [] /// `printf'`: Almost there ... this has a variadic type /// and calls the actual printers for all its arguments. /// /// Note, the `normalize_term` in its body is crucial. It's what /// allows the term to be specialized at extraction time. noextract inline_for_extraction let printf' (s:format_string) : interpret_format_string s = normalize_term (match parse_format_string s with | Some frags -> aux frags [] print_frags) /// `intro_normal_f`: a technical gadget to introduce /// implicit normalization in the domain and co-domain of a function type noextract inline_for_extraction let intro_normal_f (#a:Type) (b: (a -> Type)) (f:(x:a -> b x)) : (x:(normal a) -> normal (b x)) = f /// `printf`: The main function has type /// `s:normal format_string -> normal (interpret_format_string s)` /// Note: /// This is the type F* infers for it and it is best to leave it that way /// rather then writing it down and asking F* to re-check what it inferred. /// /// Annotating it results in a needless additional proof obligation to /// equate types after they are partially reduced, which is pointless. noextract inline_for_extraction
false
false
LowStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val printf : s:normal format_string -> normal (interpret_format_string s)
[]
LowStar.Printf.printf
{ "file_name": "ulib/LowStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s: LowStar.Printf.normal LowStar.Printf.format_string -> LowStar.Printf.normal (LowStar.Printf.interpret_format_string s)
{ "end_col": 74, "end_line": 482, "start_col": 13, "start_line": 482 }
Prims.Tot
val skip : s:normal format_string -> normal (interpret_format_string s)
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "LB" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let skip = intro_normal_f #format_string interpret_format_string skip'
val skip : s:normal format_string -> normal (interpret_format_string s) let skip =
false
null
false
intro_normal_f #format_string interpret_format_string skip'
{ "checked_file": "LowStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked", "FStar.BigOps.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Printf.fst" }
[ "total" ]
[ "LowStar.Printf.intro_normal_f", "LowStar.Printf.format_string", "LowStar.Printf.interpret_format_string", "LowStar.Printf.skip'" ]
[]
(* 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 LowStar.Printf /// This module provides imperative printing functions for several /// primitive Low* types, including /// -- booleans (%b) /// -- characters (%c) /// -- strings (%s) /// -- machine integers /// (UInt8.t as %uy, UInt16.t as %us, UInt32.t as %ul, and UInt64.t as %uL; /// Int8.t as %y, Int16.t as %i, Int32.t as %l , and Int64.t as %L) /// -- and arrays (aka buffers) of these base types formatted /// as %xN, where N is the format specifier for the array element type /// e.g., %xuy for buffers of UInt8.t /// The main function of this module is `printf` /// There are a few main differences relative to C printf /// -- The format specifiers are different (see above) /// /// -- For technical reasons explained below, an extra dummy /// argument `done` has to be provided at the end for the /// computation to have any effect. /// /// E.g., one must write /// `printf "%b %c" true 'c' done` /// rather than just /// `printf "%b %c" true 'c'` /// /// -- When printing arrays, two arguments must be passed; the /// length of the array fragment to be formatted and the array /// itself /// /// -- When extracted, rather than producing a C `printf` (which /// does not, e.g., support printing of dynamically sized /// arrays), our `printf` is specialized to a sequence of calls /// to primitive printers for each supported type /// /// Before diving into the technical details of how this module works, /// you might want to see a sample usage at the very end of this file. open FStar.Char open FStar.String open FStar.HyperStack.ST module L = FStar.List.Tot module LB = LowStar.Monotonic.Buffer /// `lmbuffer a r s l` is /// - a monotonic buffer of `a` /// - governed by preorders `r` and `s` /// - with length `l` let lmbuffer a r s l = b:LB.mbuffer a r s{ LB.len b == l } /// `StTrivial`: A effect abbreviation for a stateful computation /// with no precondition, and which does not change the state effect StTrivial (a:Type) = Stack a (requires fun h -> True) (ensures fun h0 _ h1 -> h0==h1) /// `StBuf a b`: A effect abbreviation for a stateful computation /// that may read `b` does not change the state effect StBuf (a:Type) #t #r #s #l (b:lmbuffer t r s l) = Stack a (requires fun h -> LB.live h b) (ensures (fun h0 _ h1 -> h0 == h1)) /// Primitive printers for all the types supported by this module assume val print_string: string -> StTrivial unit assume val print_char : char -> StTrivial unit assume val print_u8 : UInt8.t -> StTrivial unit assume val print_u16 : UInt16.t -> StTrivial unit assume val print_u32 : UInt32.t -> StTrivial unit assume val print_u64 : UInt64.t -> StTrivial unit assume val print_i8 : Int8.t -> StTrivial unit assume val print_i16 : Int16.t -> StTrivial unit assume val print_i32 : Int32.t -> StTrivial unit assume val print_i64 : Int64.t -> StTrivial unit assume val print_bool : bool -> StTrivial unit assume val print_lmbuffer_bool (l:_) (#r:_) (#s:_) (b:lmbuffer bool r s l) : StBuf unit b assume val print_lmbuffer_char (l:_) (#r:_) (#s:_) (b:lmbuffer char r s l) : StBuf unit b assume val print_lmbuffer_string (l:_) (#r:_) (#s:_) (b:lmbuffer string r s l) : StBuf unit b assume val print_lmbuffer_u8 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt8.t r s l) : StBuf unit b assume val print_lmbuffer_u16 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt16.t r s l) : StBuf unit b assume val print_lmbuffer_u32 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt32.t r s l) : StBuf unit b assume val print_lmbuffer_u64 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt64.t r s l) : StBuf unit b assume val print_lmbuffer_i8 (l:_) (#r:_) (#s:_) (b:lmbuffer Int8.t r s l) : StBuf unit b assume val print_lmbuffer_i16 (l:_) (#r:_) (#s:_) (b:lmbuffer Int16.t r s l) : StBuf unit b assume val print_lmbuffer_i32 (l:_) (#r:_) (#s:_) (b:lmbuffer Int32.t r s l) : StBuf unit b assume val print_lmbuffer_i64 (l:_) (#r:_) (#s:_) (b:lmbuffer Int64.t r s l) : StBuf unit b /// An attribute to control reduction noextract irreducible let __reduce__ = unit /// Base types supported so far noextract type base_typ = | Bool | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 /// Argument types are base types and arrays thereof /// Or polymorphic arguments specified by "%a" noextract type arg = | Base of base_typ | Array of base_typ | Any /// Interpreting a `base_typ` as a type [@@__reduce__] noextract let base_typ_as_type (b:base_typ) : Type0 = match b with | Bool -> bool | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t /// `fragment`: A format string is parsed into a list of fragments of /// string literals and other arguments that need to be spliced in /// (interpolated) noextract type fragment = | Frag of string | Interpolate of arg noextract let fragments = list fragment /// `parse_format s`: /// Parses a list of characters in a format string into a list of fragments /// Or None, in case the format string is invalid [@@__reduce__] noextract inline_for_extraction let rec parse_format (s:list char) : Tot (option fragments) (decreases (L.length s)) = let add_dir (d:arg) (ods : option fragments) = match ods with | None -> None | Some ds -> Some (Interpolate d::ds) in let head_buffer (ods:option fragments) = match ods with | Some (Interpolate (Base t) :: rest) -> Some (Interpolate (Array t) :: rest) | _ -> None in let cons_frag (c:char) (ods:option fragments) = match ods with | Some (Frag s::rest) -> Some (Frag (string_of_list (c :: list_of_string s)) :: rest) | Some rest -> Some (Frag (string_of_list [c]) :: rest) | _ -> None in match s with | [] -> Some [] | ['%'] -> None // %a... polymorphic arguments and preceded by their printers | '%' :: 'a' :: s' -> add_dir Any (parse_format s') // %x... arrays of base types | '%' :: 'x' :: s' -> head_buffer (parse_format ('%' :: s')) // %u ... Unsigned integers | '%' :: 'u' :: s' -> begin match s' with | 'y' :: s'' -> add_dir (Base U8) (parse_format s'') | 's' :: s'' -> add_dir (Base U16) (parse_format s'') | 'l' :: s'' -> add_dir (Base U32) (parse_format s'') | 'L' :: s'' -> add_dir (Base U64) (parse_format s'') | _ -> None end | '%' :: c :: s' -> begin match c with | '%' -> cons_frag '%' (parse_format s') | 'b' -> add_dir (Base Bool) (parse_format s') | 'c' -> add_dir (Base Char) (parse_format s') | 's' -> add_dir (Base String) (parse_format s') | 'y' -> add_dir (Base I8) (parse_format s') | 'i' -> add_dir (Base I16) (parse_format s') | 'l' -> add_dir (Base I32) (parse_format s') | 'L' -> add_dir (Base I64) (parse_format s') | _ -> None end | c :: s' -> cons_frag c (parse_format s') /// `parse_format_string`: a wrapper around `parse_format` [@@__reduce__] noextract inline_for_extraction let parse_format_string (s:string) : option fragments = parse_format (list_of_string s) /// `lift a` lifts the type `a` to a higher universe noextract type lift (a:Type u#a) : Type u#(max a b) = | Lift : a -> lift a /// `done` is a `unit` in universe 1 noextract let done : lift unit = Lift u#0 u#1 () /// `arg_t`: interpreting an argument as a type /// (in universe 1) since it is polymorphic in the preorders of a buffer /// GM: Somehow, this needs to be a `let rec` (even if it not really recursive) /// or print_frags fails to verify. I don't know why; the generated /// VC and its encoding seem identical (modulo hash consing in the /// latter). [@@__reduce__] noextract let rec arg_t (a:arg) : Type u#1 = match a with | Base t -> lift (base_typ_as_type t) | Array t -> (l:UInt32.t & r:_ & s:_ & lmbuffer (base_typ_as_type t) r s l) | Any -> (a:Type0 & (a -> StTrivial unit) & a) /// `frag_t`: a fragment is either a string literal or a argument to be interpolated noextract let frag_t = either string (a:arg & arg_t a) /// `live_frags h l` is a liveness predicate on all the buffers in `l` [@@__reduce__] noextract let rec live_frags (h:_) (l:list frag_t) : prop = match l with | [] -> True | Inl _ :: rest -> live_frags h rest | Inr a :: rest -> (match a with | (| Base _, _ |) -> live_frags h rest | (| Any, _ |) -> live_frags h rest | (| Array _, (| _, _, _, b |) |) -> LB.live h b /\ live_frags h rest) /// `interpret_frags` interprets a list of fragments as a Low* function type /// Note `l` is the fragments in L-to-R order (i.e., parsing order) /// `acc` accumulates the fragment values in reverse order [@@__reduce__] noextract let rec interpret_frags (l:fragments) (acc:list frag_t) : Type u#1 = match l with | [] -> // Always a dummy argument at the end // Ensures that all cases of this match // have the same universe, i.e., u#1 lift u#0 u#1 unit -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) | Interpolate (Base t) :: args -> // Base types are simple: we just take one more argument x:base_typ_as_type t -> interpret_frags args (Inr (| Base t, Lift x |) :: acc) | Interpolate (Array t) :: args -> // Arrays are implicitly polymorphic in their preorders `r` and `s` // which is what forces us to be in universe 1 // Note, the length `l` is explicit l:UInt32.t -> #r:LB.srel (base_typ_as_type t) -> #s:LB.srel (base_typ_as_type t) -> b:lmbuffer (base_typ_as_type t) r s l -> interpret_frags args (Inr (| Array t, (| l, r, s, b |) |) :: acc) | Interpolate Any :: args -> #a:Type0 -> p:(a -> StTrivial unit) -> x:a -> interpret_frags args (Inr (| Any, (| a, p, x |) |) :: acc) | Frag s :: args -> // Literal fragments do not incur an additional argument // We just accumulate them and recur interpret_frags args (Inl s :: acc) /// `normal` A normalization marker with very specific steps enabled noextract unfold let normal (#a:Type) (x:a) : a = FStar.Pervasives.norm [iota; zeta; delta_attr [`%__reduce__; `%BigOps.__reduce__]; delta_only [`%Base?; `%Array?; `%Some?; `%Some?.v; `%list_of_string]; primops; simplify] x /// `coerce`: A utility to trigger extensional equality of types noextract let coerce (x:'a{'a == 'b}) : 'b = x /// `fragment_printer`: The type of a printer of fragments noextract let fragment_printer = (acc:list frag_t) -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) /// `print_frags`: Having accumulated all the pieces of a format /// string and the arguments to the printed (i.e., the `list frag_t`), /// this function does the actual work of printing them all using the /// primitive printers noextract inline_for_extraction let rec print_frags (acc:list frag_t) : Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) = match acc with | [] -> () | hd::tl -> print_frags tl; (match hd with | Inl s -> print_string s | Inr (| Base t, Lift value |) -> (match t with | Bool -> print_bool value | Char -> print_char value | String -> print_string value | U8 -> print_u8 value | U16 -> print_u16 value | U32 -> print_u32 value | U64 -> print_u64 value | I8 -> print_i8 value | I16 -> print_i16 value | I32 -> print_i32 value | I64 -> print_i64 value) | Inr (| Array t, (| l, r, s, value |) |) -> (match t with | Bool -> print_lmbuffer_bool l value | Char -> print_lmbuffer_char l value | String -> print_lmbuffer_string l value | U8 -> print_lmbuffer_u8 l value | U16 -> print_lmbuffer_u16 l value | U32 -> print_lmbuffer_u32 l value | U64 -> print_lmbuffer_u64 l value | I8 -> print_lmbuffer_i8 l value | I16 -> print_lmbuffer_i16 l value | I32 -> print_lmbuffer_i32 l value | I64 -> print_lmbuffer_i64 l value) | Inr (| Any, (| _, printer, value |) |) -> printer value) [@@__reduce__] let no_inst #a (#b:a -> Type) (f: (#x:a -> b x)) : unit -> #x:a -> b x = fun () -> f [@@__reduce__] let elim_unit_arrow #t (f:unit -> t) : t = f () // let test2 (f: (#a:Type -> a -> a)) : id_t 0 = test f () // let coerce #a (#b: (a -> Type)) ($f: (#x:a -> b x)) (t:Type{norm t == (#x:a -> b x)}) /// `aux frags acc`: This is the main workhorse which interprets a /// parsed format string (`frags`) as a variadic, stateful function [@@__reduce__] noextract inline_for_extraction let rec aux (frags:fragments) (acc:list frag_t) (fp: fragment_printer) : interpret_frags frags acc = match frags with | [] -> let f (l:lift u#0 u#1 unit) : Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) = fp acc in (f <: interpret_frags [] acc) | Frag s :: rest -> coerce (aux rest (Inl s :: acc) fp) | Interpolate (Base t) :: args -> let f (x:base_typ_as_type t) : interpret_frags args (Inr (| Base t, Lift x |) :: acc) = aux args (Inr (| Base t, Lift x |) :: acc) fp in f | Interpolate (Array t) :: rest -> let f : l:UInt32.t -> #r:LB.srel (base_typ_as_type t) -> #s:LB.srel (base_typ_as_type t) -> b:lmbuffer (base_typ_as_type t) r s l -> interpret_frags rest (Inr (| Array t, (| l, r, s, b |) |) :: acc) = fun l #r #s b -> aux rest (Inr (| Array t, (| l, r, s, b |) |) :: acc) fp in f <: interpret_frags (Interpolate (Array t) :: rest) acc | Interpolate Any :: rest -> let f : unit -> #a:Type -> p:(a -> StTrivial unit) -> x:a -> interpret_frags rest (Inr (| Any, (| a, p, x |) |) :: acc) = fun () #a p x -> aux rest (Inr (| Any, (| a, p, x |) |) :: acc) fp in elim_unit_arrow (no_inst (f ()) <: (unit -> interpret_frags (Interpolate Any :: rest) acc)) /// `format_string` : A valid format string is one that can be successfully parsed [@@__reduce__] noextract let format_string = s:string{normal #bool (Some? (parse_format_string s))} /// `interpret_format_string` parses a string into fragments and then /// interprets it as a type [@@__reduce__] noextract let interpret_format_string (s:format_string) : Type = interpret_frags (Some?.v (parse_format_string s)) [] /// `printf'`: Almost there ... this has a variadic type /// and calls the actual printers for all its arguments. /// /// Note, the `normalize_term` in its body is crucial. It's what /// allows the term to be specialized at extraction time. noextract inline_for_extraction let printf' (s:format_string) : interpret_format_string s = normalize_term (match parse_format_string s with | Some frags -> aux frags [] print_frags) /// `intro_normal_f`: a technical gadget to introduce /// implicit normalization in the domain and co-domain of a function type noextract inline_for_extraction let intro_normal_f (#a:Type) (b: (a -> Type)) (f:(x:a -> b x)) : (x:(normal a) -> normal (b x)) = f /// `printf`: The main function has type /// `s:normal format_string -> normal (interpret_format_string s)` /// Note: /// This is the type F* infers for it and it is best to leave it that way /// rather then writing it down and asking F* to re-check what it inferred. /// /// Annotating it results in a needless additional proof obligation to /// equate types after they are partially reduced, which is pointless. noextract inline_for_extraction val printf : s:normal format_string -> normal (interpret_format_string s) let printf = intro_normal_f #format_string interpret_format_string printf' /// `skip`: We also provide `skip`, a function that has the same type as printf /// but normalizes to `()`, i.e., it prints nothing. This is useful for conditional /// printing in debug code, for instance. noextract inline_for_extraction let skip' (s:format_string) : interpret_format_string s = normalize_term (match parse_format_string s with | Some frags -> aux frags [] (fun _ -> ())) noextract inline_for_extraction
false
false
LowStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val skip : s:normal format_string -> normal (interpret_format_string s)
[]
LowStar.Printf.skip
{ "file_name": "ulib/LowStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s: LowStar.Printf.normal LowStar.Printf.format_string -> LowStar.Printf.normal (LowStar.Printf.interpret_format_string s)
{ "end_col": 70, "end_line": 496, "start_col": 11, "start_line": 496 }
Prims.Tot
val base_typ_as_type (b: base_typ) : Type0
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "LB" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let base_typ_as_type (b:base_typ) : Type0 = match b with | Bool -> bool | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t
val base_typ_as_type (b: base_typ) : Type0 let base_typ_as_type (b: base_typ) : Type0 =
false
null
false
match b with | Bool -> bool | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t
{ "checked_file": "LowStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked", "FStar.BigOps.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Printf.fst" }
[ "total" ]
[ "LowStar.Printf.base_typ", "Prims.bool", "FStar.String.char", "Prims.string", "FStar.UInt8.t", "FStar.UInt16.t", "FStar.UInt32.t", "FStar.UInt64.t", "FStar.Int8.t", "FStar.Int16.t", "FStar.Int32.t", "FStar.Int64.t" ]
[]
(* 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 LowStar.Printf /// This module provides imperative printing functions for several /// primitive Low* types, including /// -- booleans (%b) /// -- characters (%c) /// -- strings (%s) /// -- machine integers /// (UInt8.t as %uy, UInt16.t as %us, UInt32.t as %ul, and UInt64.t as %uL; /// Int8.t as %y, Int16.t as %i, Int32.t as %l , and Int64.t as %L) /// -- and arrays (aka buffers) of these base types formatted /// as %xN, where N is the format specifier for the array element type /// e.g., %xuy for buffers of UInt8.t /// The main function of this module is `printf` /// There are a few main differences relative to C printf /// -- The format specifiers are different (see above) /// /// -- For technical reasons explained below, an extra dummy /// argument `done` has to be provided at the end for the /// computation to have any effect. /// /// E.g., one must write /// `printf "%b %c" true 'c' done` /// rather than just /// `printf "%b %c" true 'c'` /// /// -- When printing arrays, two arguments must be passed; the /// length of the array fragment to be formatted and the array /// itself /// /// -- When extracted, rather than producing a C `printf` (which /// does not, e.g., support printing of dynamically sized /// arrays), our `printf` is specialized to a sequence of calls /// to primitive printers for each supported type /// /// Before diving into the technical details of how this module works, /// you might want to see a sample usage at the very end of this file. open FStar.Char open FStar.String open FStar.HyperStack.ST module L = FStar.List.Tot module LB = LowStar.Monotonic.Buffer /// `lmbuffer a r s l` is /// - a monotonic buffer of `a` /// - governed by preorders `r` and `s` /// - with length `l` let lmbuffer a r s l = b:LB.mbuffer a r s{ LB.len b == l } /// `StTrivial`: A effect abbreviation for a stateful computation /// with no precondition, and which does not change the state effect StTrivial (a:Type) = Stack a (requires fun h -> True) (ensures fun h0 _ h1 -> h0==h1) /// `StBuf a b`: A effect abbreviation for a stateful computation /// that may read `b` does not change the state effect StBuf (a:Type) #t #r #s #l (b:lmbuffer t r s l) = Stack a (requires fun h -> LB.live h b) (ensures (fun h0 _ h1 -> h0 == h1)) /// Primitive printers for all the types supported by this module assume val print_string: string -> StTrivial unit assume val print_char : char -> StTrivial unit assume val print_u8 : UInt8.t -> StTrivial unit assume val print_u16 : UInt16.t -> StTrivial unit assume val print_u32 : UInt32.t -> StTrivial unit assume val print_u64 : UInt64.t -> StTrivial unit assume val print_i8 : Int8.t -> StTrivial unit assume val print_i16 : Int16.t -> StTrivial unit assume val print_i32 : Int32.t -> StTrivial unit assume val print_i64 : Int64.t -> StTrivial unit assume val print_bool : bool -> StTrivial unit assume val print_lmbuffer_bool (l:_) (#r:_) (#s:_) (b:lmbuffer bool r s l) : StBuf unit b assume val print_lmbuffer_char (l:_) (#r:_) (#s:_) (b:lmbuffer char r s l) : StBuf unit b assume val print_lmbuffer_string (l:_) (#r:_) (#s:_) (b:lmbuffer string r s l) : StBuf unit b assume val print_lmbuffer_u8 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt8.t r s l) : StBuf unit b assume val print_lmbuffer_u16 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt16.t r s l) : StBuf unit b assume val print_lmbuffer_u32 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt32.t r s l) : StBuf unit b assume val print_lmbuffer_u64 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt64.t r s l) : StBuf unit b assume val print_lmbuffer_i8 (l:_) (#r:_) (#s:_) (b:lmbuffer Int8.t r s l) : StBuf unit b assume val print_lmbuffer_i16 (l:_) (#r:_) (#s:_) (b:lmbuffer Int16.t r s l) : StBuf unit b assume val print_lmbuffer_i32 (l:_) (#r:_) (#s:_) (b:lmbuffer Int32.t r s l) : StBuf unit b assume val print_lmbuffer_i64 (l:_) (#r:_) (#s:_) (b:lmbuffer Int64.t r s l) : StBuf unit b /// An attribute to control reduction noextract irreducible let __reduce__ = unit /// Base types supported so far noextract type base_typ = | Bool | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 /// Argument types are base types and arrays thereof /// Or polymorphic arguments specified by "%a" noextract type arg = | Base of base_typ | Array of base_typ | Any /// Interpreting a `base_typ` as a type [@@__reduce__] noextract
false
true
LowStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val base_typ_as_type (b: base_typ) : Type0
[]
LowStar.Printf.base_typ_as_type
{ "file_name": "ulib/LowStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
b: LowStar.Printf.base_typ -> Type0
{ "end_col": 27, "end_line": 151, "start_col": 2, "start_line": 140 }
Prims.Tot
val coerce (x: 'a{'a == 'b}) : 'b
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "LB" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let coerce (x:'a{'a == 'b}) : 'b = x
val coerce (x: 'a{'a == 'b}) : 'b let coerce (x: 'a{'a == 'b}) : 'b =
false
null
false
x
{ "checked_file": "LowStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked", "FStar.BigOps.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Printf.fst" }
[ "total" ]
[ "Prims.eq2" ]
[]
(* 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 LowStar.Printf /// This module provides imperative printing functions for several /// primitive Low* types, including /// -- booleans (%b) /// -- characters (%c) /// -- strings (%s) /// -- machine integers /// (UInt8.t as %uy, UInt16.t as %us, UInt32.t as %ul, and UInt64.t as %uL; /// Int8.t as %y, Int16.t as %i, Int32.t as %l , and Int64.t as %L) /// -- and arrays (aka buffers) of these base types formatted /// as %xN, where N is the format specifier for the array element type /// e.g., %xuy for buffers of UInt8.t /// The main function of this module is `printf` /// There are a few main differences relative to C printf /// -- The format specifiers are different (see above) /// /// -- For technical reasons explained below, an extra dummy /// argument `done` has to be provided at the end for the /// computation to have any effect. /// /// E.g., one must write /// `printf "%b %c" true 'c' done` /// rather than just /// `printf "%b %c" true 'c'` /// /// -- When printing arrays, two arguments must be passed; the /// length of the array fragment to be formatted and the array /// itself /// /// -- When extracted, rather than producing a C `printf` (which /// does not, e.g., support printing of dynamically sized /// arrays), our `printf` is specialized to a sequence of calls /// to primitive printers for each supported type /// /// Before diving into the technical details of how this module works, /// you might want to see a sample usage at the very end of this file. open FStar.Char open FStar.String open FStar.HyperStack.ST module L = FStar.List.Tot module LB = LowStar.Monotonic.Buffer /// `lmbuffer a r s l` is /// - a monotonic buffer of `a` /// - governed by preorders `r` and `s` /// - with length `l` let lmbuffer a r s l = b:LB.mbuffer a r s{ LB.len b == l } /// `StTrivial`: A effect abbreviation for a stateful computation /// with no precondition, and which does not change the state effect StTrivial (a:Type) = Stack a (requires fun h -> True) (ensures fun h0 _ h1 -> h0==h1) /// `StBuf a b`: A effect abbreviation for a stateful computation /// that may read `b` does not change the state effect StBuf (a:Type) #t #r #s #l (b:lmbuffer t r s l) = Stack a (requires fun h -> LB.live h b) (ensures (fun h0 _ h1 -> h0 == h1)) /// Primitive printers for all the types supported by this module assume val print_string: string -> StTrivial unit assume val print_char : char -> StTrivial unit assume val print_u8 : UInt8.t -> StTrivial unit assume val print_u16 : UInt16.t -> StTrivial unit assume val print_u32 : UInt32.t -> StTrivial unit assume val print_u64 : UInt64.t -> StTrivial unit assume val print_i8 : Int8.t -> StTrivial unit assume val print_i16 : Int16.t -> StTrivial unit assume val print_i32 : Int32.t -> StTrivial unit assume val print_i64 : Int64.t -> StTrivial unit assume val print_bool : bool -> StTrivial unit assume val print_lmbuffer_bool (l:_) (#r:_) (#s:_) (b:lmbuffer bool r s l) : StBuf unit b assume val print_lmbuffer_char (l:_) (#r:_) (#s:_) (b:lmbuffer char r s l) : StBuf unit b assume val print_lmbuffer_string (l:_) (#r:_) (#s:_) (b:lmbuffer string r s l) : StBuf unit b assume val print_lmbuffer_u8 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt8.t r s l) : StBuf unit b assume val print_lmbuffer_u16 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt16.t r s l) : StBuf unit b assume val print_lmbuffer_u32 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt32.t r s l) : StBuf unit b assume val print_lmbuffer_u64 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt64.t r s l) : StBuf unit b assume val print_lmbuffer_i8 (l:_) (#r:_) (#s:_) (b:lmbuffer Int8.t r s l) : StBuf unit b assume val print_lmbuffer_i16 (l:_) (#r:_) (#s:_) (b:lmbuffer Int16.t r s l) : StBuf unit b assume val print_lmbuffer_i32 (l:_) (#r:_) (#s:_) (b:lmbuffer Int32.t r s l) : StBuf unit b assume val print_lmbuffer_i64 (l:_) (#r:_) (#s:_) (b:lmbuffer Int64.t r s l) : StBuf unit b /// An attribute to control reduction noextract irreducible let __reduce__ = unit /// Base types supported so far noextract type base_typ = | Bool | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 /// Argument types are base types and arrays thereof /// Or polymorphic arguments specified by "%a" noextract type arg = | Base of base_typ | Array of base_typ | Any /// Interpreting a `base_typ` as a type [@@__reduce__] noextract let base_typ_as_type (b:base_typ) : Type0 = match b with | Bool -> bool | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t /// `fragment`: A format string is parsed into a list of fragments of /// string literals and other arguments that need to be spliced in /// (interpolated) noextract type fragment = | Frag of string | Interpolate of arg noextract let fragments = list fragment /// `parse_format s`: /// Parses a list of characters in a format string into a list of fragments /// Or None, in case the format string is invalid [@@__reduce__] noextract inline_for_extraction let rec parse_format (s:list char) : Tot (option fragments) (decreases (L.length s)) = let add_dir (d:arg) (ods : option fragments) = match ods with | None -> None | Some ds -> Some (Interpolate d::ds) in let head_buffer (ods:option fragments) = match ods with | Some (Interpolate (Base t) :: rest) -> Some (Interpolate (Array t) :: rest) | _ -> None in let cons_frag (c:char) (ods:option fragments) = match ods with | Some (Frag s::rest) -> Some (Frag (string_of_list (c :: list_of_string s)) :: rest) | Some rest -> Some (Frag (string_of_list [c]) :: rest) | _ -> None in match s with | [] -> Some [] | ['%'] -> None // %a... polymorphic arguments and preceded by their printers | '%' :: 'a' :: s' -> add_dir Any (parse_format s') // %x... arrays of base types | '%' :: 'x' :: s' -> head_buffer (parse_format ('%' :: s')) // %u ... Unsigned integers | '%' :: 'u' :: s' -> begin match s' with | 'y' :: s'' -> add_dir (Base U8) (parse_format s'') | 's' :: s'' -> add_dir (Base U16) (parse_format s'') | 'l' :: s'' -> add_dir (Base U32) (parse_format s'') | 'L' :: s'' -> add_dir (Base U64) (parse_format s'') | _ -> None end | '%' :: c :: s' -> begin match c with | '%' -> cons_frag '%' (parse_format s') | 'b' -> add_dir (Base Bool) (parse_format s') | 'c' -> add_dir (Base Char) (parse_format s') | 's' -> add_dir (Base String) (parse_format s') | 'y' -> add_dir (Base I8) (parse_format s') | 'i' -> add_dir (Base I16) (parse_format s') | 'l' -> add_dir (Base I32) (parse_format s') | 'L' -> add_dir (Base I64) (parse_format s') | _ -> None end | c :: s' -> cons_frag c (parse_format s') /// `parse_format_string`: a wrapper around `parse_format` [@@__reduce__] noextract inline_for_extraction let parse_format_string (s:string) : option fragments = parse_format (list_of_string s) /// `lift a` lifts the type `a` to a higher universe noextract type lift (a:Type u#a) : Type u#(max a b) = | Lift : a -> lift a /// `done` is a `unit` in universe 1 noextract let done : lift unit = Lift u#0 u#1 () /// `arg_t`: interpreting an argument as a type /// (in universe 1) since it is polymorphic in the preorders of a buffer /// GM: Somehow, this needs to be a `let rec` (even if it not really recursive) /// or print_frags fails to verify. I don't know why; the generated /// VC and its encoding seem identical (modulo hash consing in the /// latter). [@@__reduce__] noextract let rec arg_t (a:arg) : Type u#1 = match a with | Base t -> lift (base_typ_as_type t) | Array t -> (l:UInt32.t & r:_ & s:_ & lmbuffer (base_typ_as_type t) r s l) | Any -> (a:Type0 & (a -> StTrivial unit) & a) /// `frag_t`: a fragment is either a string literal or a argument to be interpolated noextract let frag_t = either string (a:arg & arg_t a) /// `live_frags h l` is a liveness predicate on all the buffers in `l` [@@__reduce__] noextract let rec live_frags (h:_) (l:list frag_t) : prop = match l with | [] -> True | Inl _ :: rest -> live_frags h rest | Inr a :: rest -> (match a with | (| Base _, _ |) -> live_frags h rest | (| Any, _ |) -> live_frags h rest | (| Array _, (| _, _, _, b |) |) -> LB.live h b /\ live_frags h rest) /// `interpret_frags` interprets a list of fragments as a Low* function type /// Note `l` is the fragments in L-to-R order (i.e., parsing order) /// `acc` accumulates the fragment values in reverse order [@@__reduce__] noextract let rec interpret_frags (l:fragments) (acc:list frag_t) : Type u#1 = match l with | [] -> // Always a dummy argument at the end // Ensures that all cases of this match // have the same universe, i.e., u#1 lift u#0 u#1 unit -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) | Interpolate (Base t) :: args -> // Base types are simple: we just take one more argument x:base_typ_as_type t -> interpret_frags args (Inr (| Base t, Lift x |) :: acc) | Interpolate (Array t) :: args -> // Arrays are implicitly polymorphic in their preorders `r` and `s` // which is what forces us to be in universe 1 // Note, the length `l` is explicit l:UInt32.t -> #r:LB.srel (base_typ_as_type t) -> #s:LB.srel (base_typ_as_type t) -> b:lmbuffer (base_typ_as_type t) r s l -> interpret_frags args (Inr (| Array t, (| l, r, s, b |) |) :: acc) | Interpolate Any :: args -> #a:Type0 -> p:(a -> StTrivial unit) -> x:a -> interpret_frags args (Inr (| Any, (| a, p, x |) |) :: acc) | Frag s :: args -> // Literal fragments do not incur an additional argument // We just accumulate them and recur interpret_frags args (Inl s :: acc) /// `normal` A normalization marker with very specific steps enabled noextract unfold let normal (#a:Type) (x:a) : a = FStar.Pervasives.norm [iota; zeta; delta_attr [`%__reduce__; `%BigOps.__reduce__]; delta_only [`%Base?; `%Array?; `%Some?; `%Some?.v; `%list_of_string]; primops; simplify] x /// `coerce`: A utility to trigger extensional equality of types
false
false
LowStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val coerce (x: 'a{'a == 'b}) : 'b
[]
LowStar.Printf.coerce
{ "file_name": "ulib/LowStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: 'a{'a == 'b} -> 'b
{ "end_col": 36, "end_line": 334, "start_col": 35, "start_line": 334 }
Prims.Tot
val arg_t (a: arg) : Type u#1
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "LB" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec arg_t (a:arg) : Type u#1 = match a with | Base t -> lift (base_typ_as_type t) | Array t -> (l:UInt32.t & r:_ & s:_ & lmbuffer (base_typ_as_type t) r s l) | Any -> (a:Type0 & (a -> StTrivial unit) & a)
val arg_t (a: arg) : Type u#1 let rec arg_t (a: arg) : Type u#1 =
false
null
false
match a with | Base t -> lift (base_typ_as_type t) | Array t -> (l: UInt32.t & r: _ & s: _ & lmbuffer (base_typ_as_type t) r s l) | Any -> (a: Type0 & (a -> StTrivial unit) & a)
{ "checked_file": "LowStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked", "FStar.BigOps.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Printf.fst" }
[ "total" ]
[ "LowStar.Printf.arg", "LowStar.Printf.base_typ", "LowStar.Printf.lift", "LowStar.Printf.base_typ_as_type", "FStar.Pervasives.dtuple4", "FStar.UInt32.t", "LowStar.Monotonic.Buffer.srel", "LowStar.Printf.lmbuffer", "FStar.Pervasives.dtuple3", "Prims.unit" ]
[]
(* 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 LowStar.Printf /// This module provides imperative printing functions for several /// primitive Low* types, including /// -- booleans (%b) /// -- characters (%c) /// -- strings (%s) /// -- machine integers /// (UInt8.t as %uy, UInt16.t as %us, UInt32.t as %ul, and UInt64.t as %uL; /// Int8.t as %y, Int16.t as %i, Int32.t as %l , and Int64.t as %L) /// -- and arrays (aka buffers) of these base types formatted /// as %xN, where N is the format specifier for the array element type /// e.g., %xuy for buffers of UInt8.t /// The main function of this module is `printf` /// There are a few main differences relative to C printf /// -- The format specifiers are different (see above) /// /// -- For technical reasons explained below, an extra dummy /// argument `done` has to be provided at the end for the /// computation to have any effect. /// /// E.g., one must write /// `printf "%b %c" true 'c' done` /// rather than just /// `printf "%b %c" true 'c'` /// /// -- When printing arrays, two arguments must be passed; the /// length of the array fragment to be formatted and the array /// itself /// /// -- When extracted, rather than producing a C `printf` (which /// does not, e.g., support printing of dynamically sized /// arrays), our `printf` is specialized to a sequence of calls /// to primitive printers for each supported type /// /// Before diving into the technical details of how this module works, /// you might want to see a sample usage at the very end of this file. open FStar.Char open FStar.String open FStar.HyperStack.ST module L = FStar.List.Tot module LB = LowStar.Monotonic.Buffer /// `lmbuffer a r s l` is /// - a monotonic buffer of `a` /// - governed by preorders `r` and `s` /// - with length `l` let lmbuffer a r s l = b:LB.mbuffer a r s{ LB.len b == l } /// `StTrivial`: A effect abbreviation for a stateful computation /// with no precondition, and which does not change the state effect StTrivial (a:Type) = Stack a (requires fun h -> True) (ensures fun h0 _ h1 -> h0==h1) /// `StBuf a b`: A effect abbreviation for a stateful computation /// that may read `b` does not change the state effect StBuf (a:Type) #t #r #s #l (b:lmbuffer t r s l) = Stack a (requires fun h -> LB.live h b) (ensures (fun h0 _ h1 -> h0 == h1)) /// Primitive printers for all the types supported by this module assume val print_string: string -> StTrivial unit assume val print_char : char -> StTrivial unit assume val print_u8 : UInt8.t -> StTrivial unit assume val print_u16 : UInt16.t -> StTrivial unit assume val print_u32 : UInt32.t -> StTrivial unit assume val print_u64 : UInt64.t -> StTrivial unit assume val print_i8 : Int8.t -> StTrivial unit assume val print_i16 : Int16.t -> StTrivial unit assume val print_i32 : Int32.t -> StTrivial unit assume val print_i64 : Int64.t -> StTrivial unit assume val print_bool : bool -> StTrivial unit assume val print_lmbuffer_bool (l:_) (#r:_) (#s:_) (b:lmbuffer bool r s l) : StBuf unit b assume val print_lmbuffer_char (l:_) (#r:_) (#s:_) (b:lmbuffer char r s l) : StBuf unit b assume val print_lmbuffer_string (l:_) (#r:_) (#s:_) (b:lmbuffer string r s l) : StBuf unit b assume val print_lmbuffer_u8 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt8.t r s l) : StBuf unit b assume val print_lmbuffer_u16 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt16.t r s l) : StBuf unit b assume val print_lmbuffer_u32 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt32.t r s l) : StBuf unit b assume val print_lmbuffer_u64 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt64.t r s l) : StBuf unit b assume val print_lmbuffer_i8 (l:_) (#r:_) (#s:_) (b:lmbuffer Int8.t r s l) : StBuf unit b assume val print_lmbuffer_i16 (l:_) (#r:_) (#s:_) (b:lmbuffer Int16.t r s l) : StBuf unit b assume val print_lmbuffer_i32 (l:_) (#r:_) (#s:_) (b:lmbuffer Int32.t r s l) : StBuf unit b assume val print_lmbuffer_i64 (l:_) (#r:_) (#s:_) (b:lmbuffer Int64.t r s l) : StBuf unit b /// An attribute to control reduction noextract irreducible let __reduce__ = unit /// Base types supported so far noextract type base_typ = | Bool | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 /// Argument types are base types and arrays thereof /// Or polymorphic arguments specified by "%a" noextract type arg = | Base of base_typ | Array of base_typ | Any /// Interpreting a `base_typ` as a type [@@__reduce__] noextract let base_typ_as_type (b:base_typ) : Type0 = match b with | Bool -> bool | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t /// `fragment`: A format string is parsed into a list of fragments of /// string literals and other arguments that need to be spliced in /// (interpolated) noextract type fragment = | Frag of string | Interpolate of arg noextract let fragments = list fragment /// `parse_format s`: /// Parses a list of characters in a format string into a list of fragments /// Or None, in case the format string is invalid [@@__reduce__] noextract inline_for_extraction let rec parse_format (s:list char) : Tot (option fragments) (decreases (L.length s)) = let add_dir (d:arg) (ods : option fragments) = match ods with | None -> None | Some ds -> Some (Interpolate d::ds) in let head_buffer (ods:option fragments) = match ods with | Some (Interpolate (Base t) :: rest) -> Some (Interpolate (Array t) :: rest) | _ -> None in let cons_frag (c:char) (ods:option fragments) = match ods with | Some (Frag s::rest) -> Some (Frag (string_of_list (c :: list_of_string s)) :: rest) | Some rest -> Some (Frag (string_of_list [c]) :: rest) | _ -> None in match s with | [] -> Some [] | ['%'] -> None // %a... polymorphic arguments and preceded by their printers | '%' :: 'a' :: s' -> add_dir Any (parse_format s') // %x... arrays of base types | '%' :: 'x' :: s' -> head_buffer (parse_format ('%' :: s')) // %u ... Unsigned integers | '%' :: 'u' :: s' -> begin match s' with | 'y' :: s'' -> add_dir (Base U8) (parse_format s'') | 's' :: s'' -> add_dir (Base U16) (parse_format s'') | 'l' :: s'' -> add_dir (Base U32) (parse_format s'') | 'L' :: s'' -> add_dir (Base U64) (parse_format s'') | _ -> None end | '%' :: c :: s' -> begin match c with | '%' -> cons_frag '%' (parse_format s') | 'b' -> add_dir (Base Bool) (parse_format s') | 'c' -> add_dir (Base Char) (parse_format s') | 's' -> add_dir (Base String) (parse_format s') | 'y' -> add_dir (Base I8) (parse_format s') | 'i' -> add_dir (Base I16) (parse_format s') | 'l' -> add_dir (Base I32) (parse_format s') | 'L' -> add_dir (Base I64) (parse_format s') | _ -> None end | c :: s' -> cons_frag c (parse_format s') /// `parse_format_string`: a wrapper around `parse_format` [@@__reduce__] noextract inline_for_extraction let parse_format_string (s:string) : option fragments = parse_format (list_of_string s) /// `lift a` lifts the type `a` to a higher universe noextract type lift (a:Type u#a) : Type u#(max a b) = | Lift : a -> lift a /// `done` is a `unit` in universe 1 noextract let done : lift unit = Lift u#0 u#1 () /// `arg_t`: interpreting an argument as a type /// (in universe 1) since it is polymorphic in the preorders of a buffer /// GM: Somehow, this needs to be a `let rec` (even if it not really recursive) /// or print_frags fails to verify. I don't know why; the generated /// VC and its encoding seem identical (modulo hash consing in the /// latter). [@@__reduce__] noextract
false
true
LowStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val arg_t (a: arg) : Type u#1
[ "recursion" ]
LowStar.Printf.arg_t
{ "file_name": "ulib/LowStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: LowStar.Printf.arg -> Type
{ "end_col": 48, "end_line": 257, "start_col": 2, "start_line": 254 }
Prims.Tot
val intro_normal_f (#a: Type) (b: (a -> Type)) (f: (x: a -> b x)) : (x: (normal a) -> normal (b x))
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "LB" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let intro_normal_f (#a:Type) (b: (a -> Type)) (f:(x:a -> b x)) : (x:(normal a) -> normal (b x)) = f
val intro_normal_f (#a: Type) (b: (a -> Type)) (f: (x: a -> b x)) : (x: (normal a) -> normal (b x)) let intro_normal_f (#a: Type) (b: (a -> Type)) (f: (x: a -> b x)) : (x: (normal a) -> normal (b x)) =
false
null
false
f
{ "checked_file": "LowStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked", "FStar.BigOps.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Printf.fst" }
[ "total" ]
[ "LowStar.Printf.normal" ]
[]
(* 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 LowStar.Printf /// This module provides imperative printing functions for several /// primitive Low* types, including /// -- booleans (%b) /// -- characters (%c) /// -- strings (%s) /// -- machine integers /// (UInt8.t as %uy, UInt16.t as %us, UInt32.t as %ul, and UInt64.t as %uL; /// Int8.t as %y, Int16.t as %i, Int32.t as %l , and Int64.t as %L) /// -- and arrays (aka buffers) of these base types formatted /// as %xN, where N is the format specifier for the array element type /// e.g., %xuy for buffers of UInt8.t /// The main function of this module is `printf` /// There are a few main differences relative to C printf /// -- The format specifiers are different (see above) /// /// -- For technical reasons explained below, an extra dummy /// argument `done` has to be provided at the end for the /// computation to have any effect. /// /// E.g., one must write /// `printf "%b %c" true 'c' done` /// rather than just /// `printf "%b %c" true 'c'` /// /// -- When printing arrays, two arguments must be passed; the /// length of the array fragment to be formatted and the array /// itself /// /// -- When extracted, rather than producing a C `printf` (which /// does not, e.g., support printing of dynamically sized /// arrays), our `printf` is specialized to a sequence of calls /// to primitive printers for each supported type /// /// Before diving into the technical details of how this module works, /// you might want to see a sample usage at the very end of this file. open FStar.Char open FStar.String open FStar.HyperStack.ST module L = FStar.List.Tot module LB = LowStar.Monotonic.Buffer /// `lmbuffer a r s l` is /// - a monotonic buffer of `a` /// - governed by preorders `r` and `s` /// - with length `l` let lmbuffer a r s l = b:LB.mbuffer a r s{ LB.len b == l } /// `StTrivial`: A effect abbreviation for a stateful computation /// with no precondition, and which does not change the state effect StTrivial (a:Type) = Stack a (requires fun h -> True) (ensures fun h0 _ h1 -> h0==h1) /// `StBuf a b`: A effect abbreviation for a stateful computation /// that may read `b` does not change the state effect StBuf (a:Type) #t #r #s #l (b:lmbuffer t r s l) = Stack a (requires fun h -> LB.live h b) (ensures (fun h0 _ h1 -> h0 == h1)) /// Primitive printers for all the types supported by this module assume val print_string: string -> StTrivial unit assume val print_char : char -> StTrivial unit assume val print_u8 : UInt8.t -> StTrivial unit assume val print_u16 : UInt16.t -> StTrivial unit assume val print_u32 : UInt32.t -> StTrivial unit assume val print_u64 : UInt64.t -> StTrivial unit assume val print_i8 : Int8.t -> StTrivial unit assume val print_i16 : Int16.t -> StTrivial unit assume val print_i32 : Int32.t -> StTrivial unit assume val print_i64 : Int64.t -> StTrivial unit assume val print_bool : bool -> StTrivial unit assume val print_lmbuffer_bool (l:_) (#r:_) (#s:_) (b:lmbuffer bool r s l) : StBuf unit b assume val print_lmbuffer_char (l:_) (#r:_) (#s:_) (b:lmbuffer char r s l) : StBuf unit b assume val print_lmbuffer_string (l:_) (#r:_) (#s:_) (b:lmbuffer string r s l) : StBuf unit b assume val print_lmbuffer_u8 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt8.t r s l) : StBuf unit b assume val print_lmbuffer_u16 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt16.t r s l) : StBuf unit b assume val print_lmbuffer_u32 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt32.t r s l) : StBuf unit b assume val print_lmbuffer_u64 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt64.t r s l) : StBuf unit b assume val print_lmbuffer_i8 (l:_) (#r:_) (#s:_) (b:lmbuffer Int8.t r s l) : StBuf unit b assume val print_lmbuffer_i16 (l:_) (#r:_) (#s:_) (b:lmbuffer Int16.t r s l) : StBuf unit b assume val print_lmbuffer_i32 (l:_) (#r:_) (#s:_) (b:lmbuffer Int32.t r s l) : StBuf unit b assume val print_lmbuffer_i64 (l:_) (#r:_) (#s:_) (b:lmbuffer Int64.t r s l) : StBuf unit b /// An attribute to control reduction noextract irreducible let __reduce__ = unit /// Base types supported so far noextract type base_typ = | Bool | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 /// Argument types are base types and arrays thereof /// Or polymorphic arguments specified by "%a" noextract type arg = | Base of base_typ | Array of base_typ | Any /// Interpreting a `base_typ` as a type [@@__reduce__] noextract let base_typ_as_type (b:base_typ) : Type0 = match b with | Bool -> bool | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t /// `fragment`: A format string is parsed into a list of fragments of /// string literals and other arguments that need to be spliced in /// (interpolated) noextract type fragment = | Frag of string | Interpolate of arg noextract let fragments = list fragment /// `parse_format s`: /// Parses a list of characters in a format string into a list of fragments /// Or None, in case the format string is invalid [@@__reduce__] noextract inline_for_extraction let rec parse_format (s:list char) : Tot (option fragments) (decreases (L.length s)) = let add_dir (d:arg) (ods : option fragments) = match ods with | None -> None | Some ds -> Some (Interpolate d::ds) in let head_buffer (ods:option fragments) = match ods with | Some (Interpolate (Base t) :: rest) -> Some (Interpolate (Array t) :: rest) | _ -> None in let cons_frag (c:char) (ods:option fragments) = match ods with | Some (Frag s::rest) -> Some (Frag (string_of_list (c :: list_of_string s)) :: rest) | Some rest -> Some (Frag (string_of_list [c]) :: rest) | _ -> None in match s with | [] -> Some [] | ['%'] -> None // %a... polymorphic arguments and preceded by their printers | '%' :: 'a' :: s' -> add_dir Any (parse_format s') // %x... arrays of base types | '%' :: 'x' :: s' -> head_buffer (parse_format ('%' :: s')) // %u ... Unsigned integers | '%' :: 'u' :: s' -> begin match s' with | 'y' :: s'' -> add_dir (Base U8) (parse_format s'') | 's' :: s'' -> add_dir (Base U16) (parse_format s'') | 'l' :: s'' -> add_dir (Base U32) (parse_format s'') | 'L' :: s'' -> add_dir (Base U64) (parse_format s'') | _ -> None end | '%' :: c :: s' -> begin match c with | '%' -> cons_frag '%' (parse_format s') | 'b' -> add_dir (Base Bool) (parse_format s') | 'c' -> add_dir (Base Char) (parse_format s') | 's' -> add_dir (Base String) (parse_format s') | 'y' -> add_dir (Base I8) (parse_format s') | 'i' -> add_dir (Base I16) (parse_format s') | 'l' -> add_dir (Base I32) (parse_format s') | 'L' -> add_dir (Base I64) (parse_format s') | _ -> None end | c :: s' -> cons_frag c (parse_format s') /// `parse_format_string`: a wrapper around `parse_format` [@@__reduce__] noextract inline_for_extraction let parse_format_string (s:string) : option fragments = parse_format (list_of_string s) /// `lift a` lifts the type `a` to a higher universe noextract type lift (a:Type u#a) : Type u#(max a b) = | Lift : a -> lift a /// `done` is a `unit` in universe 1 noextract let done : lift unit = Lift u#0 u#1 () /// `arg_t`: interpreting an argument as a type /// (in universe 1) since it is polymorphic in the preorders of a buffer /// GM: Somehow, this needs to be a `let rec` (even if it not really recursive) /// or print_frags fails to verify. I don't know why; the generated /// VC and its encoding seem identical (modulo hash consing in the /// latter). [@@__reduce__] noextract let rec arg_t (a:arg) : Type u#1 = match a with | Base t -> lift (base_typ_as_type t) | Array t -> (l:UInt32.t & r:_ & s:_ & lmbuffer (base_typ_as_type t) r s l) | Any -> (a:Type0 & (a -> StTrivial unit) & a) /// `frag_t`: a fragment is either a string literal or a argument to be interpolated noextract let frag_t = either string (a:arg & arg_t a) /// `live_frags h l` is a liveness predicate on all the buffers in `l` [@@__reduce__] noextract let rec live_frags (h:_) (l:list frag_t) : prop = match l with | [] -> True | Inl _ :: rest -> live_frags h rest | Inr a :: rest -> (match a with | (| Base _, _ |) -> live_frags h rest | (| Any, _ |) -> live_frags h rest | (| Array _, (| _, _, _, b |) |) -> LB.live h b /\ live_frags h rest) /// `interpret_frags` interprets a list of fragments as a Low* function type /// Note `l` is the fragments in L-to-R order (i.e., parsing order) /// `acc` accumulates the fragment values in reverse order [@@__reduce__] noextract let rec interpret_frags (l:fragments) (acc:list frag_t) : Type u#1 = match l with | [] -> // Always a dummy argument at the end // Ensures that all cases of this match // have the same universe, i.e., u#1 lift u#0 u#1 unit -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) | Interpolate (Base t) :: args -> // Base types are simple: we just take one more argument x:base_typ_as_type t -> interpret_frags args (Inr (| Base t, Lift x |) :: acc) | Interpolate (Array t) :: args -> // Arrays are implicitly polymorphic in their preorders `r` and `s` // which is what forces us to be in universe 1 // Note, the length `l` is explicit l:UInt32.t -> #r:LB.srel (base_typ_as_type t) -> #s:LB.srel (base_typ_as_type t) -> b:lmbuffer (base_typ_as_type t) r s l -> interpret_frags args (Inr (| Array t, (| l, r, s, b |) |) :: acc) | Interpolate Any :: args -> #a:Type0 -> p:(a -> StTrivial unit) -> x:a -> interpret_frags args (Inr (| Any, (| a, p, x |) |) :: acc) | Frag s :: args -> // Literal fragments do not incur an additional argument // We just accumulate them and recur interpret_frags args (Inl s :: acc) /// `normal` A normalization marker with very specific steps enabled noextract unfold let normal (#a:Type) (x:a) : a = FStar.Pervasives.norm [iota; zeta; delta_attr [`%__reduce__; `%BigOps.__reduce__]; delta_only [`%Base?; `%Array?; `%Some?; `%Some?.v; `%list_of_string]; primops; simplify] x /// `coerce`: A utility to trigger extensional equality of types noextract let coerce (x:'a{'a == 'b}) : 'b = x /// `fragment_printer`: The type of a printer of fragments noextract let fragment_printer = (acc:list frag_t) -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) /// `print_frags`: Having accumulated all the pieces of a format /// string and the arguments to the printed (i.e., the `list frag_t`), /// this function does the actual work of printing them all using the /// primitive printers noextract inline_for_extraction let rec print_frags (acc:list frag_t) : Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) = match acc with | [] -> () | hd::tl -> print_frags tl; (match hd with | Inl s -> print_string s | Inr (| Base t, Lift value |) -> (match t with | Bool -> print_bool value | Char -> print_char value | String -> print_string value | U8 -> print_u8 value | U16 -> print_u16 value | U32 -> print_u32 value | U64 -> print_u64 value | I8 -> print_i8 value | I16 -> print_i16 value | I32 -> print_i32 value | I64 -> print_i64 value) | Inr (| Array t, (| l, r, s, value |) |) -> (match t with | Bool -> print_lmbuffer_bool l value | Char -> print_lmbuffer_char l value | String -> print_lmbuffer_string l value | U8 -> print_lmbuffer_u8 l value | U16 -> print_lmbuffer_u16 l value | U32 -> print_lmbuffer_u32 l value | U64 -> print_lmbuffer_u64 l value | I8 -> print_lmbuffer_i8 l value | I16 -> print_lmbuffer_i16 l value | I32 -> print_lmbuffer_i32 l value | I64 -> print_lmbuffer_i64 l value) | Inr (| Any, (| _, printer, value |) |) -> printer value) [@@__reduce__] let no_inst #a (#b:a -> Type) (f: (#x:a -> b x)) : unit -> #x:a -> b x = fun () -> f [@@__reduce__] let elim_unit_arrow #t (f:unit -> t) : t = f () // let test2 (f: (#a:Type -> a -> a)) : id_t 0 = test f () // let coerce #a (#b: (a -> Type)) ($f: (#x:a -> b x)) (t:Type{norm t == (#x:a -> b x)}) /// `aux frags acc`: This is the main workhorse which interprets a /// parsed format string (`frags`) as a variadic, stateful function [@@__reduce__] noextract inline_for_extraction let rec aux (frags:fragments) (acc:list frag_t) (fp: fragment_printer) : interpret_frags frags acc = match frags with | [] -> let f (l:lift u#0 u#1 unit) : Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) = fp acc in (f <: interpret_frags [] acc) | Frag s :: rest -> coerce (aux rest (Inl s :: acc) fp) | Interpolate (Base t) :: args -> let f (x:base_typ_as_type t) : interpret_frags args (Inr (| Base t, Lift x |) :: acc) = aux args (Inr (| Base t, Lift x |) :: acc) fp in f | Interpolate (Array t) :: rest -> let f : l:UInt32.t -> #r:LB.srel (base_typ_as_type t) -> #s:LB.srel (base_typ_as_type t) -> b:lmbuffer (base_typ_as_type t) r s l -> interpret_frags rest (Inr (| Array t, (| l, r, s, b |) |) :: acc) = fun l #r #s b -> aux rest (Inr (| Array t, (| l, r, s, b |) |) :: acc) fp in f <: interpret_frags (Interpolate (Array t) :: rest) acc | Interpolate Any :: rest -> let f : unit -> #a:Type -> p:(a -> StTrivial unit) -> x:a -> interpret_frags rest (Inr (| Any, (| a, p, x |) |) :: acc) = fun () #a p x -> aux rest (Inr (| Any, (| a, p, x |) |) :: acc) fp in elim_unit_arrow (no_inst (f ()) <: (unit -> interpret_frags (Interpolate Any :: rest) acc)) /// `format_string` : A valid format string is one that can be successfully parsed [@@__reduce__] noextract let format_string = s:string{normal #bool (Some? (parse_format_string s))} /// `interpret_format_string` parses a string into fragments and then /// interprets it as a type [@@__reduce__] noextract let interpret_format_string (s:format_string) : Type = interpret_frags (Some?.v (parse_format_string s)) [] /// `printf'`: Almost there ... this has a variadic type /// and calls the actual printers for all its arguments. /// /// Note, the `normalize_term` in its body is crucial. It's what /// allows the term to be specialized at extraction time. noextract inline_for_extraction let printf' (s:format_string) : interpret_format_string s = normalize_term (match parse_format_string s with | Some frags -> aux frags [] print_frags) /// `intro_normal_f`: a technical gadget to introduce /// implicit normalization in the domain and co-domain of a function type noextract inline_for_extraction let intro_normal_f (#a:Type) (b: (a -> Type)) (f:(x:a -> b x))
false
false
LowStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val intro_normal_f (#a: Type) (b: (a -> Type)) (f: (x: a -> b x)) : (x: (normal a) -> normal (b x))
[]
LowStar.Printf.intro_normal_f
{ "file_name": "ulib/LowStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
b: (_: a -> Type) -> f: (x: a -> b x) -> x: LowStar.Printf.normal a -> LowStar.Printf.normal (b x)
{ "end_col": 5, "end_line": 470, "start_col": 4, "start_line": 470 }
Prims.Tot
val interpret_frags (l: fragments) (acc: list frag_t) : Type u#1
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "LB" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec interpret_frags (l:fragments) (acc:list frag_t) : Type u#1 = match l with | [] -> // Always a dummy argument at the end // Ensures that all cases of this match // have the same universe, i.e., u#1 lift u#0 u#1 unit -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) | Interpolate (Base t) :: args -> // Base types are simple: we just take one more argument x:base_typ_as_type t -> interpret_frags args (Inr (| Base t, Lift x |) :: acc) | Interpolate (Array t) :: args -> // Arrays are implicitly polymorphic in their preorders `r` and `s` // which is what forces us to be in universe 1 // Note, the length `l` is explicit l:UInt32.t -> #r:LB.srel (base_typ_as_type t) -> #s:LB.srel (base_typ_as_type t) -> b:lmbuffer (base_typ_as_type t) r s l -> interpret_frags args (Inr (| Array t, (| l, r, s, b |) |) :: acc) | Interpolate Any :: args -> #a:Type0 -> p:(a -> StTrivial unit) -> x:a -> interpret_frags args (Inr (| Any, (| a, p, x |) |) :: acc) | Frag s :: args -> // Literal fragments do not incur an additional argument // We just accumulate them and recur interpret_frags args (Inl s :: acc)
val interpret_frags (l: fragments) (acc: list frag_t) : Type u#1 let rec interpret_frags (l: fragments) (acc: list frag_t) : Type u#1 =
false
null
false
match l with | [] -> lift u#0 u#1 unit -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) | Interpolate (Base t) :: args -> x: base_typ_as_type t -> interpret_frags args (Inr (| Base t, Lift x |) :: acc) | Interpolate (Array t) :: args -> l: UInt32.t -> #r: LB.srel (base_typ_as_type t) -> #s: LB.srel (base_typ_as_type t) -> b: lmbuffer (base_typ_as_type t) r s l -> interpret_frags args (Inr (| Array t, (| l, r, s, b |) |) :: acc) | Interpolate Any :: args -> #a: Type0 -> p: (a -> StTrivial unit) -> x: a -> interpret_frags args (Inr (| Any, (| a, p, x |) |) :: acc) | Frag s :: args -> interpret_frags args (Inl s :: acc)
{ "checked_file": "LowStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked", "FStar.BigOps.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Printf.fst" }
[ "total" ]
[ "LowStar.Printf.fragments", "Prims.list", "LowStar.Printf.frag_t", "LowStar.Printf.lift", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "LowStar.Printf.live_frags", "Prims.eq2", "LowStar.Printf.base_typ", "LowStar.Printf.fragment", "LowStar.Printf.base_typ_as_type", "LowStar.Printf.interpret_frags", "Prims.Cons", "FStar.Pervasives.Inr", "Prims.string", "Prims.dtuple2", "LowStar.Printf.arg", "LowStar.Printf.arg_t", "Prims.Mkdtuple2", "LowStar.Printf.Base", "LowStar.Printf.Lift", "FStar.UInt32.t", "LowStar.Monotonic.Buffer.srel", "LowStar.Printf.lmbuffer", "LowStar.Printf.Array", "FStar.Pervasives.Mkdtuple4", "LowStar.Printf.Any", "FStar.Pervasives.Mkdtuple3", "FStar.Pervasives.Inl" ]
[]
(* 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 LowStar.Printf /// This module provides imperative printing functions for several /// primitive Low* types, including /// -- booleans (%b) /// -- characters (%c) /// -- strings (%s) /// -- machine integers /// (UInt8.t as %uy, UInt16.t as %us, UInt32.t as %ul, and UInt64.t as %uL; /// Int8.t as %y, Int16.t as %i, Int32.t as %l , and Int64.t as %L) /// -- and arrays (aka buffers) of these base types formatted /// as %xN, where N is the format specifier for the array element type /// e.g., %xuy for buffers of UInt8.t /// The main function of this module is `printf` /// There are a few main differences relative to C printf /// -- The format specifiers are different (see above) /// /// -- For technical reasons explained below, an extra dummy /// argument `done` has to be provided at the end for the /// computation to have any effect. /// /// E.g., one must write /// `printf "%b %c" true 'c' done` /// rather than just /// `printf "%b %c" true 'c'` /// /// -- When printing arrays, two arguments must be passed; the /// length of the array fragment to be formatted and the array /// itself /// /// -- When extracted, rather than producing a C `printf` (which /// does not, e.g., support printing of dynamically sized /// arrays), our `printf` is specialized to a sequence of calls /// to primitive printers for each supported type /// /// Before diving into the technical details of how this module works, /// you might want to see a sample usage at the very end of this file. open FStar.Char open FStar.String open FStar.HyperStack.ST module L = FStar.List.Tot module LB = LowStar.Monotonic.Buffer /// `lmbuffer a r s l` is /// - a monotonic buffer of `a` /// - governed by preorders `r` and `s` /// - with length `l` let lmbuffer a r s l = b:LB.mbuffer a r s{ LB.len b == l } /// `StTrivial`: A effect abbreviation for a stateful computation /// with no precondition, and which does not change the state effect StTrivial (a:Type) = Stack a (requires fun h -> True) (ensures fun h0 _ h1 -> h0==h1) /// `StBuf a b`: A effect abbreviation for a stateful computation /// that may read `b` does not change the state effect StBuf (a:Type) #t #r #s #l (b:lmbuffer t r s l) = Stack a (requires fun h -> LB.live h b) (ensures (fun h0 _ h1 -> h0 == h1)) /// Primitive printers for all the types supported by this module assume val print_string: string -> StTrivial unit assume val print_char : char -> StTrivial unit assume val print_u8 : UInt8.t -> StTrivial unit assume val print_u16 : UInt16.t -> StTrivial unit assume val print_u32 : UInt32.t -> StTrivial unit assume val print_u64 : UInt64.t -> StTrivial unit assume val print_i8 : Int8.t -> StTrivial unit assume val print_i16 : Int16.t -> StTrivial unit assume val print_i32 : Int32.t -> StTrivial unit assume val print_i64 : Int64.t -> StTrivial unit assume val print_bool : bool -> StTrivial unit assume val print_lmbuffer_bool (l:_) (#r:_) (#s:_) (b:lmbuffer bool r s l) : StBuf unit b assume val print_lmbuffer_char (l:_) (#r:_) (#s:_) (b:lmbuffer char r s l) : StBuf unit b assume val print_lmbuffer_string (l:_) (#r:_) (#s:_) (b:lmbuffer string r s l) : StBuf unit b assume val print_lmbuffer_u8 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt8.t r s l) : StBuf unit b assume val print_lmbuffer_u16 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt16.t r s l) : StBuf unit b assume val print_lmbuffer_u32 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt32.t r s l) : StBuf unit b assume val print_lmbuffer_u64 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt64.t r s l) : StBuf unit b assume val print_lmbuffer_i8 (l:_) (#r:_) (#s:_) (b:lmbuffer Int8.t r s l) : StBuf unit b assume val print_lmbuffer_i16 (l:_) (#r:_) (#s:_) (b:lmbuffer Int16.t r s l) : StBuf unit b assume val print_lmbuffer_i32 (l:_) (#r:_) (#s:_) (b:lmbuffer Int32.t r s l) : StBuf unit b assume val print_lmbuffer_i64 (l:_) (#r:_) (#s:_) (b:lmbuffer Int64.t r s l) : StBuf unit b /// An attribute to control reduction noextract irreducible let __reduce__ = unit /// Base types supported so far noextract type base_typ = | Bool | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 /// Argument types are base types and arrays thereof /// Or polymorphic arguments specified by "%a" noextract type arg = | Base of base_typ | Array of base_typ | Any /// Interpreting a `base_typ` as a type [@@__reduce__] noextract let base_typ_as_type (b:base_typ) : Type0 = match b with | Bool -> bool | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t /// `fragment`: A format string is parsed into a list of fragments of /// string literals and other arguments that need to be spliced in /// (interpolated) noextract type fragment = | Frag of string | Interpolate of arg noextract let fragments = list fragment /// `parse_format s`: /// Parses a list of characters in a format string into a list of fragments /// Or None, in case the format string is invalid [@@__reduce__] noextract inline_for_extraction let rec parse_format (s:list char) : Tot (option fragments) (decreases (L.length s)) = let add_dir (d:arg) (ods : option fragments) = match ods with | None -> None | Some ds -> Some (Interpolate d::ds) in let head_buffer (ods:option fragments) = match ods with | Some (Interpolate (Base t) :: rest) -> Some (Interpolate (Array t) :: rest) | _ -> None in let cons_frag (c:char) (ods:option fragments) = match ods with | Some (Frag s::rest) -> Some (Frag (string_of_list (c :: list_of_string s)) :: rest) | Some rest -> Some (Frag (string_of_list [c]) :: rest) | _ -> None in match s with | [] -> Some [] | ['%'] -> None // %a... polymorphic arguments and preceded by their printers | '%' :: 'a' :: s' -> add_dir Any (parse_format s') // %x... arrays of base types | '%' :: 'x' :: s' -> head_buffer (parse_format ('%' :: s')) // %u ... Unsigned integers | '%' :: 'u' :: s' -> begin match s' with | 'y' :: s'' -> add_dir (Base U8) (parse_format s'') | 's' :: s'' -> add_dir (Base U16) (parse_format s'') | 'l' :: s'' -> add_dir (Base U32) (parse_format s'') | 'L' :: s'' -> add_dir (Base U64) (parse_format s'') | _ -> None end | '%' :: c :: s' -> begin match c with | '%' -> cons_frag '%' (parse_format s') | 'b' -> add_dir (Base Bool) (parse_format s') | 'c' -> add_dir (Base Char) (parse_format s') | 's' -> add_dir (Base String) (parse_format s') | 'y' -> add_dir (Base I8) (parse_format s') | 'i' -> add_dir (Base I16) (parse_format s') | 'l' -> add_dir (Base I32) (parse_format s') | 'L' -> add_dir (Base I64) (parse_format s') | _ -> None end | c :: s' -> cons_frag c (parse_format s') /// `parse_format_string`: a wrapper around `parse_format` [@@__reduce__] noextract inline_for_extraction let parse_format_string (s:string) : option fragments = parse_format (list_of_string s) /// `lift a` lifts the type `a` to a higher universe noextract type lift (a:Type u#a) : Type u#(max a b) = | Lift : a -> lift a /// `done` is a `unit` in universe 1 noextract let done : lift unit = Lift u#0 u#1 () /// `arg_t`: interpreting an argument as a type /// (in universe 1) since it is polymorphic in the preorders of a buffer /// GM: Somehow, this needs to be a `let rec` (even if it not really recursive) /// or print_frags fails to verify. I don't know why; the generated /// VC and its encoding seem identical (modulo hash consing in the /// latter). [@@__reduce__] noextract let rec arg_t (a:arg) : Type u#1 = match a with | Base t -> lift (base_typ_as_type t) | Array t -> (l:UInt32.t & r:_ & s:_ & lmbuffer (base_typ_as_type t) r s l) | Any -> (a:Type0 & (a -> StTrivial unit) & a) /// `frag_t`: a fragment is either a string literal or a argument to be interpolated noextract let frag_t = either string (a:arg & arg_t a) /// `live_frags h l` is a liveness predicate on all the buffers in `l` [@@__reduce__] noextract let rec live_frags (h:_) (l:list frag_t) : prop = match l with | [] -> True | Inl _ :: rest -> live_frags h rest | Inr a :: rest -> (match a with | (| Base _, _ |) -> live_frags h rest | (| Any, _ |) -> live_frags h rest | (| Array _, (| _, _, _, b |) |) -> LB.live h b /\ live_frags h rest) /// `interpret_frags` interprets a list of fragments as a Low* function type /// Note `l` is the fragments in L-to-R order (i.e., parsing order) /// `acc` accumulates the fragment values in reverse order [@@__reduce__] noextract
false
true
LowStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val interpret_frags (l: fragments) (acc: list frag_t) : Type u#1
[ "recursion" ]
LowStar.Printf.interpret_frags
{ "file_name": "ulib/LowStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: LowStar.Printf.fragments -> acc: Prims.list LowStar.Printf.frag_t -> Type
{ "end_col": 39, "end_line": 317, "start_col": 2, "start_line": 283 }
Prims.Tot
val aux (frags: fragments) (acc: list frag_t) (fp: fragment_printer) : interpret_frags frags acc
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "LB" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec aux (frags:fragments) (acc:list frag_t) (fp: fragment_printer) : interpret_frags frags acc = match frags with | [] -> let f (l:lift u#0 u#1 unit) : Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) = fp acc in (f <: interpret_frags [] acc) | Frag s :: rest -> coerce (aux rest (Inl s :: acc) fp) | Interpolate (Base t) :: args -> let f (x:base_typ_as_type t) : interpret_frags args (Inr (| Base t, Lift x |) :: acc) = aux args (Inr (| Base t, Lift x |) :: acc) fp in f | Interpolate (Array t) :: rest -> let f : l:UInt32.t -> #r:LB.srel (base_typ_as_type t) -> #s:LB.srel (base_typ_as_type t) -> b:lmbuffer (base_typ_as_type t) r s l -> interpret_frags rest (Inr (| Array t, (| l, r, s, b |) |) :: acc) = fun l #r #s b -> aux rest (Inr (| Array t, (| l, r, s, b |) |) :: acc) fp in f <: interpret_frags (Interpolate (Array t) :: rest) acc | Interpolate Any :: rest -> let f : unit -> #a:Type -> p:(a -> StTrivial unit) -> x:a -> interpret_frags rest (Inr (| Any, (| a, p, x |) |) :: acc) = fun () #a p x -> aux rest (Inr (| Any, (| a, p, x |) |) :: acc) fp in elim_unit_arrow (no_inst (f ()) <: (unit -> interpret_frags (Interpolate Any :: rest) acc))
val aux (frags: fragments) (acc: list frag_t) (fp: fragment_printer) : interpret_frags frags acc let rec aux (frags: fragments) (acc: list frag_t) (fp: fragment_printer) : interpret_frags frags acc =
false
null
false
match frags with | [] -> let f (l: lift u#0 u#1 unit) : Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) = fp acc in (f <: interpret_frags [] acc) | Frag s :: rest -> coerce (aux rest (Inl s :: acc) fp) | Interpolate (Base t) :: args -> let f (x: base_typ_as_type t) : interpret_frags args (Inr (| Base t, Lift x |) :: acc) = aux args (Inr (| Base t, Lift x |) :: acc) fp in f | Interpolate (Array t) :: rest -> let f: l: UInt32.t -> #r: LB.srel (base_typ_as_type t) -> #s: LB.srel (base_typ_as_type t) -> b: lmbuffer (base_typ_as_type t) r s l -> interpret_frags rest (Inr (| Array t, (| l, r, s, b |) |) :: acc) = fun l #r #s b -> aux rest (Inr (| Array t, (| l, r, s, b |) |) :: acc) fp in f <: interpret_frags (Interpolate (Array t) :: rest) acc | Interpolate Any :: rest -> let f: unit -> #a: Type -> p: (a -> StTrivial unit) -> x: a -> interpret_frags rest (Inr (| Any, (| a, p, x |) |) :: acc) = fun () #a p x -> aux rest (Inr (| Any, (| a, p, x |) |) :: acc) fp in elim_unit_arrow (no_inst (f ()) <: (unit -> interpret_frags (Interpolate Any :: rest) acc))
{ "checked_file": "LowStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked", "FStar.BigOps.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Printf.fst" }
[ "total" ]
[ "LowStar.Printf.fragments", "Prims.list", "LowStar.Printf.frag_t", "LowStar.Printf.fragment_printer", "LowStar.Printf.interpret_frags", "Prims.Nil", "LowStar.Printf.fragment", "LowStar.Printf.lift", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "LowStar.Printf.live_frags", "Prims.eq2", "Prims.string", "LowStar.Printf.coerce", "Prims.Cons", "FStar.Pervasives.Inl", "Prims.dtuple2", "LowStar.Printf.arg", "LowStar.Printf.arg_t", "LowStar.Printf.aux", "LowStar.Printf.base_typ", "LowStar.Printf.base_typ_as_type", "FStar.Pervasives.Inr", "Prims.Mkdtuple2", "LowStar.Printf.Base", "LowStar.Printf.Lift", "LowStar.Printf.Interpolate", "LowStar.Printf.Array", "FStar.UInt32.t", "FStar.Preorder.preorder", "FStar.Seq.Base.seq", "LowStar.Printf.lmbuffer", "FStar.Pervasives.Mkdtuple4", "LowStar.Printf.elim_unit_arrow", "LowStar.Printf.no_inst", "LowStar.Printf.Any", "FStar.Pervasives.Mkdtuple3" ]
[]
(* 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 LowStar.Printf /// This module provides imperative printing functions for several /// primitive Low* types, including /// -- booleans (%b) /// -- characters (%c) /// -- strings (%s) /// -- machine integers /// (UInt8.t as %uy, UInt16.t as %us, UInt32.t as %ul, and UInt64.t as %uL; /// Int8.t as %y, Int16.t as %i, Int32.t as %l , and Int64.t as %L) /// -- and arrays (aka buffers) of these base types formatted /// as %xN, where N is the format specifier for the array element type /// e.g., %xuy for buffers of UInt8.t /// The main function of this module is `printf` /// There are a few main differences relative to C printf /// -- The format specifiers are different (see above) /// /// -- For technical reasons explained below, an extra dummy /// argument `done` has to be provided at the end for the /// computation to have any effect. /// /// E.g., one must write /// `printf "%b %c" true 'c' done` /// rather than just /// `printf "%b %c" true 'c'` /// /// -- When printing arrays, two arguments must be passed; the /// length of the array fragment to be formatted and the array /// itself /// /// -- When extracted, rather than producing a C `printf` (which /// does not, e.g., support printing of dynamically sized /// arrays), our `printf` is specialized to a sequence of calls /// to primitive printers for each supported type /// /// Before diving into the technical details of how this module works, /// you might want to see a sample usage at the very end of this file. open FStar.Char open FStar.String open FStar.HyperStack.ST module L = FStar.List.Tot module LB = LowStar.Monotonic.Buffer /// `lmbuffer a r s l` is /// - a monotonic buffer of `a` /// - governed by preorders `r` and `s` /// - with length `l` let lmbuffer a r s l = b:LB.mbuffer a r s{ LB.len b == l } /// `StTrivial`: A effect abbreviation for a stateful computation /// with no precondition, and which does not change the state effect StTrivial (a:Type) = Stack a (requires fun h -> True) (ensures fun h0 _ h1 -> h0==h1) /// `StBuf a b`: A effect abbreviation for a stateful computation /// that may read `b` does not change the state effect StBuf (a:Type) #t #r #s #l (b:lmbuffer t r s l) = Stack a (requires fun h -> LB.live h b) (ensures (fun h0 _ h1 -> h0 == h1)) /// Primitive printers for all the types supported by this module assume val print_string: string -> StTrivial unit assume val print_char : char -> StTrivial unit assume val print_u8 : UInt8.t -> StTrivial unit assume val print_u16 : UInt16.t -> StTrivial unit assume val print_u32 : UInt32.t -> StTrivial unit assume val print_u64 : UInt64.t -> StTrivial unit assume val print_i8 : Int8.t -> StTrivial unit assume val print_i16 : Int16.t -> StTrivial unit assume val print_i32 : Int32.t -> StTrivial unit assume val print_i64 : Int64.t -> StTrivial unit assume val print_bool : bool -> StTrivial unit assume val print_lmbuffer_bool (l:_) (#r:_) (#s:_) (b:lmbuffer bool r s l) : StBuf unit b assume val print_lmbuffer_char (l:_) (#r:_) (#s:_) (b:lmbuffer char r s l) : StBuf unit b assume val print_lmbuffer_string (l:_) (#r:_) (#s:_) (b:lmbuffer string r s l) : StBuf unit b assume val print_lmbuffer_u8 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt8.t r s l) : StBuf unit b assume val print_lmbuffer_u16 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt16.t r s l) : StBuf unit b assume val print_lmbuffer_u32 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt32.t r s l) : StBuf unit b assume val print_lmbuffer_u64 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt64.t r s l) : StBuf unit b assume val print_lmbuffer_i8 (l:_) (#r:_) (#s:_) (b:lmbuffer Int8.t r s l) : StBuf unit b assume val print_lmbuffer_i16 (l:_) (#r:_) (#s:_) (b:lmbuffer Int16.t r s l) : StBuf unit b assume val print_lmbuffer_i32 (l:_) (#r:_) (#s:_) (b:lmbuffer Int32.t r s l) : StBuf unit b assume val print_lmbuffer_i64 (l:_) (#r:_) (#s:_) (b:lmbuffer Int64.t r s l) : StBuf unit b /// An attribute to control reduction noextract irreducible let __reduce__ = unit /// Base types supported so far noextract type base_typ = | Bool | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 /// Argument types are base types and arrays thereof /// Or polymorphic arguments specified by "%a" noextract type arg = | Base of base_typ | Array of base_typ | Any /// Interpreting a `base_typ` as a type [@@__reduce__] noextract let base_typ_as_type (b:base_typ) : Type0 = match b with | Bool -> bool | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t /// `fragment`: A format string is parsed into a list of fragments of /// string literals and other arguments that need to be spliced in /// (interpolated) noextract type fragment = | Frag of string | Interpolate of arg noextract let fragments = list fragment /// `parse_format s`: /// Parses a list of characters in a format string into a list of fragments /// Or None, in case the format string is invalid [@@__reduce__] noextract inline_for_extraction let rec parse_format (s:list char) : Tot (option fragments) (decreases (L.length s)) = let add_dir (d:arg) (ods : option fragments) = match ods with | None -> None | Some ds -> Some (Interpolate d::ds) in let head_buffer (ods:option fragments) = match ods with | Some (Interpolate (Base t) :: rest) -> Some (Interpolate (Array t) :: rest) | _ -> None in let cons_frag (c:char) (ods:option fragments) = match ods with | Some (Frag s::rest) -> Some (Frag (string_of_list (c :: list_of_string s)) :: rest) | Some rest -> Some (Frag (string_of_list [c]) :: rest) | _ -> None in match s with | [] -> Some [] | ['%'] -> None // %a... polymorphic arguments and preceded by their printers | '%' :: 'a' :: s' -> add_dir Any (parse_format s') // %x... arrays of base types | '%' :: 'x' :: s' -> head_buffer (parse_format ('%' :: s')) // %u ... Unsigned integers | '%' :: 'u' :: s' -> begin match s' with | 'y' :: s'' -> add_dir (Base U8) (parse_format s'') | 's' :: s'' -> add_dir (Base U16) (parse_format s'') | 'l' :: s'' -> add_dir (Base U32) (parse_format s'') | 'L' :: s'' -> add_dir (Base U64) (parse_format s'') | _ -> None end | '%' :: c :: s' -> begin match c with | '%' -> cons_frag '%' (parse_format s') | 'b' -> add_dir (Base Bool) (parse_format s') | 'c' -> add_dir (Base Char) (parse_format s') | 's' -> add_dir (Base String) (parse_format s') | 'y' -> add_dir (Base I8) (parse_format s') | 'i' -> add_dir (Base I16) (parse_format s') | 'l' -> add_dir (Base I32) (parse_format s') | 'L' -> add_dir (Base I64) (parse_format s') | _ -> None end | c :: s' -> cons_frag c (parse_format s') /// `parse_format_string`: a wrapper around `parse_format` [@@__reduce__] noextract inline_for_extraction let parse_format_string (s:string) : option fragments = parse_format (list_of_string s) /// `lift a` lifts the type `a` to a higher universe noextract type lift (a:Type u#a) : Type u#(max a b) = | Lift : a -> lift a /// `done` is a `unit` in universe 1 noextract let done : lift unit = Lift u#0 u#1 () /// `arg_t`: interpreting an argument as a type /// (in universe 1) since it is polymorphic in the preorders of a buffer /// GM: Somehow, this needs to be a `let rec` (even if it not really recursive) /// or print_frags fails to verify. I don't know why; the generated /// VC and its encoding seem identical (modulo hash consing in the /// latter). [@@__reduce__] noextract let rec arg_t (a:arg) : Type u#1 = match a with | Base t -> lift (base_typ_as_type t) | Array t -> (l:UInt32.t & r:_ & s:_ & lmbuffer (base_typ_as_type t) r s l) | Any -> (a:Type0 & (a -> StTrivial unit) & a) /// `frag_t`: a fragment is either a string literal or a argument to be interpolated noextract let frag_t = either string (a:arg & arg_t a) /// `live_frags h l` is a liveness predicate on all the buffers in `l` [@@__reduce__] noextract let rec live_frags (h:_) (l:list frag_t) : prop = match l with | [] -> True | Inl _ :: rest -> live_frags h rest | Inr a :: rest -> (match a with | (| Base _, _ |) -> live_frags h rest | (| Any, _ |) -> live_frags h rest | (| Array _, (| _, _, _, b |) |) -> LB.live h b /\ live_frags h rest) /// `interpret_frags` interprets a list of fragments as a Low* function type /// Note `l` is the fragments in L-to-R order (i.e., parsing order) /// `acc` accumulates the fragment values in reverse order [@@__reduce__] noextract let rec interpret_frags (l:fragments) (acc:list frag_t) : Type u#1 = match l with | [] -> // Always a dummy argument at the end // Ensures that all cases of this match // have the same universe, i.e., u#1 lift u#0 u#1 unit -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) | Interpolate (Base t) :: args -> // Base types are simple: we just take one more argument x:base_typ_as_type t -> interpret_frags args (Inr (| Base t, Lift x |) :: acc) | Interpolate (Array t) :: args -> // Arrays are implicitly polymorphic in their preorders `r` and `s` // which is what forces us to be in universe 1 // Note, the length `l` is explicit l:UInt32.t -> #r:LB.srel (base_typ_as_type t) -> #s:LB.srel (base_typ_as_type t) -> b:lmbuffer (base_typ_as_type t) r s l -> interpret_frags args (Inr (| Array t, (| l, r, s, b |) |) :: acc) | Interpolate Any :: args -> #a:Type0 -> p:(a -> StTrivial unit) -> x:a -> interpret_frags args (Inr (| Any, (| a, p, x |) |) :: acc) | Frag s :: args -> // Literal fragments do not incur an additional argument // We just accumulate them and recur interpret_frags args (Inl s :: acc) /// `normal` A normalization marker with very specific steps enabled noextract unfold let normal (#a:Type) (x:a) : a = FStar.Pervasives.norm [iota; zeta; delta_attr [`%__reduce__; `%BigOps.__reduce__]; delta_only [`%Base?; `%Array?; `%Some?; `%Some?.v; `%list_of_string]; primops; simplify] x /// `coerce`: A utility to trigger extensional equality of types noextract let coerce (x:'a{'a == 'b}) : 'b = x /// `fragment_printer`: The type of a printer of fragments noextract let fragment_printer = (acc:list frag_t) -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) /// `print_frags`: Having accumulated all the pieces of a format /// string and the arguments to the printed (i.e., the `list frag_t`), /// this function does the actual work of printing them all using the /// primitive printers noextract inline_for_extraction let rec print_frags (acc:list frag_t) : Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) = match acc with | [] -> () | hd::tl -> print_frags tl; (match hd with | Inl s -> print_string s | Inr (| Base t, Lift value |) -> (match t with | Bool -> print_bool value | Char -> print_char value | String -> print_string value | U8 -> print_u8 value | U16 -> print_u16 value | U32 -> print_u32 value | U64 -> print_u64 value | I8 -> print_i8 value | I16 -> print_i16 value | I32 -> print_i32 value | I64 -> print_i64 value) | Inr (| Array t, (| l, r, s, value |) |) -> (match t with | Bool -> print_lmbuffer_bool l value | Char -> print_lmbuffer_char l value | String -> print_lmbuffer_string l value | U8 -> print_lmbuffer_u8 l value | U16 -> print_lmbuffer_u16 l value | U32 -> print_lmbuffer_u32 l value | U64 -> print_lmbuffer_u64 l value | I8 -> print_lmbuffer_i8 l value | I16 -> print_lmbuffer_i16 l value | I32 -> print_lmbuffer_i32 l value | I64 -> print_lmbuffer_i64 l value) | Inr (| Any, (| _, printer, value |) |) -> printer value) [@@__reduce__] let no_inst #a (#b:a -> Type) (f: (#x:a -> b x)) : unit -> #x:a -> b x = fun () -> f [@@__reduce__] let elim_unit_arrow #t (f:unit -> t) : t = f () // let test2 (f: (#a:Type -> a -> a)) : id_t 0 = test f () // let coerce #a (#b: (a -> Type)) ($f: (#x:a -> b x)) (t:Type{norm t == (#x:a -> b x)}) /// `aux frags acc`: This is the main workhorse which interprets a /// parsed format string (`frags`) as a variadic, stateful function [@@__reduce__] noextract inline_for_extraction
false
false
LowStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aux (frags: fragments) (acc: list frag_t) (fp: fragment_printer) : interpret_frags frags acc
[ "recursion" ]
LowStar.Printf.aux
{ "file_name": "ulib/LowStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
frags: LowStar.Printf.fragments -> acc: Prims.list LowStar.Printf.frag_t -> fp: LowStar.Printf.fragment_printer -> LowStar.Printf.interpret_frags frags acc
{ "end_col": 95, "end_line": 440, "start_col": 2, "start_line": 400 }
Prims.Tot
val printf' (s: format_string) : interpret_format_string s
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "LB" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let printf' (s:format_string) : interpret_format_string s = normalize_term (match parse_format_string s with | Some frags -> aux frags [] print_frags)
val printf' (s: format_string) : interpret_format_string s let printf' (s: format_string) : interpret_format_string s =
false
null
false
normalize_term (match parse_format_string s with | Some frags -> aux frags [] print_frags)
{ "checked_file": "LowStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked", "FStar.BigOps.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Printf.fst" }
[ "total" ]
[ "LowStar.Printf.format_string", "FStar.Pervasives.normalize_term", "LowStar.Printf.interpret_format_string", "LowStar.Printf.parse_format_string", "LowStar.Printf.fragments", "LowStar.Printf.aux", "Prims.Nil", "LowStar.Printf.frag_t", "LowStar.Printf.print_frags" ]
[]
(* 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 LowStar.Printf /// This module provides imperative printing functions for several /// primitive Low* types, including /// -- booleans (%b) /// -- characters (%c) /// -- strings (%s) /// -- machine integers /// (UInt8.t as %uy, UInt16.t as %us, UInt32.t as %ul, and UInt64.t as %uL; /// Int8.t as %y, Int16.t as %i, Int32.t as %l , and Int64.t as %L) /// -- and arrays (aka buffers) of these base types formatted /// as %xN, where N is the format specifier for the array element type /// e.g., %xuy for buffers of UInt8.t /// The main function of this module is `printf` /// There are a few main differences relative to C printf /// -- The format specifiers are different (see above) /// /// -- For technical reasons explained below, an extra dummy /// argument `done` has to be provided at the end for the /// computation to have any effect. /// /// E.g., one must write /// `printf "%b %c" true 'c' done` /// rather than just /// `printf "%b %c" true 'c'` /// /// -- When printing arrays, two arguments must be passed; the /// length of the array fragment to be formatted and the array /// itself /// /// -- When extracted, rather than producing a C `printf` (which /// does not, e.g., support printing of dynamically sized /// arrays), our `printf` is specialized to a sequence of calls /// to primitive printers for each supported type /// /// Before diving into the technical details of how this module works, /// you might want to see a sample usage at the very end of this file. open FStar.Char open FStar.String open FStar.HyperStack.ST module L = FStar.List.Tot module LB = LowStar.Monotonic.Buffer /// `lmbuffer a r s l` is /// - a monotonic buffer of `a` /// - governed by preorders `r` and `s` /// - with length `l` let lmbuffer a r s l = b:LB.mbuffer a r s{ LB.len b == l } /// `StTrivial`: A effect abbreviation for a stateful computation /// with no precondition, and which does not change the state effect StTrivial (a:Type) = Stack a (requires fun h -> True) (ensures fun h0 _ h1 -> h0==h1) /// `StBuf a b`: A effect abbreviation for a stateful computation /// that may read `b` does not change the state effect StBuf (a:Type) #t #r #s #l (b:lmbuffer t r s l) = Stack a (requires fun h -> LB.live h b) (ensures (fun h0 _ h1 -> h0 == h1)) /// Primitive printers for all the types supported by this module assume val print_string: string -> StTrivial unit assume val print_char : char -> StTrivial unit assume val print_u8 : UInt8.t -> StTrivial unit assume val print_u16 : UInt16.t -> StTrivial unit assume val print_u32 : UInt32.t -> StTrivial unit assume val print_u64 : UInt64.t -> StTrivial unit assume val print_i8 : Int8.t -> StTrivial unit assume val print_i16 : Int16.t -> StTrivial unit assume val print_i32 : Int32.t -> StTrivial unit assume val print_i64 : Int64.t -> StTrivial unit assume val print_bool : bool -> StTrivial unit assume val print_lmbuffer_bool (l:_) (#r:_) (#s:_) (b:lmbuffer bool r s l) : StBuf unit b assume val print_lmbuffer_char (l:_) (#r:_) (#s:_) (b:lmbuffer char r s l) : StBuf unit b assume val print_lmbuffer_string (l:_) (#r:_) (#s:_) (b:lmbuffer string r s l) : StBuf unit b assume val print_lmbuffer_u8 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt8.t r s l) : StBuf unit b assume val print_lmbuffer_u16 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt16.t r s l) : StBuf unit b assume val print_lmbuffer_u32 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt32.t r s l) : StBuf unit b assume val print_lmbuffer_u64 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt64.t r s l) : StBuf unit b assume val print_lmbuffer_i8 (l:_) (#r:_) (#s:_) (b:lmbuffer Int8.t r s l) : StBuf unit b assume val print_lmbuffer_i16 (l:_) (#r:_) (#s:_) (b:lmbuffer Int16.t r s l) : StBuf unit b assume val print_lmbuffer_i32 (l:_) (#r:_) (#s:_) (b:lmbuffer Int32.t r s l) : StBuf unit b assume val print_lmbuffer_i64 (l:_) (#r:_) (#s:_) (b:lmbuffer Int64.t r s l) : StBuf unit b /// An attribute to control reduction noextract irreducible let __reduce__ = unit /// Base types supported so far noextract type base_typ = | Bool | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 /// Argument types are base types and arrays thereof /// Or polymorphic arguments specified by "%a" noextract type arg = | Base of base_typ | Array of base_typ | Any /// Interpreting a `base_typ` as a type [@@__reduce__] noextract let base_typ_as_type (b:base_typ) : Type0 = match b with | Bool -> bool | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t /// `fragment`: A format string is parsed into a list of fragments of /// string literals and other arguments that need to be spliced in /// (interpolated) noextract type fragment = | Frag of string | Interpolate of arg noextract let fragments = list fragment /// `parse_format s`: /// Parses a list of characters in a format string into a list of fragments /// Or None, in case the format string is invalid [@@__reduce__] noextract inline_for_extraction let rec parse_format (s:list char) : Tot (option fragments) (decreases (L.length s)) = let add_dir (d:arg) (ods : option fragments) = match ods with | None -> None | Some ds -> Some (Interpolate d::ds) in let head_buffer (ods:option fragments) = match ods with | Some (Interpolate (Base t) :: rest) -> Some (Interpolate (Array t) :: rest) | _ -> None in let cons_frag (c:char) (ods:option fragments) = match ods with | Some (Frag s::rest) -> Some (Frag (string_of_list (c :: list_of_string s)) :: rest) | Some rest -> Some (Frag (string_of_list [c]) :: rest) | _ -> None in match s with | [] -> Some [] | ['%'] -> None // %a... polymorphic arguments and preceded by their printers | '%' :: 'a' :: s' -> add_dir Any (parse_format s') // %x... arrays of base types | '%' :: 'x' :: s' -> head_buffer (parse_format ('%' :: s')) // %u ... Unsigned integers | '%' :: 'u' :: s' -> begin match s' with | 'y' :: s'' -> add_dir (Base U8) (parse_format s'') | 's' :: s'' -> add_dir (Base U16) (parse_format s'') | 'l' :: s'' -> add_dir (Base U32) (parse_format s'') | 'L' :: s'' -> add_dir (Base U64) (parse_format s'') | _ -> None end | '%' :: c :: s' -> begin match c with | '%' -> cons_frag '%' (parse_format s') | 'b' -> add_dir (Base Bool) (parse_format s') | 'c' -> add_dir (Base Char) (parse_format s') | 's' -> add_dir (Base String) (parse_format s') | 'y' -> add_dir (Base I8) (parse_format s') | 'i' -> add_dir (Base I16) (parse_format s') | 'l' -> add_dir (Base I32) (parse_format s') | 'L' -> add_dir (Base I64) (parse_format s') | _ -> None end | c :: s' -> cons_frag c (parse_format s') /// `parse_format_string`: a wrapper around `parse_format` [@@__reduce__] noextract inline_for_extraction let parse_format_string (s:string) : option fragments = parse_format (list_of_string s) /// `lift a` lifts the type `a` to a higher universe noextract type lift (a:Type u#a) : Type u#(max a b) = | Lift : a -> lift a /// `done` is a `unit` in universe 1 noextract let done : lift unit = Lift u#0 u#1 () /// `arg_t`: interpreting an argument as a type /// (in universe 1) since it is polymorphic in the preorders of a buffer /// GM: Somehow, this needs to be a `let rec` (even if it not really recursive) /// or print_frags fails to verify. I don't know why; the generated /// VC and its encoding seem identical (modulo hash consing in the /// latter). [@@__reduce__] noextract let rec arg_t (a:arg) : Type u#1 = match a with | Base t -> lift (base_typ_as_type t) | Array t -> (l:UInt32.t & r:_ & s:_ & lmbuffer (base_typ_as_type t) r s l) | Any -> (a:Type0 & (a -> StTrivial unit) & a) /// `frag_t`: a fragment is either a string literal or a argument to be interpolated noextract let frag_t = either string (a:arg & arg_t a) /// `live_frags h l` is a liveness predicate on all the buffers in `l` [@@__reduce__] noextract let rec live_frags (h:_) (l:list frag_t) : prop = match l with | [] -> True | Inl _ :: rest -> live_frags h rest | Inr a :: rest -> (match a with | (| Base _, _ |) -> live_frags h rest | (| Any, _ |) -> live_frags h rest | (| Array _, (| _, _, _, b |) |) -> LB.live h b /\ live_frags h rest) /// `interpret_frags` interprets a list of fragments as a Low* function type /// Note `l` is the fragments in L-to-R order (i.e., parsing order) /// `acc` accumulates the fragment values in reverse order [@@__reduce__] noextract let rec interpret_frags (l:fragments) (acc:list frag_t) : Type u#1 = match l with | [] -> // Always a dummy argument at the end // Ensures that all cases of this match // have the same universe, i.e., u#1 lift u#0 u#1 unit -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) | Interpolate (Base t) :: args -> // Base types are simple: we just take one more argument x:base_typ_as_type t -> interpret_frags args (Inr (| Base t, Lift x |) :: acc) | Interpolate (Array t) :: args -> // Arrays are implicitly polymorphic in their preorders `r` and `s` // which is what forces us to be in universe 1 // Note, the length `l` is explicit l:UInt32.t -> #r:LB.srel (base_typ_as_type t) -> #s:LB.srel (base_typ_as_type t) -> b:lmbuffer (base_typ_as_type t) r s l -> interpret_frags args (Inr (| Array t, (| l, r, s, b |) |) :: acc) | Interpolate Any :: args -> #a:Type0 -> p:(a -> StTrivial unit) -> x:a -> interpret_frags args (Inr (| Any, (| a, p, x |) |) :: acc) | Frag s :: args -> // Literal fragments do not incur an additional argument // We just accumulate them and recur interpret_frags args (Inl s :: acc) /// `normal` A normalization marker with very specific steps enabled noextract unfold let normal (#a:Type) (x:a) : a = FStar.Pervasives.norm [iota; zeta; delta_attr [`%__reduce__; `%BigOps.__reduce__]; delta_only [`%Base?; `%Array?; `%Some?; `%Some?.v; `%list_of_string]; primops; simplify] x /// `coerce`: A utility to trigger extensional equality of types noextract let coerce (x:'a{'a == 'b}) : 'b = x /// `fragment_printer`: The type of a printer of fragments noextract let fragment_printer = (acc:list frag_t) -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) /// `print_frags`: Having accumulated all the pieces of a format /// string and the arguments to the printed (i.e., the `list frag_t`), /// this function does the actual work of printing them all using the /// primitive printers noextract inline_for_extraction let rec print_frags (acc:list frag_t) : Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) = match acc with | [] -> () | hd::tl -> print_frags tl; (match hd with | Inl s -> print_string s | Inr (| Base t, Lift value |) -> (match t with | Bool -> print_bool value | Char -> print_char value | String -> print_string value | U8 -> print_u8 value | U16 -> print_u16 value | U32 -> print_u32 value | U64 -> print_u64 value | I8 -> print_i8 value | I16 -> print_i16 value | I32 -> print_i32 value | I64 -> print_i64 value) | Inr (| Array t, (| l, r, s, value |) |) -> (match t with | Bool -> print_lmbuffer_bool l value | Char -> print_lmbuffer_char l value | String -> print_lmbuffer_string l value | U8 -> print_lmbuffer_u8 l value | U16 -> print_lmbuffer_u16 l value | U32 -> print_lmbuffer_u32 l value | U64 -> print_lmbuffer_u64 l value | I8 -> print_lmbuffer_i8 l value | I16 -> print_lmbuffer_i16 l value | I32 -> print_lmbuffer_i32 l value | I64 -> print_lmbuffer_i64 l value) | Inr (| Any, (| _, printer, value |) |) -> printer value) [@@__reduce__] let no_inst #a (#b:a -> Type) (f: (#x:a -> b x)) : unit -> #x:a -> b x = fun () -> f [@@__reduce__] let elim_unit_arrow #t (f:unit -> t) : t = f () // let test2 (f: (#a:Type -> a -> a)) : id_t 0 = test f () // let coerce #a (#b: (a -> Type)) ($f: (#x:a -> b x)) (t:Type{norm t == (#x:a -> b x)}) /// `aux frags acc`: This is the main workhorse which interprets a /// parsed format string (`frags`) as a variadic, stateful function [@@__reduce__] noextract inline_for_extraction let rec aux (frags:fragments) (acc:list frag_t) (fp: fragment_printer) : interpret_frags frags acc = match frags with | [] -> let f (l:lift u#0 u#1 unit) : Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) = fp acc in (f <: interpret_frags [] acc) | Frag s :: rest -> coerce (aux rest (Inl s :: acc) fp) | Interpolate (Base t) :: args -> let f (x:base_typ_as_type t) : interpret_frags args (Inr (| Base t, Lift x |) :: acc) = aux args (Inr (| Base t, Lift x |) :: acc) fp in f | Interpolate (Array t) :: rest -> let f : l:UInt32.t -> #r:LB.srel (base_typ_as_type t) -> #s:LB.srel (base_typ_as_type t) -> b:lmbuffer (base_typ_as_type t) r s l -> interpret_frags rest (Inr (| Array t, (| l, r, s, b |) |) :: acc) = fun l #r #s b -> aux rest (Inr (| Array t, (| l, r, s, b |) |) :: acc) fp in f <: interpret_frags (Interpolate (Array t) :: rest) acc | Interpolate Any :: rest -> let f : unit -> #a:Type -> p:(a -> StTrivial unit) -> x:a -> interpret_frags rest (Inr (| Any, (| a, p, x |) |) :: acc) = fun () #a p x -> aux rest (Inr (| Any, (| a, p, x |) |) :: acc) fp in elim_unit_arrow (no_inst (f ()) <: (unit -> interpret_frags (Interpolate Any :: rest) acc)) /// `format_string` : A valid format string is one that can be successfully parsed [@@__reduce__] noextract let format_string = s:string{normal #bool (Some? (parse_format_string s))} /// `interpret_format_string` parses a string into fragments and then /// interprets it as a type [@@__reduce__] noextract let interpret_format_string (s:format_string) : Type = interpret_frags (Some?.v (parse_format_string s)) [] /// `printf'`: Almost there ... this has a variadic type /// and calls the actual printers for all its arguments. /// /// Note, the `normalize_term` in its body is crucial. It's what /// allows the term to be specialized at extraction time. noextract inline_for_extraction
false
false
LowStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val printf' (s: format_string) : interpret_format_string s
[]
LowStar.Printf.printf'
{ "file_name": "ulib/LowStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s: LowStar.Printf.format_string -> LowStar.Printf.interpret_format_string s
{ "end_col": 45, "end_line": 463, "start_col": 2, "start_line": 461 }
Prims.Tot
val skip' (s: format_string) : interpret_format_string s
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "LB" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let skip' (s:format_string) : interpret_format_string s = normalize_term (match parse_format_string s with | Some frags -> aux frags [] (fun _ -> ()))
val skip' (s: format_string) : interpret_format_string s let skip' (s: format_string) : interpret_format_string s =
false
null
false
normalize_term (match parse_format_string s with | Some frags -> aux frags [] (fun _ -> ()))
{ "checked_file": "LowStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked", "FStar.BigOps.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Printf.fst" }
[ "total" ]
[ "LowStar.Printf.format_string", "FStar.Pervasives.normalize_term", "LowStar.Printf.interpret_format_string", "LowStar.Printf.parse_format_string", "LowStar.Printf.fragments", "LowStar.Printf.aux", "Prims.Nil", "LowStar.Printf.frag_t", "Prims.list", "Prims.unit" ]
[]
(* 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 LowStar.Printf /// This module provides imperative printing functions for several /// primitive Low* types, including /// -- booleans (%b) /// -- characters (%c) /// -- strings (%s) /// -- machine integers /// (UInt8.t as %uy, UInt16.t as %us, UInt32.t as %ul, and UInt64.t as %uL; /// Int8.t as %y, Int16.t as %i, Int32.t as %l , and Int64.t as %L) /// -- and arrays (aka buffers) of these base types formatted /// as %xN, where N is the format specifier for the array element type /// e.g., %xuy for buffers of UInt8.t /// The main function of this module is `printf` /// There are a few main differences relative to C printf /// -- The format specifiers are different (see above) /// /// -- For technical reasons explained below, an extra dummy /// argument `done` has to be provided at the end for the /// computation to have any effect. /// /// E.g., one must write /// `printf "%b %c" true 'c' done` /// rather than just /// `printf "%b %c" true 'c'` /// /// -- When printing arrays, two arguments must be passed; the /// length of the array fragment to be formatted and the array /// itself /// /// -- When extracted, rather than producing a C `printf` (which /// does not, e.g., support printing of dynamically sized /// arrays), our `printf` is specialized to a sequence of calls /// to primitive printers for each supported type /// /// Before diving into the technical details of how this module works, /// you might want to see a sample usage at the very end of this file. open FStar.Char open FStar.String open FStar.HyperStack.ST module L = FStar.List.Tot module LB = LowStar.Monotonic.Buffer /// `lmbuffer a r s l` is /// - a monotonic buffer of `a` /// - governed by preorders `r` and `s` /// - with length `l` let lmbuffer a r s l = b:LB.mbuffer a r s{ LB.len b == l } /// `StTrivial`: A effect abbreviation for a stateful computation /// with no precondition, and which does not change the state effect StTrivial (a:Type) = Stack a (requires fun h -> True) (ensures fun h0 _ h1 -> h0==h1) /// `StBuf a b`: A effect abbreviation for a stateful computation /// that may read `b` does not change the state effect StBuf (a:Type) #t #r #s #l (b:lmbuffer t r s l) = Stack a (requires fun h -> LB.live h b) (ensures (fun h0 _ h1 -> h0 == h1)) /// Primitive printers for all the types supported by this module assume val print_string: string -> StTrivial unit assume val print_char : char -> StTrivial unit assume val print_u8 : UInt8.t -> StTrivial unit assume val print_u16 : UInt16.t -> StTrivial unit assume val print_u32 : UInt32.t -> StTrivial unit assume val print_u64 : UInt64.t -> StTrivial unit assume val print_i8 : Int8.t -> StTrivial unit assume val print_i16 : Int16.t -> StTrivial unit assume val print_i32 : Int32.t -> StTrivial unit assume val print_i64 : Int64.t -> StTrivial unit assume val print_bool : bool -> StTrivial unit assume val print_lmbuffer_bool (l:_) (#r:_) (#s:_) (b:lmbuffer bool r s l) : StBuf unit b assume val print_lmbuffer_char (l:_) (#r:_) (#s:_) (b:lmbuffer char r s l) : StBuf unit b assume val print_lmbuffer_string (l:_) (#r:_) (#s:_) (b:lmbuffer string r s l) : StBuf unit b assume val print_lmbuffer_u8 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt8.t r s l) : StBuf unit b assume val print_lmbuffer_u16 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt16.t r s l) : StBuf unit b assume val print_lmbuffer_u32 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt32.t r s l) : StBuf unit b assume val print_lmbuffer_u64 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt64.t r s l) : StBuf unit b assume val print_lmbuffer_i8 (l:_) (#r:_) (#s:_) (b:lmbuffer Int8.t r s l) : StBuf unit b assume val print_lmbuffer_i16 (l:_) (#r:_) (#s:_) (b:lmbuffer Int16.t r s l) : StBuf unit b assume val print_lmbuffer_i32 (l:_) (#r:_) (#s:_) (b:lmbuffer Int32.t r s l) : StBuf unit b assume val print_lmbuffer_i64 (l:_) (#r:_) (#s:_) (b:lmbuffer Int64.t r s l) : StBuf unit b /// An attribute to control reduction noextract irreducible let __reduce__ = unit /// Base types supported so far noextract type base_typ = | Bool | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 /// Argument types are base types and arrays thereof /// Or polymorphic arguments specified by "%a" noextract type arg = | Base of base_typ | Array of base_typ | Any /// Interpreting a `base_typ` as a type [@@__reduce__] noextract let base_typ_as_type (b:base_typ) : Type0 = match b with | Bool -> bool | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t /// `fragment`: A format string is parsed into a list of fragments of /// string literals and other arguments that need to be spliced in /// (interpolated) noextract type fragment = | Frag of string | Interpolate of arg noextract let fragments = list fragment /// `parse_format s`: /// Parses a list of characters in a format string into a list of fragments /// Or None, in case the format string is invalid [@@__reduce__] noextract inline_for_extraction let rec parse_format (s:list char) : Tot (option fragments) (decreases (L.length s)) = let add_dir (d:arg) (ods : option fragments) = match ods with | None -> None | Some ds -> Some (Interpolate d::ds) in let head_buffer (ods:option fragments) = match ods with | Some (Interpolate (Base t) :: rest) -> Some (Interpolate (Array t) :: rest) | _ -> None in let cons_frag (c:char) (ods:option fragments) = match ods with | Some (Frag s::rest) -> Some (Frag (string_of_list (c :: list_of_string s)) :: rest) | Some rest -> Some (Frag (string_of_list [c]) :: rest) | _ -> None in match s with | [] -> Some [] | ['%'] -> None // %a... polymorphic arguments and preceded by their printers | '%' :: 'a' :: s' -> add_dir Any (parse_format s') // %x... arrays of base types | '%' :: 'x' :: s' -> head_buffer (parse_format ('%' :: s')) // %u ... Unsigned integers | '%' :: 'u' :: s' -> begin match s' with | 'y' :: s'' -> add_dir (Base U8) (parse_format s'') | 's' :: s'' -> add_dir (Base U16) (parse_format s'') | 'l' :: s'' -> add_dir (Base U32) (parse_format s'') | 'L' :: s'' -> add_dir (Base U64) (parse_format s'') | _ -> None end | '%' :: c :: s' -> begin match c with | '%' -> cons_frag '%' (parse_format s') | 'b' -> add_dir (Base Bool) (parse_format s') | 'c' -> add_dir (Base Char) (parse_format s') | 's' -> add_dir (Base String) (parse_format s') | 'y' -> add_dir (Base I8) (parse_format s') | 'i' -> add_dir (Base I16) (parse_format s') | 'l' -> add_dir (Base I32) (parse_format s') | 'L' -> add_dir (Base I64) (parse_format s') | _ -> None end | c :: s' -> cons_frag c (parse_format s') /// `parse_format_string`: a wrapper around `parse_format` [@@__reduce__] noextract inline_for_extraction let parse_format_string (s:string) : option fragments = parse_format (list_of_string s) /// `lift a` lifts the type `a` to a higher universe noextract type lift (a:Type u#a) : Type u#(max a b) = | Lift : a -> lift a /// `done` is a `unit` in universe 1 noextract let done : lift unit = Lift u#0 u#1 () /// `arg_t`: interpreting an argument as a type /// (in universe 1) since it is polymorphic in the preorders of a buffer /// GM: Somehow, this needs to be a `let rec` (even if it not really recursive) /// or print_frags fails to verify. I don't know why; the generated /// VC and its encoding seem identical (modulo hash consing in the /// latter). [@@__reduce__] noextract let rec arg_t (a:arg) : Type u#1 = match a with | Base t -> lift (base_typ_as_type t) | Array t -> (l:UInt32.t & r:_ & s:_ & lmbuffer (base_typ_as_type t) r s l) | Any -> (a:Type0 & (a -> StTrivial unit) & a) /// `frag_t`: a fragment is either a string literal or a argument to be interpolated noextract let frag_t = either string (a:arg & arg_t a) /// `live_frags h l` is a liveness predicate on all the buffers in `l` [@@__reduce__] noextract let rec live_frags (h:_) (l:list frag_t) : prop = match l with | [] -> True | Inl _ :: rest -> live_frags h rest | Inr a :: rest -> (match a with | (| Base _, _ |) -> live_frags h rest | (| Any, _ |) -> live_frags h rest | (| Array _, (| _, _, _, b |) |) -> LB.live h b /\ live_frags h rest) /// `interpret_frags` interprets a list of fragments as a Low* function type /// Note `l` is the fragments in L-to-R order (i.e., parsing order) /// `acc` accumulates the fragment values in reverse order [@@__reduce__] noextract let rec interpret_frags (l:fragments) (acc:list frag_t) : Type u#1 = match l with | [] -> // Always a dummy argument at the end // Ensures that all cases of this match // have the same universe, i.e., u#1 lift u#0 u#1 unit -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) | Interpolate (Base t) :: args -> // Base types are simple: we just take one more argument x:base_typ_as_type t -> interpret_frags args (Inr (| Base t, Lift x |) :: acc) | Interpolate (Array t) :: args -> // Arrays are implicitly polymorphic in their preorders `r` and `s` // which is what forces us to be in universe 1 // Note, the length `l` is explicit l:UInt32.t -> #r:LB.srel (base_typ_as_type t) -> #s:LB.srel (base_typ_as_type t) -> b:lmbuffer (base_typ_as_type t) r s l -> interpret_frags args (Inr (| Array t, (| l, r, s, b |) |) :: acc) | Interpolate Any :: args -> #a:Type0 -> p:(a -> StTrivial unit) -> x:a -> interpret_frags args (Inr (| Any, (| a, p, x |) |) :: acc) | Frag s :: args -> // Literal fragments do not incur an additional argument // We just accumulate them and recur interpret_frags args (Inl s :: acc) /// `normal` A normalization marker with very specific steps enabled noextract unfold let normal (#a:Type) (x:a) : a = FStar.Pervasives.norm [iota; zeta; delta_attr [`%__reduce__; `%BigOps.__reduce__]; delta_only [`%Base?; `%Array?; `%Some?; `%Some?.v; `%list_of_string]; primops; simplify] x /// `coerce`: A utility to trigger extensional equality of types noextract let coerce (x:'a{'a == 'b}) : 'b = x /// `fragment_printer`: The type of a printer of fragments noextract let fragment_printer = (acc:list frag_t) -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) /// `print_frags`: Having accumulated all the pieces of a format /// string and the arguments to the printed (i.e., the `list frag_t`), /// this function does the actual work of printing them all using the /// primitive printers noextract inline_for_extraction let rec print_frags (acc:list frag_t) : Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) = match acc with | [] -> () | hd::tl -> print_frags tl; (match hd with | Inl s -> print_string s | Inr (| Base t, Lift value |) -> (match t with | Bool -> print_bool value | Char -> print_char value | String -> print_string value | U8 -> print_u8 value | U16 -> print_u16 value | U32 -> print_u32 value | U64 -> print_u64 value | I8 -> print_i8 value | I16 -> print_i16 value | I32 -> print_i32 value | I64 -> print_i64 value) | Inr (| Array t, (| l, r, s, value |) |) -> (match t with | Bool -> print_lmbuffer_bool l value | Char -> print_lmbuffer_char l value | String -> print_lmbuffer_string l value | U8 -> print_lmbuffer_u8 l value | U16 -> print_lmbuffer_u16 l value | U32 -> print_lmbuffer_u32 l value | U64 -> print_lmbuffer_u64 l value | I8 -> print_lmbuffer_i8 l value | I16 -> print_lmbuffer_i16 l value | I32 -> print_lmbuffer_i32 l value | I64 -> print_lmbuffer_i64 l value) | Inr (| Any, (| _, printer, value |) |) -> printer value) [@@__reduce__] let no_inst #a (#b:a -> Type) (f: (#x:a -> b x)) : unit -> #x:a -> b x = fun () -> f [@@__reduce__] let elim_unit_arrow #t (f:unit -> t) : t = f () // let test2 (f: (#a:Type -> a -> a)) : id_t 0 = test f () // let coerce #a (#b: (a -> Type)) ($f: (#x:a -> b x)) (t:Type{norm t == (#x:a -> b x)}) /// `aux frags acc`: This is the main workhorse which interprets a /// parsed format string (`frags`) as a variadic, stateful function [@@__reduce__] noextract inline_for_extraction let rec aux (frags:fragments) (acc:list frag_t) (fp: fragment_printer) : interpret_frags frags acc = match frags with | [] -> let f (l:lift u#0 u#1 unit) : Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) = fp acc in (f <: interpret_frags [] acc) | Frag s :: rest -> coerce (aux rest (Inl s :: acc) fp) | Interpolate (Base t) :: args -> let f (x:base_typ_as_type t) : interpret_frags args (Inr (| Base t, Lift x |) :: acc) = aux args (Inr (| Base t, Lift x |) :: acc) fp in f | Interpolate (Array t) :: rest -> let f : l:UInt32.t -> #r:LB.srel (base_typ_as_type t) -> #s:LB.srel (base_typ_as_type t) -> b:lmbuffer (base_typ_as_type t) r s l -> interpret_frags rest (Inr (| Array t, (| l, r, s, b |) |) :: acc) = fun l #r #s b -> aux rest (Inr (| Array t, (| l, r, s, b |) |) :: acc) fp in f <: interpret_frags (Interpolate (Array t) :: rest) acc | Interpolate Any :: rest -> let f : unit -> #a:Type -> p:(a -> StTrivial unit) -> x:a -> interpret_frags rest (Inr (| Any, (| a, p, x |) |) :: acc) = fun () #a p x -> aux rest (Inr (| Any, (| a, p, x |) |) :: acc) fp in elim_unit_arrow (no_inst (f ()) <: (unit -> interpret_frags (Interpolate Any :: rest) acc)) /// `format_string` : A valid format string is one that can be successfully parsed [@@__reduce__] noextract let format_string = s:string{normal #bool (Some? (parse_format_string s))} /// `interpret_format_string` parses a string into fragments and then /// interprets it as a type [@@__reduce__] noextract let interpret_format_string (s:format_string) : Type = interpret_frags (Some?.v (parse_format_string s)) [] /// `printf'`: Almost there ... this has a variadic type /// and calls the actual printers for all its arguments. /// /// Note, the `normalize_term` in its body is crucial. It's what /// allows the term to be specialized at extraction time. noextract inline_for_extraction let printf' (s:format_string) : interpret_format_string s = normalize_term (match parse_format_string s with | Some frags -> aux frags [] print_frags) /// `intro_normal_f`: a technical gadget to introduce /// implicit normalization in the domain and co-domain of a function type noextract inline_for_extraction let intro_normal_f (#a:Type) (b: (a -> Type)) (f:(x:a -> b x)) : (x:(normal a) -> normal (b x)) = f /// `printf`: The main function has type /// `s:normal format_string -> normal (interpret_format_string s)` /// Note: /// This is the type F* infers for it and it is best to leave it that way /// rather then writing it down and asking F* to re-check what it inferred. /// /// Annotating it results in a needless additional proof obligation to /// equate types after they are partially reduced, which is pointless. noextract inline_for_extraction val printf : s:normal format_string -> normal (interpret_format_string s) let printf = intro_normal_f #format_string interpret_format_string printf' /// `skip`: We also provide `skip`, a function that has the same type as printf /// but normalizes to `()`, i.e., it prints nothing. This is useful for conditional /// printing in debug code, for instance. noextract inline_for_extraction
false
false
LowStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val skip' (s: format_string) : interpret_format_string s
[]
LowStar.Printf.skip'
{ "file_name": "ulib/LowStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s: LowStar.Printf.format_string -> LowStar.Printf.interpret_format_string s
{ "end_col": 47, "end_line": 492, "start_col": 2, "start_line": 490 }
FStar.HyperStack.ST.Stack
val test2 (x: (int * int)) (print_pair: ((int * int) -> StTrivial unit)) : Stack unit (requires (fun h0 -> True)) (ensures (fun h0 _ h1 -> h0 == h1))
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "LB" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test2 (x:(int * int)) (print_pair:(int * int) -> StTrivial unit) : Stack unit (requires (fun h0 -> True)) (ensures (fun h0 _ h1 -> h0 == h1)) = printf "Hello pair %a" print_pair x done
val test2 (x: (int * int)) (print_pair: ((int * int) -> StTrivial unit)) : Stack unit (requires (fun h0 -> True)) (ensures (fun h0 _ h1 -> h0 == h1)) let test2 (x: (int * int)) (print_pair: ((int * int) -> StTrivial unit)) : Stack unit (requires (fun h0 -> True)) (ensures (fun h0 _ h1 -> h0 == h1)) =
true
null
false
printf "Hello pair %a" print_pair x done
{ "checked_file": "LowStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked", "FStar.BigOps.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Printf.fst" }
[]
[ "FStar.Pervasives.Native.tuple2", "Prims.int", "Prims.unit", "LowStar.Printf.printf", "LowStar.Printf.done", "FStar.Monotonic.HyperStack.mem", "Prims.l_True", "Prims.eq2" ]
[]
(* 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 LowStar.Printf /// This module provides imperative printing functions for several /// primitive Low* types, including /// -- booleans (%b) /// -- characters (%c) /// -- strings (%s) /// -- machine integers /// (UInt8.t as %uy, UInt16.t as %us, UInt32.t as %ul, and UInt64.t as %uL; /// Int8.t as %y, Int16.t as %i, Int32.t as %l , and Int64.t as %L) /// -- and arrays (aka buffers) of these base types formatted /// as %xN, where N is the format specifier for the array element type /// e.g., %xuy for buffers of UInt8.t /// The main function of this module is `printf` /// There are a few main differences relative to C printf /// -- The format specifiers are different (see above) /// /// -- For technical reasons explained below, an extra dummy /// argument `done` has to be provided at the end for the /// computation to have any effect. /// /// E.g., one must write /// `printf "%b %c" true 'c' done` /// rather than just /// `printf "%b %c" true 'c'` /// /// -- When printing arrays, two arguments must be passed; the /// length of the array fragment to be formatted and the array /// itself /// /// -- When extracted, rather than producing a C `printf` (which /// does not, e.g., support printing of dynamically sized /// arrays), our `printf` is specialized to a sequence of calls /// to primitive printers for each supported type /// /// Before diving into the technical details of how this module works, /// you might want to see a sample usage at the very end of this file. open FStar.Char open FStar.String open FStar.HyperStack.ST module L = FStar.List.Tot module LB = LowStar.Monotonic.Buffer /// `lmbuffer a r s l` is /// - a monotonic buffer of `a` /// - governed by preorders `r` and `s` /// - with length `l` let lmbuffer a r s l = b:LB.mbuffer a r s{ LB.len b == l } /// `StTrivial`: A effect abbreviation for a stateful computation /// with no precondition, and which does not change the state effect StTrivial (a:Type) = Stack a (requires fun h -> True) (ensures fun h0 _ h1 -> h0==h1) /// `StBuf a b`: A effect abbreviation for a stateful computation /// that may read `b` does not change the state effect StBuf (a:Type) #t #r #s #l (b:lmbuffer t r s l) = Stack a (requires fun h -> LB.live h b) (ensures (fun h0 _ h1 -> h0 == h1)) /// Primitive printers for all the types supported by this module assume val print_string: string -> StTrivial unit assume val print_char : char -> StTrivial unit assume val print_u8 : UInt8.t -> StTrivial unit assume val print_u16 : UInt16.t -> StTrivial unit assume val print_u32 : UInt32.t -> StTrivial unit assume val print_u64 : UInt64.t -> StTrivial unit assume val print_i8 : Int8.t -> StTrivial unit assume val print_i16 : Int16.t -> StTrivial unit assume val print_i32 : Int32.t -> StTrivial unit assume val print_i64 : Int64.t -> StTrivial unit assume val print_bool : bool -> StTrivial unit assume val print_lmbuffer_bool (l:_) (#r:_) (#s:_) (b:lmbuffer bool r s l) : StBuf unit b assume val print_lmbuffer_char (l:_) (#r:_) (#s:_) (b:lmbuffer char r s l) : StBuf unit b assume val print_lmbuffer_string (l:_) (#r:_) (#s:_) (b:lmbuffer string r s l) : StBuf unit b assume val print_lmbuffer_u8 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt8.t r s l) : StBuf unit b assume val print_lmbuffer_u16 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt16.t r s l) : StBuf unit b assume val print_lmbuffer_u32 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt32.t r s l) : StBuf unit b assume val print_lmbuffer_u64 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt64.t r s l) : StBuf unit b assume val print_lmbuffer_i8 (l:_) (#r:_) (#s:_) (b:lmbuffer Int8.t r s l) : StBuf unit b assume val print_lmbuffer_i16 (l:_) (#r:_) (#s:_) (b:lmbuffer Int16.t r s l) : StBuf unit b assume val print_lmbuffer_i32 (l:_) (#r:_) (#s:_) (b:lmbuffer Int32.t r s l) : StBuf unit b assume val print_lmbuffer_i64 (l:_) (#r:_) (#s:_) (b:lmbuffer Int64.t r s l) : StBuf unit b /// An attribute to control reduction noextract irreducible let __reduce__ = unit /// Base types supported so far noextract type base_typ = | Bool | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 /// Argument types are base types and arrays thereof /// Or polymorphic arguments specified by "%a" noextract type arg = | Base of base_typ | Array of base_typ | Any /// Interpreting a `base_typ` as a type [@@__reduce__] noextract let base_typ_as_type (b:base_typ) : Type0 = match b with | Bool -> bool | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t /// `fragment`: A format string is parsed into a list of fragments of /// string literals and other arguments that need to be spliced in /// (interpolated) noextract type fragment = | Frag of string | Interpolate of arg noextract let fragments = list fragment /// `parse_format s`: /// Parses a list of characters in a format string into a list of fragments /// Or None, in case the format string is invalid [@@__reduce__] noextract inline_for_extraction let rec parse_format (s:list char) : Tot (option fragments) (decreases (L.length s)) = let add_dir (d:arg) (ods : option fragments) = match ods with | None -> None | Some ds -> Some (Interpolate d::ds) in let head_buffer (ods:option fragments) = match ods with | Some (Interpolate (Base t) :: rest) -> Some (Interpolate (Array t) :: rest) | _ -> None in let cons_frag (c:char) (ods:option fragments) = match ods with | Some (Frag s::rest) -> Some (Frag (string_of_list (c :: list_of_string s)) :: rest) | Some rest -> Some (Frag (string_of_list [c]) :: rest) | _ -> None in match s with | [] -> Some [] | ['%'] -> None // %a... polymorphic arguments and preceded by their printers | '%' :: 'a' :: s' -> add_dir Any (parse_format s') // %x... arrays of base types | '%' :: 'x' :: s' -> head_buffer (parse_format ('%' :: s')) // %u ... Unsigned integers | '%' :: 'u' :: s' -> begin match s' with | 'y' :: s'' -> add_dir (Base U8) (parse_format s'') | 's' :: s'' -> add_dir (Base U16) (parse_format s'') | 'l' :: s'' -> add_dir (Base U32) (parse_format s'') | 'L' :: s'' -> add_dir (Base U64) (parse_format s'') | _ -> None end | '%' :: c :: s' -> begin match c with | '%' -> cons_frag '%' (parse_format s') | 'b' -> add_dir (Base Bool) (parse_format s') | 'c' -> add_dir (Base Char) (parse_format s') | 's' -> add_dir (Base String) (parse_format s') | 'y' -> add_dir (Base I8) (parse_format s') | 'i' -> add_dir (Base I16) (parse_format s') | 'l' -> add_dir (Base I32) (parse_format s') | 'L' -> add_dir (Base I64) (parse_format s') | _ -> None end | c :: s' -> cons_frag c (parse_format s') /// `parse_format_string`: a wrapper around `parse_format` [@@__reduce__] noextract inline_for_extraction let parse_format_string (s:string) : option fragments = parse_format (list_of_string s) /// `lift a` lifts the type `a` to a higher universe noextract type lift (a:Type u#a) : Type u#(max a b) = | Lift : a -> lift a /// `done` is a `unit` in universe 1 noextract let done : lift unit = Lift u#0 u#1 () /// `arg_t`: interpreting an argument as a type /// (in universe 1) since it is polymorphic in the preorders of a buffer /// GM: Somehow, this needs to be a `let rec` (even if it not really recursive) /// or print_frags fails to verify. I don't know why; the generated /// VC and its encoding seem identical (modulo hash consing in the /// latter). [@@__reduce__] noextract let rec arg_t (a:arg) : Type u#1 = match a with | Base t -> lift (base_typ_as_type t) | Array t -> (l:UInt32.t & r:_ & s:_ & lmbuffer (base_typ_as_type t) r s l) | Any -> (a:Type0 & (a -> StTrivial unit) & a) /// `frag_t`: a fragment is either a string literal or a argument to be interpolated noextract let frag_t = either string (a:arg & arg_t a) /// `live_frags h l` is a liveness predicate on all the buffers in `l` [@@__reduce__] noextract let rec live_frags (h:_) (l:list frag_t) : prop = match l with | [] -> True | Inl _ :: rest -> live_frags h rest | Inr a :: rest -> (match a with | (| Base _, _ |) -> live_frags h rest | (| Any, _ |) -> live_frags h rest | (| Array _, (| _, _, _, b |) |) -> LB.live h b /\ live_frags h rest) /// `interpret_frags` interprets a list of fragments as a Low* function type /// Note `l` is the fragments in L-to-R order (i.e., parsing order) /// `acc` accumulates the fragment values in reverse order [@@__reduce__] noextract let rec interpret_frags (l:fragments) (acc:list frag_t) : Type u#1 = match l with | [] -> // Always a dummy argument at the end // Ensures that all cases of this match // have the same universe, i.e., u#1 lift u#0 u#1 unit -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) | Interpolate (Base t) :: args -> // Base types are simple: we just take one more argument x:base_typ_as_type t -> interpret_frags args (Inr (| Base t, Lift x |) :: acc) | Interpolate (Array t) :: args -> // Arrays are implicitly polymorphic in their preorders `r` and `s` // which is what forces us to be in universe 1 // Note, the length `l` is explicit l:UInt32.t -> #r:LB.srel (base_typ_as_type t) -> #s:LB.srel (base_typ_as_type t) -> b:lmbuffer (base_typ_as_type t) r s l -> interpret_frags args (Inr (| Array t, (| l, r, s, b |) |) :: acc) | Interpolate Any :: args -> #a:Type0 -> p:(a -> StTrivial unit) -> x:a -> interpret_frags args (Inr (| Any, (| a, p, x |) |) :: acc) | Frag s :: args -> // Literal fragments do not incur an additional argument // We just accumulate them and recur interpret_frags args (Inl s :: acc) /// `normal` A normalization marker with very specific steps enabled noextract unfold let normal (#a:Type) (x:a) : a = FStar.Pervasives.norm [iota; zeta; delta_attr [`%__reduce__; `%BigOps.__reduce__]; delta_only [`%Base?; `%Array?; `%Some?; `%Some?.v; `%list_of_string]; primops; simplify] x /// `coerce`: A utility to trigger extensional equality of types noextract let coerce (x:'a{'a == 'b}) : 'b = x /// `fragment_printer`: The type of a printer of fragments noextract let fragment_printer = (acc:list frag_t) -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) /// `print_frags`: Having accumulated all the pieces of a format /// string and the arguments to the printed (i.e., the `list frag_t`), /// this function does the actual work of printing them all using the /// primitive printers noextract inline_for_extraction let rec print_frags (acc:list frag_t) : Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) = match acc with | [] -> () | hd::tl -> print_frags tl; (match hd with | Inl s -> print_string s | Inr (| Base t, Lift value |) -> (match t with | Bool -> print_bool value | Char -> print_char value | String -> print_string value | U8 -> print_u8 value | U16 -> print_u16 value | U32 -> print_u32 value | U64 -> print_u64 value | I8 -> print_i8 value | I16 -> print_i16 value | I32 -> print_i32 value | I64 -> print_i64 value) | Inr (| Array t, (| l, r, s, value |) |) -> (match t with | Bool -> print_lmbuffer_bool l value | Char -> print_lmbuffer_char l value | String -> print_lmbuffer_string l value | U8 -> print_lmbuffer_u8 l value | U16 -> print_lmbuffer_u16 l value | U32 -> print_lmbuffer_u32 l value | U64 -> print_lmbuffer_u64 l value | I8 -> print_lmbuffer_i8 l value | I16 -> print_lmbuffer_i16 l value | I32 -> print_lmbuffer_i32 l value | I64 -> print_lmbuffer_i64 l value) | Inr (| Any, (| _, printer, value |) |) -> printer value) [@@__reduce__] let no_inst #a (#b:a -> Type) (f: (#x:a -> b x)) : unit -> #x:a -> b x = fun () -> f [@@__reduce__] let elim_unit_arrow #t (f:unit -> t) : t = f () // let test2 (f: (#a:Type -> a -> a)) : id_t 0 = test f () // let coerce #a (#b: (a -> Type)) ($f: (#x:a -> b x)) (t:Type{norm t == (#x:a -> b x)}) /// `aux frags acc`: This is the main workhorse which interprets a /// parsed format string (`frags`) as a variadic, stateful function [@@__reduce__] noextract inline_for_extraction let rec aux (frags:fragments) (acc:list frag_t) (fp: fragment_printer) : interpret_frags frags acc = match frags with | [] -> let f (l:lift u#0 u#1 unit) : Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) = fp acc in (f <: interpret_frags [] acc) | Frag s :: rest -> coerce (aux rest (Inl s :: acc) fp) | Interpolate (Base t) :: args -> let f (x:base_typ_as_type t) : interpret_frags args (Inr (| Base t, Lift x |) :: acc) = aux args (Inr (| Base t, Lift x |) :: acc) fp in f | Interpolate (Array t) :: rest -> let f : l:UInt32.t -> #r:LB.srel (base_typ_as_type t) -> #s:LB.srel (base_typ_as_type t) -> b:lmbuffer (base_typ_as_type t) r s l -> interpret_frags rest (Inr (| Array t, (| l, r, s, b |) |) :: acc) = fun l #r #s b -> aux rest (Inr (| Array t, (| l, r, s, b |) |) :: acc) fp in f <: interpret_frags (Interpolate (Array t) :: rest) acc | Interpolate Any :: rest -> let f : unit -> #a:Type -> p:(a -> StTrivial unit) -> x:a -> interpret_frags rest (Inr (| Any, (| a, p, x |) |) :: acc) = fun () #a p x -> aux rest (Inr (| Any, (| a, p, x |) |) :: acc) fp in elim_unit_arrow (no_inst (f ()) <: (unit -> interpret_frags (Interpolate Any :: rest) acc)) /// `format_string` : A valid format string is one that can be successfully parsed [@@__reduce__] noextract let format_string = s:string{normal #bool (Some? (parse_format_string s))} /// `interpret_format_string` parses a string into fragments and then /// interprets it as a type [@@__reduce__] noextract let interpret_format_string (s:format_string) : Type = interpret_frags (Some?.v (parse_format_string s)) [] /// `printf'`: Almost there ... this has a variadic type /// and calls the actual printers for all its arguments. /// /// Note, the `normalize_term` in its body is crucial. It's what /// allows the term to be specialized at extraction time. noextract inline_for_extraction let printf' (s:format_string) : interpret_format_string s = normalize_term (match parse_format_string s with | Some frags -> aux frags [] print_frags) /// `intro_normal_f`: a technical gadget to introduce /// implicit normalization in the domain and co-domain of a function type noextract inline_for_extraction let intro_normal_f (#a:Type) (b: (a -> Type)) (f:(x:a -> b x)) : (x:(normal a) -> normal (b x)) = f /// `printf`: The main function has type /// `s:normal format_string -> normal (interpret_format_string s)` /// Note: /// This is the type F* infers for it and it is best to leave it that way /// rather then writing it down and asking F* to re-check what it inferred. /// /// Annotating it results in a needless additional proof obligation to /// equate types after they are partially reduced, which is pointless. noextract inline_for_extraction val printf : s:normal format_string -> normal (interpret_format_string s) let printf = intro_normal_f #format_string interpret_format_string printf' /// `skip`: We also provide `skip`, a function that has the same type as printf /// but normalizes to `()`, i.e., it prints nothing. This is useful for conditional /// printing in debug code, for instance. noextract inline_for_extraction let skip' (s:format_string) : interpret_format_string s = normalize_term (match parse_format_string s with | Some frags -> aux frags [] (fun _ -> ())) noextract inline_for_extraction val skip : s:normal format_string -> normal (interpret_format_string s) let skip = intro_normal_f #format_string interpret_format_string skip' /// `test`: A small test function /// Running `fstar --codegen OCaml LowStar.Printf.fst --extract LowStar.Printf` /// produces the following for the body of this function /// ``` /// print_string "Hello "; /// print_bool true; /// print_string " Low* "; /// print_u64 m; /// print_string " Printf "; /// print_lmbuffer_bool l () () x; /// print_string " "; /// print_string "bye" /// ``` let test (m:UInt64.t) (l:UInt32.t) (#r:_) (#s:_) (x:LB.mbuffer bool r s{LB.len x = l}) : Stack unit (requires (fun h0 -> LB.live h0 x)) (ensures (fun h0 _ h1 -> h0 == h1)) = printf "Hello %b Low* %uL Printf %xb %s" true //%b boolean m //%uL u64 l x //%xb (buffer bool) "bye" done //dummy universe coercion let test2 (x:(int * int)) (print_pair:(int * int) -> StTrivial unit) : Stack unit (requires (fun h0 -> True))
false
false
LowStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test2 (x: (int * int)) (print_pair: ((int * int) -> StTrivial unit)) : Stack unit (requires (fun h0 -> True)) (ensures (fun h0 _ h1 -> h0 == h1))
[]
LowStar.Printf.test2
{ "file_name": "ulib/LowStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: (Prims.int * Prims.int) -> print_pair: (_: (Prims.int * Prims.int) -> LowStar.Printf.StTrivial Prims.unit) -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 44, "end_line": 527, "start_col": 4, "start_line": 527 }
FStar.HyperStack.ST.Stack
val test3 (m: UInt64.t) (l: UInt32.t) (#r #s: _) (x: LB.mbuffer bool r s {LB.len x = l}) : Stack unit (requires (fun h0 -> LB.live h0 x)) (ensures (fun h0 _ h1 -> h0 == h1))
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "LB" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test3 (m:UInt64.t) (l:UInt32.t) (#r:_) (#s:_) (x:LB.mbuffer bool r s{LB.len x = l}) : Stack unit (requires (fun h0 -> LB.live h0 x)) (ensures (fun h0 _ h1 -> h0 == h1)) = skip "Hello %b Low* %uL Printf %xb %s" true //%b boolean m //%uL u64 l x //%xb (buffer bool) "bye" done
val test3 (m: UInt64.t) (l: UInt32.t) (#r #s: _) (x: LB.mbuffer bool r s {LB.len x = l}) : Stack unit (requires (fun h0 -> LB.live h0 x)) (ensures (fun h0 _ h1 -> h0 == h1)) let test3 (m: UInt64.t) (l: UInt32.t) (#r #s: _) (x: LB.mbuffer bool r s {LB.len x = l}) : Stack unit (requires (fun h0 -> LB.live h0 x)) (ensures (fun h0 _ h1 -> h0 == h1)) =
true
null
false
skip "Hello %b Low* %uL Printf %xb %s" true m l x "bye" done
{ "checked_file": "LowStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked", "FStar.BigOps.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Printf.fst" }
[]
[ "FStar.UInt64.t", "FStar.UInt32.t", "LowStar.Monotonic.Buffer.srel", "Prims.bool", "LowStar.Monotonic.Buffer.mbuffer", "Prims.b2t", "Prims.op_Equality", "LowStar.Monotonic.Buffer.len", "LowStar.Printf.skip", "LowStar.Printf.done", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "LowStar.Monotonic.Buffer.live", "Prims.eq2" ]
[]
(* 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 LowStar.Printf /// This module provides imperative printing functions for several /// primitive Low* types, including /// -- booleans (%b) /// -- characters (%c) /// -- strings (%s) /// -- machine integers /// (UInt8.t as %uy, UInt16.t as %us, UInt32.t as %ul, and UInt64.t as %uL; /// Int8.t as %y, Int16.t as %i, Int32.t as %l , and Int64.t as %L) /// -- and arrays (aka buffers) of these base types formatted /// as %xN, where N is the format specifier for the array element type /// e.g., %xuy for buffers of UInt8.t /// The main function of this module is `printf` /// There are a few main differences relative to C printf /// -- The format specifiers are different (see above) /// /// -- For technical reasons explained below, an extra dummy /// argument `done` has to be provided at the end for the /// computation to have any effect. /// /// E.g., one must write /// `printf "%b %c" true 'c' done` /// rather than just /// `printf "%b %c" true 'c'` /// /// -- When printing arrays, two arguments must be passed; the /// length of the array fragment to be formatted and the array /// itself /// /// -- When extracted, rather than producing a C `printf` (which /// does not, e.g., support printing of dynamically sized /// arrays), our `printf` is specialized to a sequence of calls /// to primitive printers for each supported type /// /// Before diving into the technical details of how this module works, /// you might want to see a sample usage at the very end of this file. open FStar.Char open FStar.String open FStar.HyperStack.ST module L = FStar.List.Tot module LB = LowStar.Monotonic.Buffer /// `lmbuffer a r s l` is /// - a monotonic buffer of `a` /// - governed by preorders `r` and `s` /// - with length `l` let lmbuffer a r s l = b:LB.mbuffer a r s{ LB.len b == l } /// `StTrivial`: A effect abbreviation for a stateful computation /// with no precondition, and which does not change the state effect StTrivial (a:Type) = Stack a (requires fun h -> True) (ensures fun h0 _ h1 -> h0==h1) /// `StBuf a b`: A effect abbreviation for a stateful computation /// that may read `b` does not change the state effect StBuf (a:Type) #t #r #s #l (b:lmbuffer t r s l) = Stack a (requires fun h -> LB.live h b) (ensures (fun h0 _ h1 -> h0 == h1)) /// Primitive printers for all the types supported by this module assume val print_string: string -> StTrivial unit assume val print_char : char -> StTrivial unit assume val print_u8 : UInt8.t -> StTrivial unit assume val print_u16 : UInt16.t -> StTrivial unit assume val print_u32 : UInt32.t -> StTrivial unit assume val print_u64 : UInt64.t -> StTrivial unit assume val print_i8 : Int8.t -> StTrivial unit assume val print_i16 : Int16.t -> StTrivial unit assume val print_i32 : Int32.t -> StTrivial unit assume val print_i64 : Int64.t -> StTrivial unit assume val print_bool : bool -> StTrivial unit assume val print_lmbuffer_bool (l:_) (#r:_) (#s:_) (b:lmbuffer bool r s l) : StBuf unit b assume val print_lmbuffer_char (l:_) (#r:_) (#s:_) (b:lmbuffer char r s l) : StBuf unit b assume val print_lmbuffer_string (l:_) (#r:_) (#s:_) (b:lmbuffer string r s l) : StBuf unit b assume val print_lmbuffer_u8 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt8.t r s l) : StBuf unit b assume val print_lmbuffer_u16 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt16.t r s l) : StBuf unit b assume val print_lmbuffer_u32 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt32.t r s l) : StBuf unit b assume val print_lmbuffer_u64 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt64.t r s l) : StBuf unit b assume val print_lmbuffer_i8 (l:_) (#r:_) (#s:_) (b:lmbuffer Int8.t r s l) : StBuf unit b assume val print_lmbuffer_i16 (l:_) (#r:_) (#s:_) (b:lmbuffer Int16.t r s l) : StBuf unit b assume val print_lmbuffer_i32 (l:_) (#r:_) (#s:_) (b:lmbuffer Int32.t r s l) : StBuf unit b assume val print_lmbuffer_i64 (l:_) (#r:_) (#s:_) (b:lmbuffer Int64.t r s l) : StBuf unit b /// An attribute to control reduction noextract irreducible let __reduce__ = unit /// Base types supported so far noextract type base_typ = | Bool | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 /// Argument types are base types and arrays thereof /// Or polymorphic arguments specified by "%a" noextract type arg = | Base of base_typ | Array of base_typ | Any /// Interpreting a `base_typ` as a type [@@__reduce__] noextract let base_typ_as_type (b:base_typ) : Type0 = match b with | Bool -> bool | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t /// `fragment`: A format string is parsed into a list of fragments of /// string literals and other arguments that need to be spliced in /// (interpolated) noextract type fragment = | Frag of string | Interpolate of arg noextract let fragments = list fragment /// `parse_format s`: /// Parses a list of characters in a format string into a list of fragments /// Or None, in case the format string is invalid [@@__reduce__] noextract inline_for_extraction let rec parse_format (s:list char) : Tot (option fragments) (decreases (L.length s)) = let add_dir (d:arg) (ods : option fragments) = match ods with | None -> None | Some ds -> Some (Interpolate d::ds) in let head_buffer (ods:option fragments) = match ods with | Some (Interpolate (Base t) :: rest) -> Some (Interpolate (Array t) :: rest) | _ -> None in let cons_frag (c:char) (ods:option fragments) = match ods with | Some (Frag s::rest) -> Some (Frag (string_of_list (c :: list_of_string s)) :: rest) | Some rest -> Some (Frag (string_of_list [c]) :: rest) | _ -> None in match s with | [] -> Some [] | ['%'] -> None // %a... polymorphic arguments and preceded by their printers | '%' :: 'a' :: s' -> add_dir Any (parse_format s') // %x... arrays of base types | '%' :: 'x' :: s' -> head_buffer (parse_format ('%' :: s')) // %u ... Unsigned integers | '%' :: 'u' :: s' -> begin match s' with | 'y' :: s'' -> add_dir (Base U8) (parse_format s'') | 's' :: s'' -> add_dir (Base U16) (parse_format s'') | 'l' :: s'' -> add_dir (Base U32) (parse_format s'') | 'L' :: s'' -> add_dir (Base U64) (parse_format s'') | _ -> None end | '%' :: c :: s' -> begin match c with | '%' -> cons_frag '%' (parse_format s') | 'b' -> add_dir (Base Bool) (parse_format s') | 'c' -> add_dir (Base Char) (parse_format s') | 's' -> add_dir (Base String) (parse_format s') | 'y' -> add_dir (Base I8) (parse_format s') | 'i' -> add_dir (Base I16) (parse_format s') | 'l' -> add_dir (Base I32) (parse_format s') | 'L' -> add_dir (Base I64) (parse_format s') | _ -> None end | c :: s' -> cons_frag c (parse_format s') /// `parse_format_string`: a wrapper around `parse_format` [@@__reduce__] noextract inline_for_extraction let parse_format_string (s:string) : option fragments = parse_format (list_of_string s) /// `lift a` lifts the type `a` to a higher universe noextract type lift (a:Type u#a) : Type u#(max a b) = | Lift : a -> lift a /// `done` is a `unit` in universe 1 noextract let done : lift unit = Lift u#0 u#1 () /// `arg_t`: interpreting an argument as a type /// (in universe 1) since it is polymorphic in the preorders of a buffer /// GM: Somehow, this needs to be a `let rec` (even if it not really recursive) /// or print_frags fails to verify. I don't know why; the generated /// VC and its encoding seem identical (modulo hash consing in the /// latter). [@@__reduce__] noextract let rec arg_t (a:arg) : Type u#1 = match a with | Base t -> lift (base_typ_as_type t) | Array t -> (l:UInt32.t & r:_ & s:_ & lmbuffer (base_typ_as_type t) r s l) | Any -> (a:Type0 & (a -> StTrivial unit) & a) /// `frag_t`: a fragment is either a string literal or a argument to be interpolated noextract let frag_t = either string (a:arg & arg_t a) /// `live_frags h l` is a liveness predicate on all the buffers in `l` [@@__reduce__] noextract let rec live_frags (h:_) (l:list frag_t) : prop = match l with | [] -> True | Inl _ :: rest -> live_frags h rest | Inr a :: rest -> (match a with | (| Base _, _ |) -> live_frags h rest | (| Any, _ |) -> live_frags h rest | (| Array _, (| _, _, _, b |) |) -> LB.live h b /\ live_frags h rest) /// `interpret_frags` interprets a list of fragments as a Low* function type /// Note `l` is the fragments in L-to-R order (i.e., parsing order) /// `acc` accumulates the fragment values in reverse order [@@__reduce__] noextract let rec interpret_frags (l:fragments) (acc:list frag_t) : Type u#1 = match l with | [] -> // Always a dummy argument at the end // Ensures that all cases of this match // have the same universe, i.e., u#1 lift u#0 u#1 unit -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) | Interpolate (Base t) :: args -> // Base types are simple: we just take one more argument x:base_typ_as_type t -> interpret_frags args (Inr (| Base t, Lift x |) :: acc) | Interpolate (Array t) :: args -> // Arrays are implicitly polymorphic in their preorders `r` and `s` // which is what forces us to be in universe 1 // Note, the length `l` is explicit l:UInt32.t -> #r:LB.srel (base_typ_as_type t) -> #s:LB.srel (base_typ_as_type t) -> b:lmbuffer (base_typ_as_type t) r s l -> interpret_frags args (Inr (| Array t, (| l, r, s, b |) |) :: acc) | Interpolate Any :: args -> #a:Type0 -> p:(a -> StTrivial unit) -> x:a -> interpret_frags args (Inr (| Any, (| a, p, x |) |) :: acc) | Frag s :: args -> // Literal fragments do not incur an additional argument // We just accumulate them and recur interpret_frags args (Inl s :: acc) /// `normal` A normalization marker with very specific steps enabled noextract unfold let normal (#a:Type) (x:a) : a = FStar.Pervasives.norm [iota; zeta; delta_attr [`%__reduce__; `%BigOps.__reduce__]; delta_only [`%Base?; `%Array?; `%Some?; `%Some?.v; `%list_of_string]; primops; simplify] x /// `coerce`: A utility to trigger extensional equality of types noextract let coerce (x:'a{'a == 'b}) : 'b = x /// `fragment_printer`: The type of a printer of fragments noextract let fragment_printer = (acc:list frag_t) -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) /// `print_frags`: Having accumulated all the pieces of a format /// string and the arguments to the printed (i.e., the `list frag_t`), /// this function does the actual work of printing them all using the /// primitive printers noextract inline_for_extraction let rec print_frags (acc:list frag_t) : Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) = match acc with | [] -> () | hd::tl -> print_frags tl; (match hd with | Inl s -> print_string s | Inr (| Base t, Lift value |) -> (match t with | Bool -> print_bool value | Char -> print_char value | String -> print_string value | U8 -> print_u8 value | U16 -> print_u16 value | U32 -> print_u32 value | U64 -> print_u64 value | I8 -> print_i8 value | I16 -> print_i16 value | I32 -> print_i32 value | I64 -> print_i64 value) | Inr (| Array t, (| l, r, s, value |) |) -> (match t with | Bool -> print_lmbuffer_bool l value | Char -> print_lmbuffer_char l value | String -> print_lmbuffer_string l value | U8 -> print_lmbuffer_u8 l value | U16 -> print_lmbuffer_u16 l value | U32 -> print_lmbuffer_u32 l value | U64 -> print_lmbuffer_u64 l value | I8 -> print_lmbuffer_i8 l value | I16 -> print_lmbuffer_i16 l value | I32 -> print_lmbuffer_i32 l value | I64 -> print_lmbuffer_i64 l value) | Inr (| Any, (| _, printer, value |) |) -> printer value) [@@__reduce__] let no_inst #a (#b:a -> Type) (f: (#x:a -> b x)) : unit -> #x:a -> b x = fun () -> f [@@__reduce__] let elim_unit_arrow #t (f:unit -> t) : t = f () // let test2 (f: (#a:Type -> a -> a)) : id_t 0 = test f () // let coerce #a (#b: (a -> Type)) ($f: (#x:a -> b x)) (t:Type{norm t == (#x:a -> b x)}) /// `aux frags acc`: This is the main workhorse which interprets a /// parsed format string (`frags`) as a variadic, stateful function [@@__reduce__] noextract inline_for_extraction let rec aux (frags:fragments) (acc:list frag_t) (fp: fragment_printer) : interpret_frags frags acc = match frags with | [] -> let f (l:lift u#0 u#1 unit) : Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) = fp acc in (f <: interpret_frags [] acc) | Frag s :: rest -> coerce (aux rest (Inl s :: acc) fp) | Interpolate (Base t) :: args -> let f (x:base_typ_as_type t) : interpret_frags args (Inr (| Base t, Lift x |) :: acc) = aux args (Inr (| Base t, Lift x |) :: acc) fp in f | Interpolate (Array t) :: rest -> let f : l:UInt32.t -> #r:LB.srel (base_typ_as_type t) -> #s:LB.srel (base_typ_as_type t) -> b:lmbuffer (base_typ_as_type t) r s l -> interpret_frags rest (Inr (| Array t, (| l, r, s, b |) |) :: acc) = fun l #r #s b -> aux rest (Inr (| Array t, (| l, r, s, b |) |) :: acc) fp in f <: interpret_frags (Interpolate (Array t) :: rest) acc | Interpolate Any :: rest -> let f : unit -> #a:Type -> p:(a -> StTrivial unit) -> x:a -> interpret_frags rest (Inr (| Any, (| a, p, x |) |) :: acc) = fun () #a p x -> aux rest (Inr (| Any, (| a, p, x |) |) :: acc) fp in elim_unit_arrow (no_inst (f ()) <: (unit -> interpret_frags (Interpolate Any :: rest) acc)) /// `format_string` : A valid format string is one that can be successfully parsed [@@__reduce__] noextract let format_string = s:string{normal #bool (Some? (parse_format_string s))} /// `interpret_format_string` parses a string into fragments and then /// interprets it as a type [@@__reduce__] noextract let interpret_format_string (s:format_string) : Type = interpret_frags (Some?.v (parse_format_string s)) [] /// `printf'`: Almost there ... this has a variadic type /// and calls the actual printers for all its arguments. /// /// Note, the `normalize_term` in its body is crucial. It's what /// allows the term to be specialized at extraction time. noextract inline_for_extraction let printf' (s:format_string) : interpret_format_string s = normalize_term (match parse_format_string s with | Some frags -> aux frags [] print_frags) /// `intro_normal_f`: a technical gadget to introduce /// implicit normalization in the domain and co-domain of a function type noextract inline_for_extraction let intro_normal_f (#a:Type) (b: (a -> Type)) (f:(x:a -> b x)) : (x:(normal a) -> normal (b x)) = f /// `printf`: The main function has type /// `s:normal format_string -> normal (interpret_format_string s)` /// Note: /// This is the type F* infers for it and it is best to leave it that way /// rather then writing it down and asking F* to re-check what it inferred. /// /// Annotating it results in a needless additional proof obligation to /// equate types after they are partially reduced, which is pointless. noextract inline_for_extraction val printf : s:normal format_string -> normal (interpret_format_string s) let printf = intro_normal_f #format_string interpret_format_string printf' /// `skip`: We also provide `skip`, a function that has the same type as printf /// but normalizes to `()`, i.e., it prints nothing. This is useful for conditional /// printing in debug code, for instance. noextract inline_for_extraction let skip' (s:format_string) : interpret_format_string s = normalize_term (match parse_format_string s with | Some frags -> aux frags [] (fun _ -> ())) noextract inline_for_extraction val skip : s:normal format_string -> normal (interpret_format_string s) let skip = intro_normal_f #format_string interpret_format_string skip' /// `test`: A small test function /// Running `fstar --codegen OCaml LowStar.Printf.fst --extract LowStar.Printf` /// produces the following for the body of this function /// ``` /// print_string "Hello "; /// print_bool true; /// print_string " Low* "; /// print_u64 m; /// print_string " Printf "; /// print_lmbuffer_bool l () () x; /// print_string " "; /// print_string "bye" /// ``` let test (m:UInt64.t) (l:UInt32.t) (#r:_) (#s:_) (x:LB.mbuffer bool r s{LB.len x = l}) : Stack unit (requires (fun h0 -> LB.live h0 x)) (ensures (fun h0 _ h1 -> h0 == h1)) = printf "Hello %b Low* %uL Printf %xb %s" true //%b boolean m //%uL u64 l x //%xb (buffer bool) "bye" done //dummy universe coercion let test2 (x:(int * int)) (print_pair:(int * int) -> StTrivial unit) : Stack unit (requires (fun h0 -> True)) (ensures (fun h0 _ h1 -> h0 == h1)) = printf "Hello pair %a" print_pair x done let test3 (m:UInt64.t) (l:UInt32.t) (#r:_) (#s:_) (x:LB.mbuffer bool r s{LB.len x = l}) : Stack unit (requires (fun h0 -> LB.live h0 x))
false
false
LowStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test3 (m: UInt64.t) (l: UInt32.t) (#r #s: _) (x: LB.mbuffer bool r s {LB.len x = l}) : Stack unit (requires (fun h0 -> LB.live h0 x)) (ensures (fun h0 _ h1 -> h0 == h1))
[]
LowStar.Printf.test3
{ "file_name": "ulib/LowStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
m: FStar.UInt64.t -> l: FStar.UInt32.t -> x: LowStar.Monotonic.Buffer.mbuffer Prims.bool r s {LowStar.Monotonic.Buffer.len x = l} -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 18, "end_line": 538, "start_col": 4, "start_line": 533 }
FStar.HyperStack.ST.Stack
val test (m: UInt64.t) (l: UInt32.t) (#r #s: _) (x: LB.mbuffer bool r s {LB.len x = l}) : Stack unit (requires (fun h0 -> LB.live h0 x)) (ensures (fun h0 _ h1 -> h0 == h1))
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "LB" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test (m:UInt64.t) (l:UInt32.t) (#r:_) (#s:_) (x:LB.mbuffer bool r s{LB.len x = l}) : Stack unit (requires (fun h0 -> LB.live h0 x)) (ensures (fun h0 _ h1 -> h0 == h1)) = printf "Hello %b Low* %uL Printf %xb %s" true //%b boolean m //%uL u64 l x //%xb (buffer bool) "bye" done
val test (m: UInt64.t) (l: UInt32.t) (#r #s: _) (x: LB.mbuffer bool r s {LB.len x = l}) : Stack unit (requires (fun h0 -> LB.live h0 x)) (ensures (fun h0 _ h1 -> h0 == h1)) let test (m: UInt64.t) (l: UInt32.t) (#r #s: _) (x: LB.mbuffer bool r s {LB.len x = l}) : Stack unit (requires (fun h0 -> LB.live h0 x)) (ensures (fun h0 _ h1 -> h0 == h1)) =
true
null
false
printf "Hello %b Low* %uL Printf %xb %s" true m l x "bye" done
{ "checked_file": "LowStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked", "FStar.BigOps.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Printf.fst" }
[]
[ "FStar.UInt64.t", "FStar.UInt32.t", "LowStar.Monotonic.Buffer.srel", "Prims.bool", "LowStar.Monotonic.Buffer.mbuffer", "Prims.b2t", "Prims.op_Equality", "LowStar.Monotonic.Buffer.len", "LowStar.Printf.printf", "LowStar.Printf.done", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "LowStar.Monotonic.Buffer.live", "Prims.eq2" ]
[]
(* 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 LowStar.Printf /// This module provides imperative printing functions for several /// primitive Low* types, including /// -- booleans (%b) /// -- characters (%c) /// -- strings (%s) /// -- machine integers /// (UInt8.t as %uy, UInt16.t as %us, UInt32.t as %ul, and UInt64.t as %uL; /// Int8.t as %y, Int16.t as %i, Int32.t as %l , and Int64.t as %L) /// -- and arrays (aka buffers) of these base types formatted /// as %xN, where N is the format specifier for the array element type /// e.g., %xuy for buffers of UInt8.t /// The main function of this module is `printf` /// There are a few main differences relative to C printf /// -- The format specifiers are different (see above) /// /// -- For technical reasons explained below, an extra dummy /// argument `done` has to be provided at the end for the /// computation to have any effect. /// /// E.g., one must write /// `printf "%b %c" true 'c' done` /// rather than just /// `printf "%b %c" true 'c'` /// /// -- When printing arrays, two arguments must be passed; the /// length of the array fragment to be formatted and the array /// itself /// /// -- When extracted, rather than producing a C `printf` (which /// does not, e.g., support printing of dynamically sized /// arrays), our `printf` is specialized to a sequence of calls /// to primitive printers for each supported type /// /// Before diving into the technical details of how this module works, /// you might want to see a sample usage at the very end of this file. open FStar.Char open FStar.String open FStar.HyperStack.ST module L = FStar.List.Tot module LB = LowStar.Monotonic.Buffer /// `lmbuffer a r s l` is /// - a monotonic buffer of `a` /// - governed by preorders `r` and `s` /// - with length `l` let lmbuffer a r s l = b:LB.mbuffer a r s{ LB.len b == l } /// `StTrivial`: A effect abbreviation for a stateful computation /// with no precondition, and which does not change the state effect StTrivial (a:Type) = Stack a (requires fun h -> True) (ensures fun h0 _ h1 -> h0==h1) /// `StBuf a b`: A effect abbreviation for a stateful computation /// that may read `b` does not change the state effect StBuf (a:Type) #t #r #s #l (b:lmbuffer t r s l) = Stack a (requires fun h -> LB.live h b) (ensures (fun h0 _ h1 -> h0 == h1)) /// Primitive printers for all the types supported by this module assume val print_string: string -> StTrivial unit assume val print_char : char -> StTrivial unit assume val print_u8 : UInt8.t -> StTrivial unit assume val print_u16 : UInt16.t -> StTrivial unit assume val print_u32 : UInt32.t -> StTrivial unit assume val print_u64 : UInt64.t -> StTrivial unit assume val print_i8 : Int8.t -> StTrivial unit assume val print_i16 : Int16.t -> StTrivial unit assume val print_i32 : Int32.t -> StTrivial unit assume val print_i64 : Int64.t -> StTrivial unit assume val print_bool : bool -> StTrivial unit assume val print_lmbuffer_bool (l:_) (#r:_) (#s:_) (b:lmbuffer bool r s l) : StBuf unit b assume val print_lmbuffer_char (l:_) (#r:_) (#s:_) (b:lmbuffer char r s l) : StBuf unit b assume val print_lmbuffer_string (l:_) (#r:_) (#s:_) (b:lmbuffer string r s l) : StBuf unit b assume val print_lmbuffer_u8 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt8.t r s l) : StBuf unit b assume val print_lmbuffer_u16 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt16.t r s l) : StBuf unit b assume val print_lmbuffer_u32 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt32.t r s l) : StBuf unit b assume val print_lmbuffer_u64 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt64.t r s l) : StBuf unit b assume val print_lmbuffer_i8 (l:_) (#r:_) (#s:_) (b:lmbuffer Int8.t r s l) : StBuf unit b assume val print_lmbuffer_i16 (l:_) (#r:_) (#s:_) (b:lmbuffer Int16.t r s l) : StBuf unit b assume val print_lmbuffer_i32 (l:_) (#r:_) (#s:_) (b:lmbuffer Int32.t r s l) : StBuf unit b assume val print_lmbuffer_i64 (l:_) (#r:_) (#s:_) (b:lmbuffer Int64.t r s l) : StBuf unit b /// An attribute to control reduction noextract irreducible let __reduce__ = unit /// Base types supported so far noextract type base_typ = | Bool | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 /// Argument types are base types and arrays thereof /// Or polymorphic arguments specified by "%a" noextract type arg = | Base of base_typ | Array of base_typ | Any /// Interpreting a `base_typ` as a type [@@__reduce__] noextract let base_typ_as_type (b:base_typ) : Type0 = match b with | Bool -> bool | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t /// `fragment`: A format string is parsed into a list of fragments of /// string literals and other arguments that need to be spliced in /// (interpolated) noextract type fragment = | Frag of string | Interpolate of arg noextract let fragments = list fragment /// `parse_format s`: /// Parses a list of characters in a format string into a list of fragments /// Or None, in case the format string is invalid [@@__reduce__] noextract inline_for_extraction let rec parse_format (s:list char) : Tot (option fragments) (decreases (L.length s)) = let add_dir (d:arg) (ods : option fragments) = match ods with | None -> None | Some ds -> Some (Interpolate d::ds) in let head_buffer (ods:option fragments) = match ods with | Some (Interpolate (Base t) :: rest) -> Some (Interpolate (Array t) :: rest) | _ -> None in let cons_frag (c:char) (ods:option fragments) = match ods with | Some (Frag s::rest) -> Some (Frag (string_of_list (c :: list_of_string s)) :: rest) | Some rest -> Some (Frag (string_of_list [c]) :: rest) | _ -> None in match s with | [] -> Some [] | ['%'] -> None // %a... polymorphic arguments and preceded by their printers | '%' :: 'a' :: s' -> add_dir Any (parse_format s') // %x... arrays of base types | '%' :: 'x' :: s' -> head_buffer (parse_format ('%' :: s')) // %u ... Unsigned integers | '%' :: 'u' :: s' -> begin match s' with | 'y' :: s'' -> add_dir (Base U8) (parse_format s'') | 's' :: s'' -> add_dir (Base U16) (parse_format s'') | 'l' :: s'' -> add_dir (Base U32) (parse_format s'') | 'L' :: s'' -> add_dir (Base U64) (parse_format s'') | _ -> None end | '%' :: c :: s' -> begin match c with | '%' -> cons_frag '%' (parse_format s') | 'b' -> add_dir (Base Bool) (parse_format s') | 'c' -> add_dir (Base Char) (parse_format s') | 's' -> add_dir (Base String) (parse_format s') | 'y' -> add_dir (Base I8) (parse_format s') | 'i' -> add_dir (Base I16) (parse_format s') | 'l' -> add_dir (Base I32) (parse_format s') | 'L' -> add_dir (Base I64) (parse_format s') | _ -> None end | c :: s' -> cons_frag c (parse_format s') /// `parse_format_string`: a wrapper around `parse_format` [@@__reduce__] noextract inline_for_extraction let parse_format_string (s:string) : option fragments = parse_format (list_of_string s) /// `lift a` lifts the type `a` to a higher universe noextract type lift (a:Type u#a) : Type u#(max a b) = | Lift : a -> lift a /// `done` is a `unit` in universe 1 noextract let done : lift unit = Lift u#0 u#1 () /// `arg_t`: interpreting an argument as a type /// (in universe 1) since it is polymorphic in the preorders of a buffer /// GM: Somehow, this needs to be a `let rec` (even if it not really recursive) /// or print_frags fails to verify. I don't know why; the generated /// VC and its encoding seem identical (modulo hash consing in the /// latter). [@@__reduce__] noextract let rec arg_t (a:arg) : Type u#1 = match a with | Base t -> lift (base_typ_as_type t) | Array t -> (l:UInt32.t & r:_ & s:_ & lmbuffer (base_typ_as_type t) r s l) | Any -> (a:Type0 & (a -> StTrivial unit) & a) /// `frag_t`: a fragment is either a string literal or a argument to be interpolated noextract let frag_t = either string (a:arg & arg_t a) /// `live_frags h l` is a liveness predicate on all the buffers in `l` [@@__reduce__] noextract let rec live_frags (h:_) (l:list frag_t) : prop = match l with | [] -> True | Inl _ :: rest -> live_frags h rest | Inr a :: rest -> (match a with | (| Base _, _ |) -> live_frags h rest | (| Any, _ |) -> live_frags h rest | (| Array _, (| _, _, _, b |) |) -> LB.live h b /\ live_frags h rest) /// `interpret_frags` interprets a list of fragments as a Low* function type /// Note `l` is the fragments in L-to-R order (i.e., parsing order) /// `acc` accumulates the fragment values in reverse order [@@__reduce__] noextract let rec interpret_frags (l:fragments) (acc:list frag_t) : Type u#1 = match l with | [] -> // Always a dummy argument at the end // Ensures that all cases of this match // have the same universe, i.e., u#1 lift u#0 u#1 unit -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) | Interpolate (Base t) :: args -> // Base types are simple: we just take one more argument x:base_typ_as_type t -> interpret_frags args (Inr (| Base t, Lift x |) :: acc) | Interpolate (Array t) :: args -> // Arrays are implicitly polymorphic in their preorders `r` and `s` // which is what forces us to be in universe 1 // Note, the length `l` is explicit l:UInt32.t -> #r:LB.srel (base_typ_as_type t) -> #s:LB.srel (base_typ_as_type t) -> b:lmbuffer (base_typ_as_type t) r s l -> interpret_frags args (Inr (| Array t, (| l, r, s, b |) |) :: acc) | Interpolate Any :: args -> #a:Type0 -> p:(a -> StTrivial unit) -> x:a -> interpret_frags args (Inr (| Any, (| a, p, x |) |) :: acc) | Frag s :: args -> // Literal fragments do not incur an additional argument // We just accumulate them and recur interpret_frags args (Inl s :: acc) /// `normal` A normalization marker with very specific steps enabled noextract unfold let normal (#a:Type) (x:a) : a = FStar.Pervasives.norm [iota; zeta; delta_attr [`%__reduce__; `%BigOps.__reduce__]; delta_only [`%Base?; `%Array?; `%Some?; `%Some?.v; `%list_of_string]; primops; simplify] x /// `coerce`: A utility to trigger extensional equality of types noextract let coerce (x:'a{'a == 'b}) : 'b = x /// `fragment_printer`: The type of a printer of fragments noextract let fragment_printer = (acc:list frag_t) -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) /// `print_frags`: Having accumulated all the pieces of a format /// string and the arguments to the printed (i.e., the `list frag_t`), /// this function does the actual work of printing them all using the /// primitive printers noextract inline_for_extraction let rec print_frags (acc:list frag_t) : Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) = match acc with | [] -> () | hd::tl -> print_frags tl; (match hd with | Inl s -> print_string s | Inr (| Base t, Lift value |) -> (match t with | Bool -> print_bool value | Char -> print_char value | String -> print_string value | U8 -> print_u8 value | U16 -> print_u16 value | U32 -> print_u32 value | U64 -> print_u64 value | I8 -> print_i8 value | I16 -> print_i16 value | I32 -> print_i32 value | I64 -> print_i64 value) | Inr (| Array t, (| l, r, s, value |) |) -> (match t with | Bool -> print_lmbuffer_bool l value | Char -> print_lmbuffer_char l value | String -> print_lmbuffer_string l value | U8 -> print_lmbuffer_u8 l value | U16 -> print_lmbuffer_u16 l value | U32 -> print_lmbuffer_u32 l value | U64 -> print_lmbuffer_u64 l value | I8 -> print_lmbuffer_i8 l value | I16 -> print_lmbuffer_i16 l value | I32 -> print_lmbuffer_i32 l value | I64 -> print_lmbuffer_i64 l value) | Inr (| Any, (| _, printer, value |) |) -> printer value) [@@__reduce__] let no_inst #a (#b:a -> Type) (f: (#x:a -> b x)) : unit -> #x:a -> b x = fun () -> f [@@__reduce__] let elim_unit_arrow #t (f:unit -> t) : t = f () // let test2 (f: (#a:Type -> a -> a)) : id_t 0 = test f () // let coerce #a (#b: (a -> Type)) ($f: (#x:a -> b x)) (t:Type{norm t == (#x:a -> b x)}) /// `aux frags acc`: This is the main workhorse which interprets a /// parsed format string (`frags`) as a variadic, stateful function [@@__reduce__] noextract inline_for_extraction let rec aux (frags:fragments) (acc:list frag_t) (fp: fragment_printer) : interpret_frags frags acc = match frags with | [] -> let f (l:lift u#0 u#1 unit) : Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) = fp acc in (f <: interpret_frags [] acc) | Frag s :: rest -> coerce (aux rest (Inl s :: acc) fp) | Interpolate (Base t) :: args -> let f (x:base_typ_as_type t) : interpret_frags args (Inr (| Base t, Lift x |) :: acc) = aux args (Inr (| Base t, Lift x |) :: acc) fp in f | Interpolate (Array t) :: rest -> let f : l:UInt32.t -> #r:LB.srel (base_typ_as_type t) -> #s:LB.srel (base_typ_as_type t) -> b:lmbuffer (base_typ_as_type t) r s l -> interpret_frags rest (Inr (| Array t, (| l, r, s, b |) |) :: acc) = fun l #r #s b -> aux rest (Inr (| Array t, (| l, r, s, b |) |) :: acc) fp in f <: interpret_frags (Interpolate (Array t) :: rest) acc | Interpolate Any :: rest -> let f : unit -> #a:Type -> p:(a -> StTrivial unit) -> x:a -> interpret_frags rest (Inr (| Any, (| a, p, x |) |) :: acc) = fun () #a p x -> aux rest (Inr (| Any, (| a, p, x |) |) :: acc) fp in elim_unit_arrow (no_inst (f ()) <: (unit -> interpret_frags (Interpolate Any :: rest) acc)) /// `format_string` : A valid format string is one that can be successfully parsed [@@__reduce__] noextract let format_string = s:string{normal #bool (Some? (parse_format_string s))} /// `interpret_format_string` parses a string into fragments and then /// interprets it as a type [@@__reduce__] noextract let interpret_format_string (s:format_string) : Type = interpret_frags (Some?.v (parse_format_string s)) [] /// `printf'`: Almost there ... this has a variadic type /// and calls the actual printers for all its arguments. /// /// Note, the `normalize_term` in its body is crucial. It's what /// allows the term to be specialized at extraction time. noextract inline_for_extraction let printf' (s:format_string) : interpret_format_string s = normalize_term (match parse_format_string s with | Some frags -> aux frags [] print_frags) /// `intro_normal_f`: a technical gadget to introduce /// implicit normalization in the domain and co-domain of a function type noextract inline_for_extraction let intro_normal_f (#a:Type) (b: (a -> Type)) (f:(x:a -> b x)) : (x:(normal a) -> normal (b x)) = f /// `printf`: The main function has type /// `s:normal format_string -> normal (interpret_format_string s)` /// Note: /// This is the type F* infers for it and it is best to leave it that way /// rather then writing it down and asking F* to re-check what it inferred. /// /// Annotating it results in a needless additional proof obligation to /// equate types after they are partially reduced, which is pointless. noextract inline_for_extraction val printf : s:normal format_string -> normal (interpret_format_string s) let printf = intro_normal_f #format_string interpret_format_string printf' /// `skip`: We also provide `skip`, a function that has the same type as printf /// but normalizes to `()`, i.e., it prints nothing. This is useful for conditional /// printing in debug code, for instance. noextract inline_for_extraction let skip' (s:format_string) : interpret_format_string s = normalize_term (match parse_format_string s with | Some frags -> aux frags [] (fun _ -> ())) noextract inline_for_extraction val skip : s:normal format_string -> normal (interpret_format_string s) let skip = intro_normal_f #format_string interpret_format_string skip' /// `test`: A small test function /// Running `fstar --codegen OCaml LowStar.Printf.fst --extract LowStar.Printf` /// produces the following for the body of this function /// ``` /// print_string "Hello "; /// print_bool true; /// print_string " Low* "; /// print_u64 m; /// print_string " Printf "; /// print_lmbuffer_bool l () () x; /// print_string " "; /// print_string "bye" /// ``` let test (m:UInt64.t) (l:UInt32.t) (#r:_) (#s:_) (x:LB.mbuffer bool r s{LB.len x = l}) : Stack unit (requires (fun h0 -> LB.live h0 x))
false
false
LowStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test (m: UInt64.t) (l: UInt32.t) (#r #s: _) (x: LB.mbuffer bool r s {LB.len x = l}) : Stack unit (requires (fun h0 -> LB.live h0 x)) (ensures (fun h0 _ h1 -> h0 == h1))
[]
LowStar.Printf.test
{ "file_name": "ulib/LowStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
m: FStar.UInt64.t -> l: FStar.UInt32.t -> x: LowStar.Monotonic.Buffer.mbuffer Prims.bool r s {LowStar.Monotonic.Buffer.len x = l} -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 18, "end_line": 521, "start_col": 4, "start_line": 516 }
FStar.HyperStack.ST.Stack
val print_frags (acc: list frag_t) : Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1)
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "LB" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec print_frags (acc:list frag_t) : Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) = match acc with | [] -> () | hd::tl -> print_frags tl; (match hd with | Inl s -> print_string s | Inr (| Base t, Lift value |) -> (match t with | Bool -> print_bool value | Char -> print_char value | String -> print_string value | U8 -> print_u8 value | U16 -> print_u16 value | U32 -> print_u32 value | U64 -> print_u64 value | I8 -> print_i8 value | I16 -> print_i16 value | I32 -> print_i32 value | I64 -> print_i64 value) | Inr (| Array t, (| l, r, s, value |) |) -> (match t with | Bool -> print_lmbuffer_bool l value | Char -> print_lmbuffer_char l value | String -> print_lmbuffer_string l value | U8 -> print_lmbuffer_u8 l value | U16 -> print_lmbuffer_u16 l value | U32 -> print_lmbuffer_u32 l value | U64 -> print_lmbuffer_u64 l value | I8 -> print_lmbuffer_i8 l value | I16 -> print_lmbuffer_i16 l value | I32 -> print_lmbuffer_i32 l value | I64 -> print_lmbuffer_i64 l value) | Inr (| Any, (| _, printer, value |) |) -> printer value)
val print_frags (acc: list frag_t) : Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) let rec print_frags (acc: list frag_t) : Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) =
true
null
false
match acc with | [] -> () | hd :: tl -> print_frags tl; (match hd with | Inl s -> print_string s | Inr (| Base t , Lift value |) -> (match t with | Bool -> print_bool value | Char -> print_char value | String -> print_string value | U8 -> print_u8 value | U16 -> print_u16 value | U32 -> print_u32 value | U64 -> print_u64 value | I8 -> print_i8 value | I16 -> print_i16 value | I32 -> print_i32 value | I64 -> print_i64 value) | Inr (| Array t , (| l , r , s , value |) |) -> (match t with | Bool -> print_lmbuffer_bool l value | Char -> print_lmbuffer_char l value | String -> print_lmbuffer_string l value | U8 -> print_lmbuffer_u8 l value | U16 -> print_lmbuffer_u16 l value | U32 -> print_lmbuffer_u32 l value | U64 -> print_lmbuffer_u64 l value | I8 -> print_lmbuffer_i8 l value | I16 -> print_lmbuffer_i16 l value | I32 -> print_lmbuffer_i32 l value | I64 -> print_lmbuffer_i64 l value) | Inr (| Any , (| _ , printer , value |) |) -> printer value)
{ "checked_file": "LowStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked", "FStar.BigOps.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Printf.fst" }
[]
[ "Prims.list", "LowStar.Printf.frag_t", "Prims.unit", "Prims.string", "LowStar.Printf.print_string", "LowStar.Printf.base_typ", "LowStar.Printf.base_typ_as_type", "LowStar.Printf.print_bool", "LowStar.Printf.print_char", "LowStar.Printf.print_u8", "LowStar.Printf.print_u16", "LowStar.Printf.print_u32", "LowStar.Printf.print_u64", "LowStar.Printf.print_i8", "LowStar.Printf.print_i16", "LowStar.Printf.print_i32", "LowStar.Printf.print_i64", "FStar.UInt32.t", "LowStar.Monotonic.Buffer.srel", "LowStar.Printf.lmbuffer", "LowStar.Printf.print_lmbuffer_bool", "LowStar.Printf.print_lmbuffer_char", "LowStar.Printf.print_lmbuffer_string", "LowStar.Printf.print_lmbuffer_u8", "LowStar.Printf.print_lmbuffer_u16", "LowStar.Printf.print_lmbuffer_u32", "LowStar.Printf.print_lmbuffer_u64", "LowStar.Printf.print_lmbuffer_i8", "LowStar.Printf.print_lmbuffer_i16", "LowStar.Printf.print_lmbuffer_i32", "LowStar.Printf.print_lmbuffer_i64", "LowStar.Printf.print_frags", "FStar.Monotonic.HyperStack.mem", "LowStar.Printf.live_frags", "Prims.eq2" ]
[]
(* 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 LowStar.Printf /// This module provides imperative printing functions for several /// primitive Low* types, including /// -- booleans (%b) /// -- characters (%c) /// -- strings (%s) /// -- machine integers /// (UInt8.t as %uy, UInt16.t as %us, UInt32.t as %ul, and UInt64.t as %uL; /// Int8.t as %y, Int16.t as %i, Int32.t as %l , and Int64.t as %L) /// -- and arrays (aka buffers) of these base types formatted /// as %xN, where N is the format specifier for the array element type /// e.g., %xuy for buffers of UInt8.t /// The main function of this module is `printf` /// There are a few main differences relative to C printf /// -- The format specifiers are different (see above) /// /// -- For technical reasons explained below, an extra dummy /// argument `done` has to be provided at the end for the /// computation to have any effect. /// /// E.g., one must write /// `printf "%b %c" true 'c' done` /// rather than just /// `printf "%b %c" true 'c'` /// /// -- When printing arrays, two arguments must be passed; the /// length of the array fragment to be formatted and the array /// itself /// /// -- When extracted, rather than producing a C `printf` (which /// does not, e.g., support printing of dynamically sized /// arrays), our `printf` is specialized to a sequence of calls /// to primitive printers for each supported type /// /// Before diving into the technical details of how this module works, /// you might want to see a sample usage at the very end of this file. open FStar.Char open FStar.String open FStar.HyperStack.ST module L = FStar.List.Tot module LB = LowStar.Monotonic.Buffer /// `lmbuffer a r s l` is /// - a monotonic buffer of `a` /// - governed by preorders `r` and `s` /// - with length `l` let lmbuffer a r s l = b:LB.mbuffer a r s{ LB.len b == l } /// `StTrivial`: A effect abbreviation for a stateful computation /// with no precondition, and which does not change the state effect StTrivial (a:Type) = Stack a (requires fun h -> True) (ensures fun h0 _ h1 -> h0==h1) /// `StBuf a b`: A effect abbreviation for a stateful computation /// that may read `b` does not change the state effect StBuf (a:Type) #t #r #s #l (b:lmbuffer t r s l) = Stack a (requires fun h -> LB.live h b) (ensures (fun h0 _ h1 -> h0 == h1)) /// Primitive printers for all the types supported by this module assume val print_string: string -> StTrivial unit assume val print_char : char -> StTrivial unit assume val print_u8 : UInt8.t -> StTrivial unit assume val print_u16 : UInt16.t -> StTrivial unit assume val print_u32 : UInt32.t -> StTrivial unit assume val print_u64 : UInt64.t -> StTrivial unit assume val print_i8 : Int8.t -> StTrivial unit assume val print_i16 : Int16.t -> StTrivial unit assume val print_i32 : Int32.t -> StTrivial unit assume val print_i64 : Int64.t -> StTrivial unit assume val print_bool : bool -> StTrivial unit assume val print_lmbuffer_bool (l:_) (#r:_) (#s:_) (b:lmbuffer bool r s l) : StBuf unit b assume val print_lmbuffer_char (l:_) (#r:_) (#s:_) (b:lmbuffer char r s l) : StBuf unit b assume val print_lmbuffer_string (l:_) (#r:_) (#s:_) (b:lmbuffer string r s l) : StBuf unit b assume val print_lmbuffer_u8 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt8.t r s l) : StBuf unit b assume val print_lmbuffer_u16 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt16.t r s l) : StBuf unit b assume val print_lmbuffer_u32 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt32.t r s l) : StBuf unit b assume val print_lmbuffer_u64 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt64.t r s l) : StBuf unit b assume val print_lmbuffer_i8 (l:_) (#r:_) (#s:_) (b:lmbuffer Int8.t r s l) : StBuf unit b assume val print_lmbuffer_i16 (l:_) (#r:_) (#s:_) (b:lmbuffer Int16.t r s l) : StBuf unit b assume val print_lmbuffer_i32 (l:_) (#r:_) (#s:_) (b:lmbuffer Int32.t r s l) : StBuf unit b assume val print_lmbuffer_i64 (l:_) (#r:_) (#s:_) (b:lmbuffer Int64.t r s l) : StBuf unit b /// An attribute to control reduction noextract irreducible let __reduce__ = unit /// Base types supported so far noextract type base_typ = | Bool | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 /// Argument types are base types and arrays thereof /// Or polymorphic arguments specified by "%a" noextract type arg = | Base of base_typ | Array of base_typ | Any /// Interpreting a `base_typ` as a type [@@__reduce__] noextract let base_typ_as_type (b:base_typ) : Type0 = match b with | Bool -> bool | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t /// `fragment`: A format string is parsed into a list of fragments of /// string literals and other arguments that need to be spliced in /// (interpolated) noextract type fragment = | Frag of string | Interpolate of arg noextract let fragments = list fragment /// `parse_format s`: /// Parses a list of characters in a format string into a list of fragments /// Or None, in case the format string is invalid [@@__reduce__] noextract inline_for_extraction let rec parse_format (s:list char) : Tot (option fragments) (decreases (L.length s)) = let add_dir (d:arg) (ods : option fragments) = match ods with | None -> None | Some ds -> Some (Interpolate d::ds) in let head_buffer (ods:option fragments) = match ods with | Some (Interpolate (Base t) :: rest) -> Some (Interpolate (Array t) :: rest) | _ -> None in let cons_frag (c:char) (ods:option fragments) = match ods with | Some (Frag s::rest) -> Some (Frag (string_of_list (c :: list_of_string s)) :: rest) | Some rest -> Some (Frag (string_of_list [c]) :: rest) | _ -> None in match s with | [] -> Some [] | ['%'] -> None // %a... polymorphic arguments and preceded by their printers | '%' :: 'a' :: s' -> add_dir Any (parse_format s') // %x... arrays of base types | '%' :: 'x' :: s' -> head_buffer (parse_format ('%' :: s')) // %u ... Unsigned integers | '%' :: 'u' :: s' -> begin match s' with | 'y' :: s'' -> add_dir (Base U8) (parse_format s'') | 's' :: s'' -> add_dir (Base U16) (parse_format s'') | 'l' :: s'' -> add_dir (Base U32) (parse_format s'') | 'L' :: s'' -> add_dir (Base U64) (parse_format s'') | _ -> None end | '%' :: c :: s' -> begin match c with | '%' -> cons_frag '%' (parse_format s') | 'b' -> add_dir (Base Bool) (parse_format s') | 'c' -> add_dir (Base Char) (parse_format s') | 's' -> add_dir (Base String) (parse_format s') | 'y' -> add_dir (Base I8) (parse_format s') | 'i' -> add_dir (Base I16) (parse_format s') | 'l' -> add_dir (Base I32) (parse_format s') | 'L' -> add_dir (Base I64) (parse_format s') | _ -> None end | c :: s' -> cons_frag c (parse_format s') /// `parse_format_string`: a wrapper around `parse_format` [@@__reduce__] noextract inline_for_extraction let parse_format_string (s:string) : option fragments = parse_format (list_of_string s) /// `lift a` lifts the type `a` to a higher universe noextract type lift (a:Type u#a) : Type u#(max a b) = | Lift : a -> lift a /// `done` is a `unit` in universe 1 noextract let done : lift unit = Lift u#0 u#1 () /// `arg_t`: interpreting an argument as a type /// (in universe 1) since it is polymorphic in the preorders of a buffer /// GM: Somehow, this needs to be a `let rec` (even if it not really recursive) /// or print_frags fails to verify. I don't know why; the generated /// VC and its encoding seem identical (modulo hash consing in the /// latter). [@@__reduce__] noextract let rec arg_t (a:arg) : Type u#1 = match a with | Base t -> lift (base_typ_as_type t) | Array t -> (l:UInt32.t & r:_ & s:_ & lmbuffer (base_typ_as_type t) r s l) | Any -> (a:Type0 & (a -> StTrivial unit) & a) /// `frag_t`: a fragment is either a string literal or a argument to be interpolated noextract let frag_t = either string (a:arg & arg_t a) /// `live_frags h l` is a liveness predicate on all the buffers in `l` [@@__reduce__] noextract let rec live_frags (h:_) (l:list frag_t) : prop = match l with | [] -> True | Inl _ :: rest -> live_frags h rest | Inr a :: rest -> (match a with | (| Base _, _ |) -> live_frags h rest | (| Any, _ |) -> live_frags h rest | (| Array _, (| _, _, _, b |) |) -> LB.live h b /\ live_frags h rest) /// `interpret_frags` interprets a list of fragments as a Low* function type /// Note `l` is the fragments in L-to-R order (i.e., parsing order) /// `acc` accumulates the fragment values in reverse order [@@__reduce__] noextract let rec interpret_frags (l:fragments) (acc:list frag_t) : Type u#1 = match l with | [] -> // Always a dummy argument at the end // Ensures that all cases of this match // have the same universe, i.e., u#1 lift u#0 u#1 unit -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) | Interpolate (Base t) :: args -> // Base types are simple: we just take one more argument x:base_typ_as_type t -> interpret_frags args (Inr (| Base t, Lift x |) :: acc) | Interpolate (Array t) :: args -> // Arrays are implicitly polymorphic in their preorders `r` and `s` // which is what forces us to be in universe 1 // Note, the length `l` is explicit l:UInt32.t -> #r:LB.srel (base_typ_as_type t) -> #s:LB.srel (base_typ_as_type t) -> b:lmbuffer (base_typ_as_type t) r s l -> interpret_frags args (Inr (| Array t, (| l, r, s, b |) |) :: acc) | Interpolate Any :: args -> #a:Type0 -> p:(a -> StTrivial unit) -> x:a -> interpret_frags args (Inr (| Any, (| a, p, x |) |) :: acc) | Frag s :: args -> // Literal fragments do not incur an additional argument // We just accumulate them and recur interpret_frags args (Inl s :: acc) /// `normal` A normalization marker with very specific steps enabled noextract unfold let normal (#a:Type) (x:a) : a = FStar.Pervasives.norm [iota; zeta; delta_attr [`%__reduce__; `%BigOps.__reduce__]; delta_only [`%Base?; `%Array?; `%Some?; `%Some?.v; `%list_of_string]; primops; simplify] x /// `coerce`: A utility to trigger extensional equality of types noextract let coerce (x:'a{'a == 'b}) : 'b = x /// `fragment_printer`: The type of a printer of fragments noextract let fragment_printer = (acc:list frag_t) -> Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1) /// `print_frags`: Having accumulated all the pieces of a format /// string and the arguments to the printed (i.e., the `list frag_t`), /// this function does the actual work of printing them all using the /// primitive printers noextract inline_for_extraction let rec print_frags (acc:list frag_t) : Stack unit (requires fun h0 -> live_frags h0 acc)
false
false
LowStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val print_frags (acc: list frag_t) : Stack unit (requires fun h0 -> live_frags h0 acc) (ensures fun h0 _ h1 -> h0 == h1)
[ "recursion" ]
LowStar.Printf.print_frags
{ "file_name": "ulib/LowStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
acc: Prims.list LowStar.Printf.frag_t -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 23, "end_line": 386, "start_col": 4, "start_line": 353 }
Prims.Tot
val parse_format (s: list char) : Tot (option fragments) (decreases (L.length s))
[ { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "LB" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec parse_format (s:list char) : Tot (option fragments) (decreases (L.length s)) = let add_dir (d:arg) (ods : option fragments) = match ods with | None -> None | Some ds -> Some (Interpolate d::ds) in let head_buffer (ods:option fragments) = match ods with | Some (Interpolate (Base t) :: rest) -> Some (Interpolate (Array t) :: rest) | _ -> None in let cons_frag (c:char) (ods:option fragments) = match ods with | Some (Frag s::rest) -> Some (Frag (string_of_list (c :: list_of_string s)) :: rest) | Some rest -> Some (Frag (string_of_list [c]) :: rest) | _ -> None in match s with | [] -> Some [] | ['%'] -> None // %a... polymorphic arguments and preceded by their printers | '%' :: 'a' :: s' -> add_dir Any (parse_format s') // %x... arrays of base types | '%' :: 'x' :: s' -> head_buffer (parse_format ('%' :: s')) // %u ... Unsigned integers | '%' :: 'u' :: s' -> begin match s' with | 'y' :: s'' -> add_dir (Base U8) (parse_format s'') | 's' :: s'' -> add_dir (Base U16) (parse_format s'') | 'l' :: s'' -> add_dir (Base U32) (parse_format s'') | 'L' :: s'' -> add_dir (Base U64) (parse_format s'') | _ -> None end | '%' :: c :: s' -> begin match c with | '%' -> cons_frag '%' (parse_format s') | 'b' -> add_dir (Base Bool) (parse_format s') | 'c' -> add_dir (Base Char) (parse_format s') | 's' -> add_dir (Base String) (parse_format s') | 'y' -> add_dir (Base I8) (parse_format s') | 'i' -> add_dir (Base I16) (parse_format s') | 'l' -> add_dir (Base I32) (parse_format s') | 'L' -> add_dir (Base I64) (parse_format s') | _ -> None end | c :: s' -> cons_frag c (parse_format s')
val parse_format (s: list char) : Tot (option fragments) (decreases (L.length s)) let rec parse_format (s: list char) : Tot (option fragments) (decreases (L.length s)) =
false
null
false
let add_dir (d: arg) (ods: option fragments) = match ods with | None -> None | Some ds -> Some (Interpolate d :: ds) in let head_buffer (ods: option fragments) = match ods with | Some (Interpolate (Base t) :: rest) -> Some (Interpolate (Array t) :: rest) | _ -> None in let cons_frag (c: char) (ods: option fragments) = match ods with | Some (Frag s :: rest) -> Some (Frag (string_of_list (c :: list_of_string s)) :: rest) | Some rest -> Some (Frag (string_of_list [c]) :: rest) | _ -> None in match s with | [] -> Some [] | ['%'] -> None | '%' :: 'a' :: s' -> add_dir Any (parse_format s') | '%' :: 'x' :: s' -> head_buffer (parse_format ('%' :: s')) | '%' :: 'u' :: s' -> (match s' with | 'y' :: s'' -> add_dir (Base U8) (parse_format s'') | 's' :: s'' -> add_dir (Base U16) (parse_format s'') | 'l' :: s'' -> add_dir (Base U32) (parse_format s'') | 'L' :: s'' -> add_dir (Base U64) (parse_format s'') | _ -> None) | '%' :: c :: s' -> (match c with | '%' -> cons_frag '%' (parse_format s') | 'b' -> add_dir (Base Bool) (parse_format s') | 'c' -> add_dir (Base Char) (parse_format s') | 's' -> add_dir (Base String) (parse_format s') | 'y' -> add_dir (Base I8) (parse_format s') | 'i' -> add_dir (Base I16) (parse_format s') | 'l' -> add_dir (Base I32) (parse_format s') | 'L' -> add_dir (Base I64) (parse_format s') | _ -> None) | c :: s' -> cons_frag c (parse_format s')
{ "checked_file": "LowStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked", "FStar.BigOps.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Printf.fst" }
[ "total", "" ]
[ "Prims.list", "FStar.String.char", "FStar.Pervasives.Native.Some", "LowStar.Printf.fragments", "Prims.Nil", "LowStar.Printf.fragment", "FStar.Pervasives.Native.None", "LowStar.Printf.Any", "LowStar.Printf.parse_format", "Prims.Cons", "LowStar.Printf.Base", "LowStar.Printf.U8", "LowStar.Printf.U16", "LowStar.Printf.U32", "LowStar.Printf.U64", "FStar.Pervasives.Native.option", "LowStar.Printf.Bool", "LowStar.Printf.Char", "LowStar.Printf.String", "LowStar.Printf.I8", "LowStar.Printf.I16", "LowStar.Printf.I32", "LowStar.Printf.I64", "FStar.Char.char", "Prims.string", "LowStar.Printf.Frag", "FStar.String.string_of_list", "FStar.String.list_of_string", "LowStar.Printf.base_typ", "LowStar.Printf.Interpolate", "LowStar.Printf.Array", "LowStar.Printf.arg" ]
[]
(* 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 LowStar.Printf /// This module provides imperative printing functions for several /// primitive Low* types, including /// -- booleans (%b) /// -- characters (%c) /// -- strings (%s) /// -- machine integers /// (UInt8.t as %uy, UInt16.t as %us, UInt32.t as %ul, and UInt64.t as %uL; /// Int8.t as %y, Int16.t as %i, Int32.t as %l , and Int64.t as %L) /// -- and arrays (aka buffers) of these base types formatted /// as %xN, where N is the format specifier for the array element type /// e.g., %xuy for buffers of UInt8.t /// The main function of this module is `printf` /// There are a few main differences relative to C printf /// -- The format specifiers are different (see above) /// /// -- For technical reasons explained below, an extra dummy /// argument `done` has to be provided at the end for the /// computation to have any effect. /// /// E.g., one must write /// `printf "%b %c" true 'c' done` /// rather than just /// `printf "%b %c" true 'c'` /// /// -- When printing arrays, two arguments must be passed; the /// length of the array fragment to be formatted and the array /// itself /// /// -- When extracted, rather than producing a C `printf` (which /// does not, e.g., support printing of dynamically sized /// arrays), our `printf` is specialized to a sequence of calls /// to primitive printers for each supported type /// /// Before diving into the technical details of how this module works, /// you might want to see a sample usage at the very end of this file. open FStar.Char open FStar.String open FStar.HyperStack.ST module L = FStar.List.Tot module LB = LowStar.Monotonic.Buffer /// `lmbuffer a r s l` is /// - a monotonic buffer of `a` /// - governed by preorders `r` and `s` /// - with length `l` let lmbuffer a r s l = b:LB.mbuffer a r s{ LB.len b == l } /// `StTrivial`: A effect abbreviation for a stateful computation /// with no precondition, and which does not change the state effect StTrivial (a:Type) = Stack a (requires fun h -> True) (ensures fun h0 _ h1 -> h0==h1) /// `StBuf a b`: A effect abbreviation for a stateful computation /// that may read `b` does not change the state effect StBuf (a:Type) #t #r #s #l (b:lmbuffer t r s l) = Stack a (requires fun h -> LB.live h b) (ensures (fun h0 _ h1 -> h0 == h1)) /// Primitive printers for all the types supported by this module assume val print_string: string -> StTrivial unit assume val print_char : char -> StTrivial unit assume val print_u8 : UInt8.t -> StTrivial unit assume val print_u16 : UInt16.t -> StTrivial unit assume val print_u32 : UInt32.t -> StTrivial unit assume val print_u64 : UInt64.t -> StTrivial unit assume val print_i8 : Int8.t -> StTrivial unit assume val print_i16 : Int16.t -> StTrivial unit assume val print_i32 : Int32.t -> StTrivial unit assume val print_i64 : Int64.t -> StTrivial unit assume val print_bool : bool -> StTrivial unit assume val print_lmbuffer_bool (l:_) (#r:_) (#s:_) (b:lmbuffer bool r s l) : StBuf unit b assume val print_lmbuffer_char (l:_) (#r:_) (#s:_) (b:lmbuffer char r s l) : StBuf unit b assume val print_lmbuffer_string (l:_) (#r:_) (#s:_) (b:lmbuffer string r s l) : StBuf unit b assume val print_lmbuffer_u8 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt8.t r s l) : StBuf unit b assume val print_lmbuffer_u16 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt16.t r s l) : StBuf unit b assume val print_lmbuffer_u32 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt32.t r s l) : StBuf unit b assume val print_lmbuffer_u64 (l:_) (#r:_) (#s:_) (b:lmbuffer UInt64.t r s l) : StBuf unit b assume val print_lmbuffer_i8 (l:_) (#r:_) (#s:_) (b:lmbuffer Int8.t r s l) : StBuf unit b assume val print_lmbuffer_i16 (l:_) (#r:_) (#s:_) (b:lmbuffer Int16.t r s l) : StBuf unit b assume val print_lmbuffer_i32 (l:_) (#r:_) (#s:_) (b:lmbuffer Int32.t r s l) : StBuf unit b assume val print_lmbuffer_i64 (l:_) (#r:_) (#s:_) (b:lmbuffer Int64.t r s l) : StBuf unit b /// An attribute to control reduction noextract irreducible let __reduce__ = unit /// Base types supported so far noextract type base_typ = | Bool | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 /// Argument types are base types and arrays thereof /// Or polymorphic arguments specified by "%a" noextract type arg = | Base of base_typ | Array of base_typ | Any /// Interpreting a `base_typ` as a type [@@__reduce__] noextract let base_typ_as_type (b:base_typ) : Type0 = match b with | Bool -> bool | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t /// `fragment`: A format string is parsed into a list of fragments of /// string literals and other arguments that need to be spliced in /// (interpolated) noextract type fragment = | Frag of string | Interpolate of arg noextract let fragments = list fragment /// `parse_format s`: /// Parses a list of characters in a format string into a list of fragments /// Or None, in case the format string is invalid [@@__reduce__] noextract inline_for_extraction let rec parse_format (s:list char) : Tot (option fragments)
false
true
LowStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse_format (s: list char) : Tot (option fragments) (decreases (L.length s))
[ "recursion" ]
LowStar.Printf.parse_format
{ "file_name": "ulib/LowStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s: Prims.list FStar.String.char -> Prims.Tot (FStar.Pervasives.Native.option LowStar.Printf.fragments)
{ "end_col": 34, "end_line": 225, "start_col": 2, "start_line": 173 }
Prims.Tot
val array_literal_inv: #a: Type0 -> n: US.t -> arr: A.array a -> f: (i: US.t{US.v i < US.v n} -> a) -> i: Loops.nat_at_most n -> Seq.seq a -> vprop
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Loops", "short_module": "Loops" }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let array_literal_inv (#a:Type0) (n:US.t) (arr:A.array a) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) : Seq.seq a -> vprop = fun s -> A.pts_to arr full_perm s `star` pure (array_literal_inv_pure n f i s)
val array_literal_inv: #a: Type0 -> n: US.t -> arr: A.array a -> f: (i: US.t{US.v i < US.v n} -> a) -> i: Loops.nat_at_most n -> Seq.seq a -> vprop let array_literal_inv (#a: Type0) (n: US.t) (arr: A.array a) (f: (i: US.t{US.v i < US.v n} -> a)) (i: Loops.nat_at_most n) : Seq.seq a -> vprop =
false
null
false
fun s -> (A.pts_to arr full_perm s) `star` (pure (array_literal_inv_pure n f i s))
{ "checked_file": "Steel.ST.Array.Util.fst.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.Reference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.ST.Effect.fsti.checked", "Steel.ST.Array.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Array.Util.fst" }
[ "total" ]
[ "FStar.SizeT.t", "Steel.ST.Array.array", "Prims.b2t", "Prims.op_LessThan", "FStar.SizeT.v", "Steel.ST.Loops.nat_at_most", "FStar.Seq.Base.seq", "Steel.Effect.Common.star", "Steel.ST.Array.pts_to", "Steel.FractionalPermission.full_perm", "Steel.ST.Util.pure", "Steel.ST.Array.Util.array_literal_inv_pure", "Steel.Effect.Common.vprop" ]
[]
(* Copyright 2021 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.Util module G = FStar.Ghost module US = FStar.SizeT module R = Steel.ST.Reference module A = Steel.ST.Array module Loops = Steel.ST.Loops open Steel.FractionalPermission open Steel.ST.Effect open Steel.ST.Util /// Implementation of array_literal using a for loop let array_literal_inv_pure (#a:Type0) (n:US.t) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) (s:Seq.seq a) : prop = forall (j:nat). (j < i /\ j < Seq.length s) ==> Seq.index s j == f (US.uint_to_t j) [@@ __reduce__] let array_literal_inv (#a:Type0) (n:US.t) (arr:A.array a) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n)
false
false
Steel.ST.Array.Util.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val array_literal_inv: #a: Type0 -> n: US.t -> arr: A.array a -> f: (i: US.t{US.v i < US.v n} -> a) -> i: Loops.nat_at_most n -> Seq.seq a -> vprop
[]
Steel.ST.Array.Util.array_literal_inv
{ "file_name": "lib/steel/Steel.ST.Array.Util.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: FStar.SizeT.t -> arr: Steel.ST.Array.array a -> f: (i: FStar.SizeT.t{FStar.SizeT.v i < FStar.SizeT.v n} -> a) -> i: Steel.ST.Loops.nat_at_most n -> _: FStar.Seq.Base.seq a -> Steel.Effect.Common.vprop
{ "end_col": 41, "end_line": 54, "start_col": 4, "start_line": 51 }
Prims.Tot
val array_literal_inv_pure (#a: Type0) (n: US.t) (f: (i: US.t{US.v i < US.v n} -> a)) (i: Loops.nat_at_most n) (s: Seq.seq a) : prop
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Loops", "short_module": "Loops" }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let array_literal_inv_pure (#a:Type0) (n:US.t) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) (s:Seq.seq a) : prop = forall (j:nat). (j < i /\ j < Seq.length s) ==> Seq.index s j == f (US.uint_to_t j)
val array_literal_inv_pure (#a: Type0) (n: US.t) (f: (i: US.t{US.v i < US.v n} -> a)) (i: Loops.nat_at_most n) (s: Seq.seq a) : prop let array_literal_inv_pure (#a: Type0) (n: US.t) (f: (i: US.t{US.v i < US.v n} -> a)) (i: Loops.nat_at_most n) (s: Seq.seq a) : prop =
false
null
false
forall (j: nat). (j < i /\ j < Seq.length s) ==> Seq.index s j == f (US.uint_to_t j)
{ "checked_file": "Steel.ST.Array.Util.fst.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.Reference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.ST.Effect.fsti.checked", "Steel.ST.Array.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Array.Util.fst" }
[ "total" ]
[ "FStar.SizeT.t", "Prims.b2t", "Prims.op_LessThan", "FStar.SizeT.v", "Steel.ST.Loops.nat_at_most", "FStar.Seq.Base.seq", "Prims.l_Forall", "Prims.nat", "Prims.l_imp", "Prims.l_and", "FStar.Seq.Base.length", "Prims.eq2", "FStar.Seq.Base.index", "FStar.SizeT.uint_to_t", "Prims.prop" ]
[]
(* Copyright 2021 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.Util module G = FStar.Ghost module US = FStar.SizeT module R = Steel.ST.Reference module A = Steel.ST.Array module Loops = Steel.ST.Loops open Steel.FractionalPermission open Steel.ST.Effect open Steel.ST.Util /// Implementation of array_literal using a for loop let array_literal_inv_pure (#a:Type0) (n:US.t) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) (s:Seq.seq a)
false
false
Steel.ST.Array.Util.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val array_literal_inv_pure (#a: Type0) (n: US.t) (f: (i: US.t{US.v i < US.v n} -> a)) (i: Loops.nat_at_most n) (s: Seq.seq a) : prop
[]
Steel.ST.Array.Util.array_literal_inv_pure
{ "file_name": "lib/steel/Steel.ST.Array.Util.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: FStar.SizeT.t -> f: (i: FStar.SizeT.t{FStar.SizeT.v i < FStar.SizeT.v n} -> a) -> i: Steel.ST.Loops.nat_at_most n -> s: FStar.Seq.Base.seq a -> Prims.prop
{ "end_col": 73, "end_line": 41, "start_col": 4, "start_line": 40 }
Prims.Tot
val forall_pure_inv_b: #a: Type0 -> n: US.t -> p: (a -> bool) -> s: Seq.seq a -> squash (Seq.length s == US.v n) -> i: US.t -> b: bool -> prop
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Loops", "short_module": "Loops" }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let forall_pure_inv_b (#a:Type0) (n:US.t) (p:a -> bool) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (i:US.t) (b:bool) : prop = b == (i `US.lt` n && p (Seq.index s (US.v i)))
val forall_pure_inv_b: #a: Type0 -> n: US.t -> p: (a -> bool) -> s: Seq.seq a -> squash (Seq.length s == US.v n) -> i: US.t -> b: bool -> prop let forall_pure_inv_b (#a: Type0) (n: US.t) (p: (a -> bool)) (s: Seq.seq a) (_: squash (Seq.length s == US.v n)) (i: US.t) (b: bool) : prop =
false
null
false
b == (i `US.lt` n && p (Seq.index s (US.v i)))
{ "checked_file": "Steel.ST.Array.Util.fst.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.Reference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.ST.Effect.fsti.checked", "Steel.ST.Array.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Array.Util.fst" }
[ "total" ]
[ "FStar.SizeT.t", "Prims.bool", "FStar.Seq.Base.seq", "Prims.squash", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "FStar.SizeT.v", "Prims.op_AmpAmp", "FStar.SizeT.lt", "FStar.Seq.Base.index", "Prims.prop" ]
[]
(* Copyright 2021 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.Util module G = FStar.Ghost module US = FStar.SizeT module R = Steel.ST.Reference module A = Steel.ST.Array module Loops = Steel.ST.Loops open Steel.FractionalPermission open Steel.ST.Effect open Steel.ST.Util /// Implementation of array_literal using a for loop let array_literal_inv_pure (#a:Type0) (n:US.t) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) (s:Seq.seq a) : prop = forall (j:nat). (j < i /\ j < Seq.length s) ==> Seq.index s j == f (US.uint_to_t j) [@@ __reduce__] let array_literal_inv (#a:Type0) (n:US.t) (arr:A.array a) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) : Seq.seq a -> vprop = fun s -> A.pts_to arr full_perm s `star` pure (array_literal_inv_pure n f i s) inline_for_extraction let array_literal_loop_body (#a:Type0) (n:US.t) (arr:A.array a{A.length arr == US.v n}) (f:(i:US.t{US.v i < US.v n} -> a)) : i:Loops.u32_between 0sz n -> STT unit (exists_ (array_literal_inv n arr f (US.v i))) (fun _ -> exists_ (array_literal_inv n arr f (US.v i + 1))) = fun i -> let s = elim_exists () in (); A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v i) s); A.write arr i (f i); intro_pure (array_literal_inv_pure n f (US.v i + 1) (Seq.upd s (US.v i) (f i))); intro_exists (Seq.upd s (US.v i) (f i)) (array_literal_inv n arr f (US.v i + 1)) let array_literal #a n f = let arr = A.alloc (f 0sz) n in intro_pure (array_literal_inv_pure n f 1 (Seq.create (US.v n) (f 0sz))); intro_exists (Seq.create (US.v n) (f 0sz)) (array_literal_inv n arr f 1); Loops.for_loop 1sz n (fun i -> exists_ (array_literal_inv n arr f i)) (array_literal_loop_body n arr f); let s = elim_exists () in A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v n) s); assert (Seq.equal s (Seq.init (US.v n) (fun i -> f (US.uint_to_t i)))); rewrite (A.pts_to arr full_perm s) _; return arr /// Implementation of for_all using a while loop let forall_pure_inv (#a:Type0) (n:US.t) (p:a -> bool) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (i:US.t) : prop = i `US.lte` n /\ (forall (j:nat). j < US.v i ==> p (Seq.index s j)) let forall_pure_inv_b (#a:Type0) (n:US.t) (p:a -> bool) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (i:US.t) (b:bool)
false
false
Steel.ST.Array.Util.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val forall_pure_inv_b: #a: Type0 -> n: US.t -> p: (a -> bool) -> s: Seq.seq a -> squash (Seq.length s == US.v n) -> i: US.t -> b: bool -> prop
[]
Steel.ST.Array.Util.forall_pure_inv_b
{ "file_name": "lib/steel/Steel.ST.Array.Util.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: FStar.SizeT.t -> p: (_: a -> Prims.bool) -> s: FStar.Seq.Base.seq a -> _: Prims.squash (FStar.Seq.Base.length s == FStar.SizeT.v n) -> i: FStar.SizeT.t -> b: Prims.bool -> Prims.prop
{ "end_col": 50, "end_line": 124, "start_col": 4, "start_line": 124 }
Prims.Tot
val forall_pred: #a: Type0 -> n: US.t -> arr: A.array a -> p: (a -> bool) -> r: R.ref US.t -> perm: perm -> s: Seq.seq a -> squash (Seq.length s == US.v n) -> b: bool -> US.t -> vprop
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Loops", "short_module": "Loops" }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let forall_pred (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (b:bool) : US.t -> vprop = fun i -> A.pts_to arr perm s `star` R.pts_to r full_perm i `star` pure (forall_pure_inv n p s () i) `star` pure (forall_pure_inv_b n p s () i b)
val forall_pred: #a: Type0 -> n: US.t -> arr: A.array a -> p: (a -> bool) -> r: R.ref US.t -> perm: perm -> s: Seq.seq a -> squash (Seq.length s == US.v n) -> b: bool -> US.t -> vprop let forall_pred (#a: Type0) (n: US.t) (arr: A.array a) (p: (a -> bool)) (r: R.ref US.t) (perm: perm) (s: Seq.seq a) (_: squash (Seq.length s == US.v n)) (b: bool) : US.t -> vprop =
false
null
false
fun i -> (((A.pts_to arr perm s) `star` (R.pts_to r full_perm i)) `star` (pure (forall_pure_inv n p s () i))) `star` (pure (forall_pure_inv_b n p s () i b))
{ "checked_file": "Steel.ST.Array.Util.fst.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.Reference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.ST.Effect.fsti.checked", "Steel.ST.Array.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Array.Util.fst" }
[ "total" ]
[ "FStar.SizeT.t", "Steel.ST.Array.array", "Prims.bool", "Steel.ST.Reference.ref", "Steel.FractionalPermission.perm", "FStar.Seq.Base.seq", "Prims.squash", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "FStar.SizeT.v", "Steel.Effect.Common.star", "Steel.ST.Array.pts_to", "Steel.ST.Reference.pts_to", "Steel.FractionalPermission.full_perm", "Steel.ST.Util.pure", "Steel.ST.Array.Util.forall_pure_inv", "Steel.ST.Array.Util.forall_pure_inv_b", "Steel.Effect.Common.vprop" ]
[]
(* Copyright 2021 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.Util module G = FStar.Ghost module US = FStar.SizeT module R = Steel.ST.Reference module A = Steel.ST.Array module Loops = Steel.ST.Loops open Steel.FractionalPermission open Steel.ST.Effect open Steel.ST.Util /// Implementation of array_literal using a for loop let array_literal_inv_pure (#a:Type0) (n:US.t) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) (s:Seq.seq a) : prop = forall (j:nat). (j < i /\ j < Seq.length s) ==> Seq.index s j == f (US.uint_to_t j) [@@ __reduce__] let array_literal_inv (#a:Type0) (n:US.t) (arr:A.array a) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) : Seq.seq a -> vprop = fun s -> A.pts_to arr full_perm s `star` pure (array_literal_inv_pure n f i s) inline_for_extraction let array_literal_loop_body (#a:Type0) (n:US.t) (arr:A.array a{A.length arr == US.v n}) (f:(i:US.t{US.v i < US.v n} -> a)) : i:Loops.u32_between 0sz n -> STT unit (exists_ (array_literal_inv n arr f (US.v i))) (fun _ -> exists_ (array_literal_inv n arr f (US.v i + 1))) = fun i -> let s = elim_exists () in (); A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v i) s); A.write arr i (f i); intro_pure (array_literal_inv_pure n f (US.v i + 1) (Seq.upd s (US.v i) (f i))); intro_exists (Seq.upd s (US.v i) (f i)) (array_literal_inv n arr f (US.v i + 1)) let array_literal #a n f = let arr = A.alloc (f 0sz) n in intro_pure (array_literal_inv_pure n f 1 (Seq.create (US.v n) (f 0sz))); intro_exists (Seq.create (US.v n) (f 0sz)) (array_literal_inv n arr f 1); Loops.for_loop 1sz n (fun i -> exists_ (array_literal_inv n arr f i)) (array_literal_loop_body n arr f); let s = elim_exists () in A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v n) s); assert (Seq.equal s (Seq.init (US.v n) (fun i -> f (US.uint_to_t i)))); rewrite (A.pts_to arr full_perm s) _; return arr /// Implementation of for_all using a while loop let forall_pure_inv (#a:Type0) (n:US.t) (p:a -> bool) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (i:US.t) : prop = i `US.lte` n /\ (forall (j:nat). j < US.v i ==> p (Seq.index s j)) let forall_pure_inv_b (#a:Type0) (n:US.t) (p:a -> bool) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (i:US.t) (b:bool) : prop = b == (i `US.lt` n && p (Seq.index s (US.v i))) [@@ __reduce__] let forall_pred (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (b:bool)
false
false
Steel.ST.Array.Util.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val forall_pred: #a: Type0 -> n: US.t -> arr: A.array a -> p: (a -> bool) -> r: R.ref US.t -> perm: perm -> s: Seq.seq a -> squash (Seq.length s == US.v n) -> b: bool -> US.t -> vprop
[]
Steel.ST.Array.Util.forall_pred
{ "file_name": "lib/steel/Steel.ST.Array.Util.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: FStar.SizeT.t -> arr: Steel.ST.Array.array a -> p: (_: a -> Prims.bool) -> r: Steel.ST.Reference.ref FStar.SizeT.t -> perm: Steel.FractionalPermission.perm -> s: FStar.Seq.Base.seq a -> _: Prims.squash (FStar.Seq.Base.length s == FStar.SizeT.v n) -> b: Prims.bool -> _: FStar.SizeT.t -> Steel.Effect.Common.vprop
{ "end_col": 41, "end_line": 145, "start_col": 4, "start_line": 138 }
Prims.Tot
val forall2_pure_inv_b: #a: Type0 -> #b: Type0 -> n: US.t -> p: (a -> b -> bool) -> s0: Seq.seq a -> s1: Seq.seq b -> squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1) -> i: US.t -> g: bool -> prop
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Loops", "short_module": "Loops" }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let forall2_pure_inv_b (#a #b:Type0) (n:US.t) (p:a -> b -> bool) (s0:Seq.seq a) (s1:Seq.seq b) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) (i:US.t) (g:bool) : prop = g == (i `US.lt` n && p (Seq.index s0 (US.v i)) (Seq.index s1 (US.v i)))
val forall2_pure_inv_b: #a: Type0 -> #b: Type0 -> n: US.t -> p: (a -> b -> bool) -> s0: Seq.seq a -> s1: Seq.seq b -> squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1) -> i: US.t -> g: bool -> prop let forall2_pure_inv_b (#a: Type0) (#b: Type0) (n: US.t) (p: (a -> b -> bool)) (s0: Seq.seq a) (s1: Seq.seq b) (_: squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) (i: US.t) (g: bool) : prop =
false
null
false
g == (i `US.lt` n && p (Seq.index s0 (US.v i)) (Seq.index s1 (US.v i)))
{ "checked_file": "Steel.ST.Array.Util.fst.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.Reference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.ST.Effect.fsti.checked", "Steel.ST.Array.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Array.Util.fst" }
[ "total" ]
[ "FStar.SizeT.t", "Prims.bool", "FStar.Seq.Base.seq", "Prims.squash", "Prims.l_and", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "FStar.SizeT.v", "Prims.op_AmpAmp", "FStar.SizeT.lt", "FStar.Seq.Base.index", "Prims.prop" ]
[]
(* Copyright 2021 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.Util module G = FStar.Ghost module US = FStar.SizeT module R = Steel.ST.Reference module A = Steel.ST.Array module Loops = Steel.ST.Loops open Steel.FractionalPermission open Steel.ST.Effect open Steel.ST.Util /// Implementation of array_literal using a for loop let array_literal_inv_pure (#a:Type0) (n:US.t) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) (s:Seq.seq a) : prop = forall (j:nat). (j < i /\ j < Seq.length s) ==> Seq.index s j == f (US.uint_to_t j) [@@ __reduce__] let array_literal_inv (#a:Type0) (n:US.t) (arr:A.array a) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) : Seq.seq a -> vprop = fun s -> A.pts_to arr full_perm s `star` pure (array_literal_inv_pure n f i s) inline_for_extraction let array_literal_loop_body (#a:Type0) (n:US.t) (arr:A.array a{A.length arr == US.v n}) (f:(i:US.t{US.v i < US.v n} -> a)) : i:Loops.u32_between 0sz n -> STT unit (exists_ (array_literal_inv n arr f (US.v i))) (fun _ -> exists_ (array_literal_inv n arr f (US.v i + 1))) = fun i -> let s = elim_exists () in (); A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v i) s); A.write arr i (f i); intro_pure (array_literal_inv_pure n f (US.v i + 1) (Seq.upd s (US.v i) (f i))); intro_exists (Seq.upd s (US.v i) (f i)) (array_literal_inv n arr f (US.v i + 1)) let array_literal #a n f = let arr = A.alloc (f 0sz) n in intro_pure (array_literal_inv_pure n f 1 (Seq.create (US.v n) (f 0sz))); intro_exists (Seq.create (US.v n) (f 0sz)) (array_literal_inv n arr f 1); Loops.for_loop 1sz n (fun i -> exists_ (array_literal_inv n arr f i)) (array_literal_loop_body n arr f); let s = elim_exists () in A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v n) s); assert (Seq.equal s (Seq.init (US.v n) (fun i -> f (US.uint_to_t i)))); rewrite (A.pts_to arr full_perm s) _; return arr /// Implementation of for_all using a while loop let forall_pure_inv (#a:Type0) (n:US.t) (p:a -> bool) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (i:US.t) : prop = i `US.lte` n /\ (forall (j:nat). j < US.v i ==> p (Seq.index s j)) let forall_pure_inv_b (#a:Type0) (n:US.t) (p:a -> bool) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (i:US.t) (b:bool) : prop = b == (i `US.lt` n && p (Seq.index s (US.v i))) [@@ __reduce__] let forall_pred (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (b:bool) : US.t -> vprop = fun i -> A.pts_to arr perm s `star` R.pts_to r full_perm i `star` pure (forall_pure_inv n p s () i) `star` pure (forall_pure_inv_b n p s () i b) [@@ __reduce__] let forall_inv (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) : bool -> vprop = fun b -> exists_ (forall_pred n arr p r perm s () b) inline_for_extraction let forall_cond (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:G.erased (Seq.seq a)) (_:squash (Seq.length s == US.v n)) : unit -> STT bool (exists_ (forall_inv n arr p r perm s ())) (forall_inv n arr p r perm s ()) = fun _ -> let _ = elim_exists () in let _ = elim_exists () in elim_pure _; elim_pure _; let i = R.read r in let b = i = n in let res = if b then return false else let elt = A.read arr i in return (p elt) in intro_pure (forall_pure_inv n p s () i); intro_pure (forall_pure_inv_b n p s () i res); intro_exists i (forall_pred n arr p r perm s () res); return res inline_for_extraction let forall_body (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:G.erased (Seq.seq a)) (_:squash (Seq.length s == US.v n)) : unit -> STT unit (forall_inv n arr p r perm s () true) (fun _ -> exists_ (forall_inv n arr p r perm s ())) = fun _ -> let _ = elim_exists () in elim_pure _; elim_pure _; //atomic increment? let i = R.read r in R.write r (US.add i 1sz); intro_pure (forall_pure_inv n p s () (US.add i 1sz)); intro_pure (forall_pure_inv_b n p s () (US.add i 1sz) ((US.add i 1sz) `US.lt` n && p (Seq.index s (US.v (US.add i 1sz))))); intro_exists (US.add i 1sz) (forall_pred n arr p r perm s () ((US.add i 1sz) `US.lt` n && p (Seq.index s (US.v (US.add i 1sz))))); intro_exists ((US.add i 1sz) `US.lt` n && p (Seq.index s (US.v (US.add i 1sz)))) (forall_inv n arr p r perm s ()) let for_all #a #perm #s n arr p = A.pts_to_length arr s; let b = n = 0sz in if b then return true else begin //This could be stack allocated let r = R.alloc 0sz in intro_pure (forall_pure_inv n p s () 0sz); intro_pure (forall_pure_inv_b n p s () 0sz (0sz `US.lt` n && p (Seq.index s (US.v 0sz)))); intro_exists 0sz (forall_pred n arr p r perm s () (0sz `US.lt` n && p (Seq.index s (US.v 0sz)))); intro_exists (0sz `US.lt` n && p (Seq.index s (US.v 0sz))) (forall_inv n arr p r perm s ()); Loops.while_loop (forall_inv n arr p r perm s ()) (forall_cond n arr p r perm s ()) (forall_body n arr p r perm s ()); let _ = elim_exists () in let _ = elim_pure _ in let _ = elim_pure _ in let i = R.read r in //This free would go away if we had stack allocations R.free r; return (i = n) end /// Implementation of for_all2 using a while loop let forall2_pure_inv (#a #b:Type0) (n:US.t) (p:a -> b -> bool) (s0:Seq.seq a) (s1:Seq.seq b) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) (i:US.t) : prop = i `US.lte` n /\ (forall (j:nat). j < US.v i ==> p (Seq.index s0 j) (Seq.index s1 j)) let forall2_pure_inv_b (#a #b:Type0) (n:US.t) (p:a -> b -> bool) (s0:Seq.seq a) (s1:Seq.seq b) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) (i:US.t) (g:bool)
false
false
Steel.ST.Array.Util.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val forall2_pure_inv_b: #a: Type0 -> #b: Type0 -> n: US.t -> p: (a -> b -> bool) -> s0: Seq.seq a -> s1: Seq.seq b -> squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1) -> i: US.t -> g: bool -> prop
[]
Steel.ST.Array.Util.forall2_pure_inv_b
{ "file_name": "lib/steel/Steel.ST.Array.Util.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: FStar.SizeT.t -> p: (_: a -> _: b -> Prims.bool) -> s0: FStar.Seq.Base.seq a -> s1: FStar.Seq.Base.seq b -> _: Prims.squash (FStar.Seq.Base.length s0 == FStar.SizeT.v n /\ FStar.Seq.Base.length s0 == FStar.Seq.Base.length s1) -> i: FStar.SizeT.t -> g: Prims.bool -> Prims.prop
{ "end_col": 75, "end_line": 289, "start_col": 4, "start_line": 289 }
Prims.Tot
val forall_pure_inv: #a: Type0 -> n: US.t -> p: (a -> bool) -> s: Seq.seq a -> squash (Seq.length s == US.v n) -> i: US.t -> prop
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Loops", "short_module": "Loops" }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let forall_pure_inv (#a:Type0) (n:US.t) (p:a -> bool) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (i:US.t) : prop = i `US.lte` n /\ (forall (j:nat). j < US.v i ==> p (Seq.index s j))
val forall_pure_inv: #a: Type0 -> n: US.t -> p: (a -> bool) -> s: Seq.seq a -> squash (Seq.length s == US.v n) -> i: US.t -> prop let forall_pure_inv (#a: Type0) (n: US.t) (p: (a -> bool)) (s: Seq.seq a) (_: squash (Seq.length s == US.v n)) (i: US.t) : prop =
false
null
false
i `US.lte` n /\ (forall (j: nat). j < US.v i ==> p (Seq.index s j))
{ "checked_file": "Steel.ST.Array.Util.fst.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.Reference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.ST.Effect.fsti.checked", "Steel.ST.Array.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Array.Util.fst" }
[ "total" ]
[ "FStar.SizeT.t", "Prims.bool", "FStar.Seq.Base.seq", "Prims.squash", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "FStar.SizeT.v", "Prims.l_and", "Prims.b2t", "FStar.SizeT.lte", "Prims.l_Forall", "Prims.l_imp", "Prims.op_LessThan", "FStar.Seq.Base.index", "Prims.prop" ]
[]
(* Copyright 2021 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.Util module G = FStar.Ghost module US = FStar.SizeT module R = Steel.ST.Reference module A = Steel.ST.Array module Loops = Steel.ST.Loops open Steel.FractionalPermission open Steel.ST.Effect open Steel.ST.Util /// Implementation of array_literal using a for loop let array_literal_inv_pure (#a:Type0) (n:US.t) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) (s:Seq.seq a) : prop = forall (j:nat). (j < i /\ j < Seq.length s) ==> Seq.index s j == f (US.uint_to_t j) [@@ __reduce__] let array_literal_inv (#a:Type0) (n:US.t) (arr:A.array a) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) : Seq.seq a -> vprop = fun s -> A.pts_to arr full_perm s `star` pure (array_literal_inv_pure n f i s) inline_for_extraction let array_literal_loop_body (#a:Type0) (n:US.t) (arr:A.array a{A.length arr == US.v n}) (f:(i:US.t{US.v i < US.v n} -> a)) : i:Loops.u32_between 0sz n -> STT unit (exists_ (array_literal_inv n arr f (US.v i))) (fun _ -> exists_ (array_literal_inv n arr f (US.v i + 1))) = fun i -> let s = elim_exists () in (); A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v i) s); A.write arr i (f i); intro_pure (array_literal_inv_pure n f (US.v i + 1) (Seq.upd s (US.v i) (f i))); intro_exists (Seq.upd s (US.v i) (f i)) (array_literal_inv n arr f (US.v i + 1)) let array_literal #a n f = let arr = A.alloc (f 0sz) n in intro_pure (array_literal_inv_pure n f 1 (Seq.create (US.v n) (f 0sz))); intro_exists (Seq.create (US.v n) (f 0sz)) (array_literal_inv n arr f 1); Loops.for_loop 1sz n (fun i -> exists_ (array_literal_inv n arr f i)) (array_literal_loop_body n arr f); let s = elim_exists () in A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v n) s); assert (Seq.equal s (Seq.init (US.v n) (fun i -> f (US.uint_to_t i)))); rewrite (A.pts_to arr full_perm s) _; return arr /// Implementation of for_all using a while loop let forall_pure_inv (#a:Type0) (n:US.t) (p:a -> bool) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (i:US.t)
false
false
Steel.ST.Array.Util.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val forall_pure_inv: #a: Type0 -> n: US.t -> p: (a -> bool) -> s: Seq.seq a -> squash (Seq.length s == US.v n) -> i: US.t -> prop
[]
Steel.ST.Array.Util.forall_pure_inv
{ "file_name": "lib/steel/Steel.ST.Array.Util.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: FStar.SizeT.t -> p: (_: a -> Prims.bool) -> s: FStar.Seq.Base.seq a -> _: Prims.squash (FStar.Seq.Base.length s == FStar.SizeT.v n) -> i: FStar.SizeT.t -> Prims.prop
{ "end_col": 70, "end_line": 113, "start_col": 4, "start_line": 113 }
Prims.Tot
val forall_inv: #a: Type0 -> n: US.t -> arr: A.array a -> p: (a -> bool) -> r: R.ref US.t -> perm: perm -> s: Seq.seq a -> squash (Seq.length s == US.v n) -> bool -> vprop
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Loops", "short_module": "Loops" }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let forall_inv (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) : bool -> vprop = fun b -> exists_ (forall_pred n arr p r perm s () b)
val forall_inv: #a: Type0 -> n: US.t -> arr: A.array a -> p: (a -> bool) -> r: R.ref US.t -> perm: perm -> s: Seq.seq a -> squash (Seq.length s == US.v n) -> bool -> vprop let forall_inv (#a: Type0) (n: US.t) (arr: A.array a) (p: (a -> bool)) (r: R.ref US.t) (perm: perm) (s: Seq.seq a) (_: squash (Seq.length s == US.v n)) : bool -> vprop =
false
null
false
fun b -> exists_ (forall_pred n arr p r perm s () b)
{ "checked_file": "Steel.ST.Array.Util.fst.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.Reference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.ST.Effect.fsti.checked", "Steel.ST.Array.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Array.Util.fst" }
[ "total" ]
[ "FStar.SizeT.t", "Steel.ST.Array.array", "Prims.bool", "Steel.ST.Reference.ref", "Steel.FractionalPermission.perm", "FStar.Seq.Base.seq", "Prims.squash", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "FStar.SizeT.v", "Steel.ST.Util.exists_", "Steel.ST.Array.Util.forall_pred", "Steel.Effect.Common.vprop" ]
[]
(* Copyright 2021 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.Util module G = FStar.Ghost module US = FStar.SizeT module R = Steel.ST.Reference module A = Steel.ST.Array module Loops = Steel.ST.Loops open Steel.FractionalPermission open Steel.ST.Effect open Steel.ST.Util /// Implementation of array_literal using a for loop let array_literal_inv_pure (#a:Type0) (n:US.t) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) (s:Seq.seq a) : prop = forall (j:nat). (j < i /\ j < Seq.length s) ==> Seq.index s j == f (US.uint_to_t j) [@@ __reduce__] let array_literal_inv (#a:Type0) (n:US.t) (arr:A.array a) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) : Seq.seq a -> vprop = fun s -> A.pts_to arr full_perm s `star` pure (array_literal_inv_pure n f i s) inline_for_extraction let array_literal_loop_body (#a:Type0) (n:US.t) (arr:A.array a{A.length arr == US.v n}) (f:(i:US.t{US.v i < US.v n} -> a)) : i:Loops.u32_between 0sz n -> STT unit (exists_ (array_literal_inv n arr f (US.v i))) (fun _ -> exists_ (array_literal_inv n arr f (US.v i + 1))) = fun i -> let s = elim_exists () in (); A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v i) s); A.write arr i (f i); intro_pure (array_literal_inv_pure n f (US.v i + 1) (Seq.upd s (US.v i) (f i))); intro_exists (Seq.upd s (US.v i) (f i)) (array_literal_inv n arr f (US.v i + 1)) let array_literal #a n f = let arr = A.alloc (f 0sz) n in intro_pure (array_literal_inv_pure n f 1 (Seq.create (US.v n) (f 0sz))); intro_exists (Seq.create (US.v n) (f 0sz)) (array_literal_inv n arr f 1); Loops.for_loop 1sz n (fun i -> exists_ (array_literal_inv n arr f i)) (array_literal_loop_body n arr f); let s = elim_exists () in A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v n) s); assert (Seq.equal s (Seq.init (US.v n) (fun i -> f (US.uint_to_t i)))); rewrite (A.pts_to arr full_perm s) _; return arr /// Implementation of for_all using a while loop let forall_pure_inv (#a:Type0) (n:US.t) (p:a -> bool) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (i:US.t) : prop = i `US.lte` n /\ (forall (j:nat). j < US.v i ==> p (Seq.index s j)) let forall_pure_inv_b (#a:Type0) (n:US.t) (p:a -> bool) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (i:US.t) (b:bool) : prop = b == (i `US.lt` n && p (Seq.index s (US.v i))) [@@ __reduce__] let forall_pred (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (b:bool) : US.t -> vprop = fun i -> A.pts_to arr perm s `star` R.pts_to r full_perm i `star` pure (forall_pure_inv n p s () i) `star` pure (forall_pure_inv_b n p s () i b) [@@ __reduce__] let forall_inv (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:Seq.seq a) (_:squash (Seq.length s == US.v n))
false
false
Steel.ST.Array.Util.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val forall_inv: #a: Type0 -> n: US.t -> arr: A.array a -> p: (a -> bool) -> r: R.ref US.t -> perm: perm -> s: Seq.seq a -> squash (Seq.length s == US.v n) -> bool -> vprop
[]
Steel.ST.Array.Util.forall_inv
{ "file_name": "lib/steel/Steel.ST.Array.Util.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: FStar.SizeT.t -> arr: Steel.ST.Array.array a -> p: (_: a -> Prims.bool) -> r: Steel.ST.Reference.ref FStar.SizeT.t -> perm: Steel.FractionalPermission.perm -> s: FStar.Seq.Base.seq a -> _: Prims.squash (FStar.Seq.Base.length s == FStar.SizeT.v n) -> _: Prims.bool -> Steel.Effect.Common.vprop
{ "end_col": 56, "end_line": 158, "start_col": 4, "start_line": 158 }
Prims.Tot
val forall2_pred: #a: Type0 -> #b: Type0 -> n: US.t -> a0: A.array a -> a1: A.array b -> p: (a -> b -> bool) -> r: R.ref US.t -> p0: perm -> p1: perm -> s0: Seq.seq a -> s1: Seq.seq b -> squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1) -> g: bool -> US.t -> vprop
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Loops", "short_module": "Loops" }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let forall2_pred (#a #b:Type0) (n:US.t) (a0:A.array a) (a1:A.array b) (p:a -> b -> bool) (r:R.ref US.t) (p0 p1:perm) (s0:Seq.seq a) (s1:Seq.seq b) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) (g:bool) : US.t -> vprop = fun i -> A.pts_to a0 p0 s0 `star` A.pts_to a1 p1 s1 `star` R.pts_to r full_perm i `star` pure (forall2_pure_inv n p s0 s1 () i) `star` pure (forall2_pure_inv_b n p s0 s1 () i g)
val forall2_pred: #a: Type0 -> #b: Type0 -> n: US.t -> a0: A.array a -> a1: A.array b -> p: (a -> b -> bool) -> r: R.ref US.t -> p0: perm -> p1: perm -> s0: Seq.seq a -> s1: Seq.seq b -> squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1) -> g: bool -> US.t -> vprop let forall2_pred (#a: Type0) (#b: Type0) (n: US.t) (a0: A.array a) (a1: A.array b) (p: (a -> b -> bool)) (r: R.ref US.t) (p0: perm) (p1: perm) (s0: Seq.seq a) (s1: Seq.seq b) (_: squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) (g: bool) : US.t -> vprop =
false
null
false
fun i -> ((((A.pts_to a0 p0 s0) `star` (A.pts_to a1 p1 s1)) `star` (R.pts_to r full_perm i)) `star` (pure (forall2_pure_inv n p s0 s1 () i))) `star` (pure (forall2_pure_inv_b n p s0 s1 () i g))
{ "checked_file": "Steel.ST.Array.Util.fst.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.Reference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.ST.Effect.fsti.checked", "Steel.ST.Array.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Array.Util.fst" }
[ "total" ]
[ "FStar.SizeT.t", "Steel.ST.Array.array", "Prims.bool", "Steel.ST.Reference.ref", "Steel.FractionalPermission.perm", "FStar.Seq.Base.seq", "Prims.squash", "Prims.l_and", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "FStar.SizeT.v", "Steel.Effect.Common.star", "Steel.ST.Array.pts_to", "Steel.ST.Reference.pts_to", "Steel.FractionalPermission.full_perm", "Steel.ST.Util.pure", "Steel.ST.Array.Util.forall2_pure_inv", "Steel.ST.Array.Util.forall2_pure_inv_b", "Steel.Effect.Common.vprop" ]
[]
(* Copyright 2021 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.Util module G = FStar.Ghost module US = FStar.SizeT module R = Steel.ST.Reference module A = Steel.ST.Array module Loops = Steel.ST.Loops open Steel.FractionalPermission open Steel.ST.Effect open Steel.ST.Util /// Implementation of array_literal using a for loop let array_literal_inv_pure (#a:Type0) (n:US.t) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) (s:Seq.seq a) : prop = forall (j:nat). (j < i /\ j < Seq.length s) ==> Seq.index s j == f (US.uint_to_t j) [@@ __reduce__] let array_literal_inv (#a:Type0) (n:US.t) (arr:A.array a) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) : Seq.seq a -> vprop = fun s -> A.pts_to arr full_perm s `star` pure (array_literal_inv_pure n f i s) inline_for_extraction let array_literal_loop_body (#a:Type0) (n:US.t) (arr:A.array a{A.length arr == US.v n}) (f:(i:US.t{US.v i < US.v n} -> a)) : i:Loops.u32_between 0sz n -> STT unit (exists_ (array_literal_inv n arr f (US.v i))) (fun _ -> exists_ (array_literal_inv n arr f (US.v i + 1))) = fun i -> let s = elim_exists () in (); A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v i) s); A.write arr i (f i); intro_pure (array_literal_inv_pure n f (US.v i + 1) (Seq.upd s (US.v i) (f i))); intro_exists (Seq.upd s (US.v i) (f i)) (array_literal_inv n arr f (US.v i + 1)) let array_literal #a n f = let arr = A.alloc (f 0sz) n in intro_pure (array_literal_inv_pure n f 1 (Seq.create (US.v n) (f 0sz))); intro_exists (Seq.create (US.v n) (f 0sz)) (array_literal_inv n arr f 1); Loops.for_loop 1sz n (fun i -> exists_ (array_literal_inv n arr f i)) (array_literal_loop_body n arr f); let s = elim_exists () in A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v n) s); assert (Seq.equal s (Seq.init (US.v n) (fun i -> f (US.uint_to_t i)))); rewrite (A.pts_to arr full_perm s) _; return arr /// Implementation of for_all using a while loop let forall_pure_inv (#a:Type0) (n:US.t) (p:a -> bool) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (i:US.t) : prop = i `US.lte` n /\ (forall (j:nat). j < US.v i ==> p (Seq.index s j)) let forall_pure_inv_b (#a:Type0) (n:US.t) (p:a -> bool) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (i:US.t) (b:bool) : prop = b == (i `US.lt` n && p (Seq.index s (US.v i))) [@@ __reduce__] let forall_pred (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (b:bool) : US.t -> vprop = fun i -> A.pts_to arr perm s `star` R.pts_to r full_perm i `star` pure (forall_pure_inv n p s () i) `star` pure (forall_pure_inv_b n p s () i b) [@@ __reduce__] let forall_inv (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) : bool -> vprop = fun b -> exists_ (forall_pred n arr p r perm s () b) inline_for_extraction let forall_cond (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:G.erased (Seq.seq a)) (_:squash (Seq.length s == US.v n)) : unit -> STT bool (exists_ (forall_inv n arr p r perm s ())) (forall_inv n arr p r perm s ()) = fun _ -> let _ = elim_exists () in let _ = elim_exists () in elim_pure _; elim_pure _; let i = R.read r in let b = i = n in let res = if b then return false else let elt = A.read arr i in return (p elt) in intro_pure (forall_pure_inv n p s () i); intro_pure (forall_pure_inv_b n p s () i res); intro_exists i (forall_pred n arr p r perm s () res); return res inline_for_extraction let forall_body (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:G.erased (Seq.seq a)) (_:squash (Seq.length s == US.v n)) : unit -> STT unit (forall_inv n arr p r perm s () true) (fun _ -> exists_ (forall_inv n arr p r perm s ())) = fun _ -> let _ = elim_exists () in elim_pure _; elim_pure _; //atomic increment? let i = R.read r in R.write r (US.add i 1sz); intro_pure (forall_pure_inv n p s () (US.add i 1sz)); intro_pure (forall_pure_inv_b n p s () (US.add i 1sz) ((US.add i 1sz) `US.lt` n && p (Seq.index s (US.v (US.add i 1sz))))); intro_exists (US.add i 1sz) (forall_pred n arr p r perm s () ((US.add i 1sz) `US.lt` n && p (Seq.index s (US.v (US.add i 1sz))))); intro_exists ((US.add i 1sz) `US.lt` n && p (Seq.index s (US.v (US.add i 1sz)))) (forall_inv n arr p r perm s ()) let for_all #a #perm #s n arr p = A.pts_to_length arr s; let b = n = 0sz in if b then return true else begin //This could be stack allocated let r = R.alloc 0sz in intro_pure (forall_pure_inv n p s () 0sz); intro_pure (forall_pure_inv_b n p s () 0sz (0sz `US.lt` n && p (Seq.index s (US.v 0sz)))); intro_exists 0sz (forall_pred n arr p r perm s () (0sz `US.lt` n && p (Seq.index s (US.v 0sz)))); intro_exists (0sz `US.lt` n && p (Seq.index s (US.v 0sz))) (forall_inv n arr p r perm s ()); Loops.while_loop (forall_inv n arr p r perm s ()) (forall_cond n arr p r perm s ()) (forall_body n arr p r perm s ()); let _ = elim_exists () in let _ = elim_pure _ in let _ = elim_pure _ in let i = R.read r in //This free would go away if we had stack allocations R.free r; return (i = n) end /// Implementation of for_all2 using a while loop let forall2_pure_inv (#a #b:Type0) (n:US.t) (p:a -> b -> bool) (s0:Seq.seq a) (s1:Seq.seq b) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) (i:US.t) : prop = i `US.lte` n /\ (forall (j:nat). j < US.v i ==> p (Seq.index s0 j) (Seq.index s1 j)) let forall2_pure_inv_b (#a #b:Type0) (n:US.t) (p:a -> b -> bool) (s0:Seq.seq a) (s1:Seq.seq b) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) (i:US.t) (g:bool) : prop = g == (i `US.lt` n && p (Seq.index s0 (US.v i)) (Seq.index s1 (US.v i))) [@@ __reduce__] let forall2_pred (#a #b:Type0) (n:US.t) (a0:A.array a) (a1:A.array b) (p:a -> b -> bool) (r:R.ref US.t) (p0 p1:perm) (s0:Seq.seq a) (s1:Seq.seq b) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) (g:bool)
false
false
Steel.ST.Array.Util.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val forall2_pred: #a: Type0 -> #b: Type0 -> n: US.t -> a0: A.array a -> a1: A.array b -> p: (a -> b -> bool) -> r: R.ref US.t -> p0: perm -> p1: perm -> s0: Seq.seq a -> s1: Seq.seq b -> squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1) -> g: bool -> US.t -> vprop
[]
Steel.ST.Array.Util.forall2_pred
{ "file_name": "lib/steel/Steel.ST.Array.Util.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: FStar.SizeT.t -> a0: Steel.ST.Array.array a -> a1: Steel.ST.Array.array b -> p: (_: a -> _: b -> Prims.bool) -> r: Steel.ST.Reference.ref FStar.SizeT.t -> p0: Steel.FractionalPermission.perm -> p1: Steel.FractionalPermission.perm -> s0: FStar.Seq.Base.seq a -> s1: FStar.Seq.Base.seq b -> _: Prims.squash (FStar.Seq.Base.length s0 == FStar.SizeT.v n /\ FStar.Seq.Base.length s0 == FStar.Seq.Base.length s1) -> g: Prims.bool -> _: FStar.SizeT.t -> Steel.Effect.Common.vprop
{ "end_col": 46, "end_line": 314, "start_col": 4, "start_line": 305 }
Prims.Tot
val forall2_inv: #a: Type0 -> #b: Type0 -> n: US.t -> a0: A.array a -> a1: A.array b -> p: (a -> b -> bool) -> r: R.ref US.t -> p0: perm -> p1: perm -> s0: Seq.seq a -> s1: Seq.seq b -> squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1) -> bool -> vprop
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Loops", "short_module": "Loops" }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let forall2_inv (#a #b:Type0) (n:US.t) (a0:A.array a) (a1:A.array b) (p:a -> b -> bool) (r:R.ref US.t) (p0 p1:perm) (s0:Seq.seq a) (s1:Seq.seq b) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) : bool -> vprop = fun g -> exists_ (forall2_pred n a0 a1 p r p0 p1 s0 s1 () g)
val forall2_inv: #a: Type0 -> #b: Type0 -> n: US.t -> a0: A.array a -> a1: A.array b -> p: (a -> b -> bool) -> r: R.ref US.t -> p0: perm -> p1: perm -> s0: Seq.seq a -> s1: Seq.seq b -> squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1) -> bool -> vprop let forall2_inv (#a: Type0) (#b: Type0) (n: US.t) (a0: A.array a) (a1: A.array b) (p: (a -> b -> bool)) (r: R.ref US.t) (p0: perm) (p1: perm) (s0: Seq.seq a) (s1: Seq.seq b) (_: squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) : bool -> vprop =
false
null
false
fun g -> exists_ (forall2_pred n a0 a1 p r p0 p1 s0 s1 () g)
{ "checked_file": "Steel.ST.Array.Util.fst.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.Reference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.ST.Effect.fsti.checked", "Steel.ST.Array.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Array.Util.fst" }
[ "total" ]
[ "FStar.SizeT.t", "Steel.ST.Array.array", "Prims.bool", "Steel.ST.Reference.ref", "Steel.FractionalPermission.perm", "FStar.Seq.Base.seq", "Prims.squash", "Prims.l_and", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "FStar.SizeT.v", "Steel.ST.Util.exists_", "Steel.ST.Array.Util.forall2_pred", "Steel.Effect.Common.vprop" ]
[]
(* Copyright 2021 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.Util module G = FStar.Ghost module US = FStar.SizeT module R = Steel.ST.Reference module A = Steel.ST.Array module Loops = Steel.ST.Loops open Steel.FractionalPermission open Steel.ST.Effect open Steel.ST.Util /// Implementation of array_literal using a for loop let array_literal_inv_pure (#a:Type0) (n:US.t) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) (s:Seq.seq a) : prop = forall (j:nat). (j < i /\ j < Seq.length s) ==> Seq.index s j == f (US.uint_to_t j) [@@ __reduce__] let array_literal_inv (#a:Type0) (n:US.t) (arr:A.array a) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) : Seq.seq a -> vprop = fun s -> A.pts_to arr full_perm s `star` pure (array_literal_inv_pure n f i s) inline_for_extraction let array_literal_loop_body (#a:Type0) (n:US.t) (arr:A.array a{A.length arr == US.v n}) (f:(i:US.t{US.v i < US.v n} -> a)) : i:Loops.u32_between 0sz n -> STT unit (exists_ (array_literal_inv n arr f (US.v i))) (fun _ -> exists_ (array_literal_inv n arr f (US.v i + 1))) = fun i -> let s = elim_exists () in (); A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v i) s); A.write arr i (f i); intro_pure (array_literal_inv_pure n f (US.v i + 1) (Seq.upd s (US.v i) (f i))); intro_exists (Seq.upd s (US.v i) (f i)) (array_literal_inv n arr f (US.v i + 1)) let array_literal #a n f = let arr = A.alloc (f 0sz) n in intro_pure (array_literal_inv_pure n f 1 (Seq.create (US.v n) (f 0sz))); intro_exists (Seq.create (US.v n) (f 0sz)) (array_literal_inv n arr f 1); Loops.for_loop 1sz n (fun i -> exists_ (array_literal_inv n arr f i)) (array_literal_loop_body n arr f); let s = elim_exists () in A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v n) s); assert (Seq.equal s (Seq.init (US.v n) (fun i -> f (US.uint_to_t i)))); rewrite (A.pts_to arr full_perm s) _; return arr /// Implementation of for_all using a while loop let forall_pure_inv (#a:Type0) (n:US.t) (p:a -> bool) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (i:US.t) : prop = i `US.lte` n /\ (forall (j:nat). j < US.v i ==> p (Seq.index s j)) let forall_pure_inv_b (#a:Type0) (n:US.t) (p:a -> bool) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (i:US.t) (b:bool) : prop = b == (i `US.lt` n && p (Seq.index s (US.v i))) [@@ __reduce__] let forall_pred (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (b:bool) : US.t -> vprop = fun i -> A.pts_to arr perm s `star` R.pts_to r full_perm i `star` pure (forall_pure_inv n p s () i) `star` pure (forall_pure_inv_b n p s () i b) [@@ __reduce__] let forall_inv (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) : bool -> vprop = fun b -> exists_ (forall_pred n arr p r perm s () b) inline_for_extraction let forall_cond (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:G.erased (Seq.seq a)) (_:squash (Seq.length s == US.v n)) : unit -> STT bool (exists_ (forall_inv n arr p r perm s ())) (forall_inv n arr p r perm s ()) = fun _ -> let _ = elim_exists () in let _ = elim_exists () in elim_pure _; elim_pure _; let i = R.read r in let b = i = n in let res = if b then return false else let elt = A.read arr i in return (p elt) in intro_pure (forall_pure_inv n p s () i); intro_pure (forall_pure_inv_b n p s () i res); intro_exists i (forall_pred n arr p r perm s () res); return res inline_for_extraction let forall_body (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:G.erased (Seq.seq a)) (_:squash (Seq.length s == US.v n)) : unit -> STT unit (forall_inv n arr p r perm s () true) (fun _ -> exists_ (forall_inv n arr p r perm s ())) = fun _ -> let _ = elim_exists () in elim_pure _; elim_pure _; //atomic increment? let i = R.read r in R.write r (US.add i 1sz); intro_pure (forall_pure_inv n p s () (US.add i 1sz)); intro_pure (forall_pure_inv_b n p s () (US.add i 1sz) ((US.add i 1sz) `US.lt` n && p (Seq.index s (US.v (US.add i 1sz))))); intro_exists (US.add i 1sz) (forall_pred n arr p r perm s () ((US.add i 1sz) `US.lt` n && p (Seq.index s (US.v (US.add i 1sz))))); intro_exists ((US.add i 1sz) `US.lt` n && p (Seq.index s (US.v (US.add i 1sz)))) (forall_inv n arr p r perm s ()) let for_all #a #perm #s n arr p = A.pts_to_length arr s; let b = n = 0sz in if b then return true else begin //This could be stack allocated let r = R.alloc 0sz in intro_pure (forall_pure_inv n p s () 0sz); intro_pure (forall_pure_inv_b n p s () 0sz (0sz `US.lt` n && p (Seq.index s (US.v 0sz)))); intro_exists 0sz (forall_pred n arr p r perm s () (0sz `US.lt` n && p (Seq.index s (US.v 0sz)))); intro_exists (0sz `US.lt` n && p (Seq.index s (US.v 0sz))) (forall_inv n arr p r perm s ()); Loops.while_loop (forall_inv n arr p r perm s ()) (forall_cond n arr p r perm s ()) (forall_body n arr p r perm s ()); let _ = elim_exists () in let _ = elim_pure _ in let _ = elim_pure _ in let i = R.read r in //This free would go away if we had stack allocations R.free r; return (i = n) end /// Implementation of for_all2 using a while loop let forall2_pure_inv (#a #b:Type0) (n:US.t) (p:a -> b -> bool) (s0:Seq.seq a) (s1:Seq.seq b) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) (i:US.t) : prop = i `US.lte` n /\ (forall (j:nat). j < US.v i ==> p (Seq.index s0 j) (Seq.index s1 j)) let forall2_pure_inv_b (#a #b:Type0) (n:US.t) (p:a -> b -> bool) (s0:Seq.seq a) (s1:Seq.seq b) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) (i:US.t) (g:bool) : prop = g == (i `US.lt` n && p (Seq.index s0 (US.v i)) (Seq.index s1 (US.v i))) [@@ __reduce__] let forall2_pred (#a #b:Type0) (n:US.t) (a0:A.array a) (a1:A.array b) (p:a -> b -> bool) (r:R.ref US.t) (p0 p1:perm) (s0:Seq.seq a) (s1:Seq.seq b) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) (g:bool) : US.t -> vprop = fun i -> A.pts_to a0 p0 s0 `star` A.pts_to a1 p1 s1 `star` R.pts_to r full_perm i `star` pure (forall2_pure_inv n p s0 s1 () i) `star` pure (forall2_pure_inv_b n p s0 s1 () i g) [@@ __reduce__] let forall2_inv (#a #b:Type0) (n:US.t) (a0:A.array a) (a1:A.array b) (p:a -> b -> bool) (r:R.ref US.t) (p0 p1:perm) (s0:Seq.seq a) (s1:Seq.seq b) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1))
false
false
Steel.ST.Array.Util.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val forall2_inv: #a: Type0 -> #b: Type0 -> n: US.t -> a0: A.array a -> a1: A.array b -> p: (a -> b -> bool) -> r: R.ref US.t -> p0: perm -> p1: perm -> s0: Seq.seq a -> s1: Seq.seq b -> squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1) -> bool -> vprop
[]
Steel.ST.Array.Util.forall2_inv
{ "file_name": "lib/steel/Steel.ST.Array.Util.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: FStar.SizeT.t -> a0: Steel.ST.Array.array a -> a1: Steel.ST.Array.array b -> p: (_: a -> _: b -> Prims.bool) -> r: Steel.ST.Reference.ref FStar.SizeT.t -> p0: Steel.FractionalPermission.perm -> p1: Steel.FractionalPermission.perm -> s0: FStar.Seq.Base.seq a -> s1: FStar.Seq.Base.seq b -> _: Prims.squash (FStar.Seq.Base.length s0 == FStar.SizeT.v n /\ FStar.Seq.Base.length s0 == FStar.Seq.Base.length s1) -> _: Prims.bool -> Steel.Effect.Common.vprop
{ "end_col": 64, "end_line": 329, "start_col": 4, "start_line": 329 }
Prims.Tot
val forall2_pure_inv: #a: Type0 -> #b: Type0 -> n: US.t -> p: (a -> b -> bool) -> s0: Seq.seq a -> s1: Seq.seq b -> squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1) -> i: US.t -> prop
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Loops", "short_module": "Loops" }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let forall2_pure_inv (#a #b:Type0) (n:US.t) (p:a -> b -> bool) (s0:Seq.seq a) (s1:Seq.seq b) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) (i:US.t) : prop = i `US.lte` n /\ (forall (j:nat). j < US.v i ==> p (Seq.index s0 j) (Seq.index s1 j))
val forall2_pure_inv: #a: Type0 -> #b: Type0 -> n: US.t -> p: (a -> b -> bool) -> s0: Seq.seq a -> s1: Seq.seq b -> squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1) -> i: US.t -> prop let forall2_pure_inv (#a: Type0) (#b: Type0) (n: US.t) (p: (a -> b -> bool)) (s0: Seq.seq a) (s1: Seq.seq b) (_: squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) (i: US.t) : prop =
false
null
false
i `US.lte` n /\ (forall (j: nat). j < US.v i ==> p (Seq.index s0 j) (Seq.index s1 j))
{ "checked_file": "Steel.ST.Array.Util.fst.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.Reference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.ST.Effect.fsti.checked", "Steel.ST.Array.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Array.Util.fst" }
[ "total" ]
[ "FStar.SizeT.t", "Prims.bool", "FStar.Seq.Base.seq", "Prims.squash", "Prims.l_and", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "FStar.SizeT.v", "Prims.b2t", "FStar.SizeT.lte", "Prims.l_Forall", "Prims.l_imp", "Prims.op_LessThan", "FStar.Seq.Base.index", "Prims.prop" ]
[]
(* Copyright 2021 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.Util module G = FStar.Ghost module US = FStar.SizeT module R = Steel.ST.Reference module A = Steel.ST.Array module Loops = Steel.ST.Loops open Steel.FractionalPermission open Steel.ST.Effect open Steel.ST.Util /// Implementation of array_literal using a for loop let array_literal_inv_pure (#a:Type0) (n:US.t) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) (s:Seq.seq a) : prop = forall (j:nat). (j < i /\ j < Seq.length s) ==> Seq.index s j == f (US.uint_to_t j) [@@ __reduce__] let array_literal_inv (#a:Type0) (n:US.t) (arr:A.array a) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) : Seq.seq a -> vprop = fun s -> A.pts_to arr full_perm s `star` pure (array_literal_inv_pure n f i s) inline_for_extraction let array_literal_loop_body (#a:Type0) (n:US.t) (arr:A.array a{A.length arr == US.v n}) (f:(i:US.t{US.v i < US.v n} -> a)) : i:Loops.u32_between 0sz n -> STT unit (exists_ (array_literal_inv n arr f (US.v i))) (fun _ -> exists_ (array_literal_inv n arr f (US.v i + 1))) = fun i -> let s = elim_exists () in (); A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v i) s); A.write arr i (f i); intro_pure (array_literal_inv_pure n f (US.v i + 1) (Seq.upd s (US.v i) (f i))); intro_exists (Seq.upd s (US.v i) (f i)) (array_literal_inv n arr f (US.v i + 1)) let array_literal #a n f = let arr = A.alloc (f 0sz) n in intro_pure (array_literal_inv_pure n f 1 (Seq.create (US.v n) (f 0sz))); intro_exists (Seq.create (US.v n) (f 0sz)) (array_literal_inv n arr f 1); Loops.for_loop 1sz n (fun i -> exists_ (array_literal_inv n arr f i)) (array_literal_loop_body n arr f); let s = elim_exists () in A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v n) s); assert (Seq.equal s (Seq.init (US.v n) (fun i -> f (US.uint_to_t i)))); rewrite (A.pts_to arr full_perm s) _; return arr /// Implementation of for_all using a while loop let forall_pure_inv (#a:Type0) (n:US.t) (p:a -> bool) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (i:US.t) : prop = i `US.lte` n /\ (forall (j:nat). j < US.v i ==> p (Seq.index s j)) let forall_pure_inv_b (#a:Type0) (n:US.t) (p:a -> bool) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (i:US.t) (b:bool) : prop = b == (i `US.lt` n && p (Seq.index s (US.v i))) [@@ __reduce__] let forall_pred (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (b:bool) : US.t -> vprop = fun i -> A.pts_to arr perm s `star` R.pts_to r full_perm i `star` pure (forall_pure_inv n p s () i) `star` pure (forall_pure_inv_b n p s () i b) [@@ __reduce__] let forall_inv (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) : bool -> vprop = fun b -> exists_ (forall_pred n arr p r perm s () b) inline_for_extraction let forall_cond (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:G.erased (Seq.seq a)) (_:squash (Seq.length s == US.v n)) : unit -> STT bool (exists_ (forall_inv n arr p r perm s ())) (forall_inv n arr p r perm s ()) = fun _ -> let _ = elim_exists () in let _ = elim_exists () in elim_pure _; elim_pure _; let i = R.read r in let b = i = n in let res = if b then return false else let elt = A.read arr i in return (p elt) in intro_pure (forall_pure_inv n p s () i); intro_pure (forall_pure_inv_b n p s () i res); intro_exists i (forall_pred n arr p r perm s () res); return res inline_for_extraction let forall_body (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:G.erased (Seq.seq a)) (_:squash (Seq.length s == US.v n)) : unit -> STT unit (forall_inv n arr p r perm s () true) (fun _ -> exists_ (forall_inv n arr p r perm s ())) = fun _ -> let _ = elim_exists () in elim_pure _; elim_pure _; //atomic increment? let i = R.read r in R.write r (US.add i 1sz); intro_pure (forall_pure_inv n p s () (US.add i 1sz)); intro_pure (forall_pure_inv_b n p s () (US.add i 1sz) ((US.add i 1sz) `US.lt` n && p (Seq.index s (US.v (US.add i 1sz))))); intro_exists (US.add i 1sz) (forall_pred n arr p r perm s () ((US.add i 1sz) `US.lt` n && p (Seq.index s (US.v (US.add i 1sz))))); intro_exists ((US.add i 1sz) `US.lt` n && p (Seq.index s (US.v (US.add i 1sz)))) (forall_inv n arr p r perm s ()) let for_all #a #perm #s n arr p = A.pts_to_length arr s; let b = n = 0sz in if b then return true else begin //This could be stack allocated let r = R.alloc 0sz in intro_pure (forall_pure_inv n p s () 0sz); intro_pure (forall_pure_inv_b n p s () 0sz (0sz `US.lt` n && p (Seq.index s (US.v 0sz)))); intro_exists 0sz (forall_pred n arr p r perm s () (0sz `US.lt` n && p (Seq.index s (US.v 0sz)))); intro_exists (0sz `US.lt` n && p (Seq.index s (US.v 0sz))) (forall_inv n arr p r perm s ()); Loops.while_loop (forall_inv n arr p r perm s ()) (forall_cond n arr p r perm s ()) (forall_body n arr p r perm s ()); let _ = elim_exists () in let _ = elim_pure _ in let _ = elim_pure _ in let i = R.read r in //This free would go away if we had stack allocations R.free r; return (i = n) end /// Implementation of for_all2 using a while loop let forall2_pure_inv (#a #b:Type0) (n:US.t) (p:a -> b -> bool) (s0:Seq.seq a) (s1:Seq.seq b) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) (i:US.t)
false
false
Steel.ST.Array.Util.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val forall2_pure_inv: #a: Type0 -> #b: Type0 -> n: US.t -> p: (a -> b -> bool) -> s0: Seq.seq a -> s1: Seq.seq b -> squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1) -> i: US.t -> prop
[]
Steel.ST.Array.Util.forall2_pure_inv
{ "file_name": "lib/steel/Steel.ST.Array.Util.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: FStar.SizeT.t -> p: (_: a -> _: b -> Prims.bool) -> s0: FStar.Seq.Base.seq a -> s1: FStar.Seq.Base.seq b -> _: Prims.squash (FStar.Seq.Base.length s0 == FStar.SizeT.v n /\ FStar.Seq.Base.length s0 == FStar.Seq.Base.length s1) -> i: FStar.SizeT.t -> Prims.prop
{ "end_col": 88, "end_line": 277, "start_col": 4, "start_line": 277 }
Steel.ST.Effect.ST
val array_literal (#a:Type0) (n:US.t) (f:(i:US.t{US.v i < US.v n} -> a)) : ST (A.array a) emp (fun arr -> A.pts_to arr full_perm (Seq.init (US.v n) (fun i -> f (US.uint_to_t i)))) (requires US.v n > 0) (ensures fun arr -> A.length arr == US.v n)
[ { "abbrev": true, "full_module": "Steel.ST.Loops", "short_module": "Loops" }, { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let array_literal #a n f = let arr = A.alloc (f 0sz) n in intro_pure (array_literal_inv_pure n f 1 (Seq.create (US.v n) (f 0sz))); intro_exists (Seq.create (US.v n) (f 0sz)) (array_literal_inv n arr f 1); Loops.for_loop 1sz n (fun i -> exists_ (array_literal_inv n arr f i)) (array_literal_loop_body n arr f); let s = elim_exists () in A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v n) s); assert (Seq.equal s (Seq.init (US.v n) (fun i -> f (US.uint_to_t i)))); rewrite (A.pts_to arr full_perm s) _; return arr
val array_literal (#a:Type0) (n:US.t) (f:(i:US.t{US.v i < US.v n} -> a)) : ST (A.array a) emp (fun arr -> A.pts_to arr full_perm (Seq.init (US.v n) (fun i -> f (US.uint_to_t i)))) (requires US.v n > 0) (ensures fun arr -> A.length arr == US.v n) let array_literal #a n f =
true
null
false
let arr = A.alloc (f 0sz) n in intro_pure (array_literal_inv_pure n f 1 (Seq.create (US.v n) (f 0sz))); intro_exists (Seq.create (US.v n) (f 0sz)) (array_literal_inv n arr f 1); Loops.for_loop 1sz n (fun i -> exists_ (array_literal_inv n arr f i)) (array_literal_loop_body n arr f); let s = elim_exists () in A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v n) s); assert (Seq.equal s (Seq.init (US.v n) (fun i -> f (US.uint_to_t i)))); rewrite (A.pts_to arr full_perm s) _; return arr
{ "checked_file": "Steel.ST.Array.Util.fst.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.Reference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.ST.Effect.fsti.checked", "Steel.ST.Array.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Array.Util.fst" }
[]
[ "FStar.SizeT.t", "Prims.b2t", "Prims.op_LessThan", "FStar.SizeT.v", "Steel.ST.Util.return", "Steel.ST.Array.array", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.ST.Array.pts_to", "Steel.FractionalPermission.full_perm", "FStar.Seq.Base.init", "Prims.nat", "FStar.SizeT.uint_to_t", "Steel.Effect.Common.vprop", "Prims.unit", "Steel.ST.Util.rewrite", "FStar.Ghost.reveal", "FStar.Seq.Base.seq", "Prims._assert", "FStar.Seq.Base.equal", "Steel.ST.Util.elim_pure", "Steel.ST.Array.Util.array_literal_inv_pure", "Steel.ST.Array.pts_to_length", "FStar.Ghost.erased", "Steel.ST.Util.elim_exists", "Steel.Effect.Common.VStar", "Steel.ST.Util.pure", "Steel.ST.Loops.for_loop", "FStar.SizeT.__uint_to_t", "Steel.ST.Loops.nat_at_most", "Steel.ST.Util.exists_", "Steel.ST.Array.Util.array_literal_inv", "Steel.ST.Array.Util.array_literal_loop_body", "Steel.ST.Util.intro_exists", "FStar.Seq.Base.create", "Steel.ST.Util.intro_pure", "Steel.ST.Array.alloc" ]
[]
(* Copyright 2021 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.Util module G = FStar.Ghost module US = FStar.SizeT module R = Steel.ST.Reference module A = Steel.ST.Array module Loops = Steel.ST.Loops open Steel.FractionalPermission open Steel.ST.Effect open Steel.ST.Util /// Implementation of array_literal using a for loop let array_literal_inv_pure (#a:Type0) (n:US.t) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) (s:Seq.seq a) : prop = forall (j:nat). (j < i /\ j < Seq.length s) ==> Seq.index s j == f (US.uint_to_t j) [@@ __reduce__] let array_literal_inv (#a:Type0) (n:US.t) (arr:A.array a) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) : Seq.seq a -> vprop = fun s -> A.pts_to arr full_perm s `star` pure (array_literal_inv_pure n f i s) inline_for_extraction let array_literal_loop_body (#a:Type0) (n:US.t) (arr:A.array a{A.length arr == US.v n}) (f:(i:US.t{US.v i < US.v n} -> a)) : i:Loops.u32_between 0sz n -> STT unit (exists_ (array_literal_inv n arr f (US.v i))) (fun _ -> exists_ (array_literal_inv n arr f (US.v i + 1))) = fun i -> let s = elim_exists () in (); A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v i) s); A.write arr i (f i); intro_pure (array_literal_inv_pure n f (US.v i + 1) (Seq.upd s (US.v i) (f i))); intro_exists (Seq.upd s (US.v i) (f i)) (array_literal_inv n arr f (US.v i + 1))
false
false
Steel.ST.Array.Util.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val array_literal (#a:Type0) (n:US.t) (f:(i:US.t{US.v i < US.v n} -> a)) : ST (A.array a) emp (fun arr -> A.pts_to arr full_perm (Seq.init (US.v n) (fun i -> f (US.uint_to_t i)))) (requires US.v n > 0) (ensures fun arr -> A.length arr == US.v n)
[]
Steel.ST.Array.Util.array_literal
{ "file_name": "lib/steel/Steel.ST.Array.Util.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: FStar.SizeT.t -> f: (i: FStar.SizeT.t{FStar.SizeT.v i < FStar.SizeT.v n} -> a) -> Steel.ST.Effect.ST (Steel.ST.Array.array a)
{ "end_col": 12, "end_line": 100, "start_col": 26, "start_line": 80 }
Steel.ST.Effect.STT
val forall_body: #a: Type0 -> n: US.t -> arr: A.array a -> p: (a -> bool) -> r: R.ref US.t -> perm: perm -> s: G.erased (Seq.seq a) -> squash (Seq.length s == US.v n) -> unit -> STT unit (forall_inv n arr p r perm s () true) (fun _ -> exists_ (forall_inv n arr p r perm s ()))
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Loops", "short_module": "Loops" }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let forall_body (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:G.erased (Seq.seq a)) (_:squash (Seq.length s == US.v n)) : unit -> STT unit (forall_inv n arr p r perm s () true) (fun _ -> exists_ (forall_inv n arr p r perm s ())) = fun _ -> let _ = elim_exists () in elim_pure _; elim_pure _; //atomic increment? let i = R.read r in R.write r (US.add i 1sz); intro_pure (forall_pure_inv n p s () (US.add i 1sz)); intro_pure (forall_pure_inv_b n p s () (US.add i 1sz) ((US.add i 1sz) `US.lt` n && p (Seq.index s (US.v (US.add i 1sz))))); intro_exists (US.add i 1sz) (forall_pred n arr p r perm s () ((US.add i 1sz) `US.lt` n && p (Seq.index s (US.v (US.add i 1sz))))); intro_exists ((US.add i 1sz) `US.lt` n && p (Seq.index s (US.v (US.add i 1sz)))) (forall_inv n arr p r perm s ())
val forall_body: #a: Type0 -> n: US.t -> arr: A.array a -> p: (a -> bool) -> r: R.ref US.t -> perm: perm -> s: G.erased (Seq.seq a) -> squash (Seq.length s == US.v n) -> unit -> STT unit (forall_inv n arr p r perm s () true) (fun _ -> exists_ (forall_inv n arr p r perm s ())) let forall_body (#a: Type0) (n: US.t) (arr: A.array a) (p: (a -> bool)) (r: R.ref US.t) (perm: perm) (s: G.erased (Seq.seq a)) (_: squash (Seq.length s == US.v n)) : unit -> STT unit (forall_inv n arr p r perm s () true) (fun _ -> exists_ (forall_inv n arr p r perm s ())) =
true
null
false
fun _ -> let _ = elim_exists () in elim_pure _; elim_pure _; let i = R.read r in R.write r (US.add i 1sz); intro_pure (forall_pure_inv n p s () (US.add i 1sz)); intro_pure (forall_pure_inv_b n p s () (US.add i 1sz) ((US.add i 1sz) `US.lt` n && p (Seq.index s (US.v (US.add i 1sz))))); intro_exists (US.add i 1sz) (forall_pred n arr p r perm s () ((US.add i 1sz) `US.lt` n && p (Seq.index s (US.v (US.add i 1sz))))); intro_exists ((US.add i 1sz) `US.lt` n && p (Seq.index s (US.v (US.add i 1sz)))) (forall_inv n arr p r perm s ())
{ "checked_file": "Steel.ST.Array.Util.fst.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.Reference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.ST.Effect.fsti.checked", "Steel.ST.Array.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Array.Util.fst" }
[]
[ "FStar.SizeT.t", "Steel.ST.Array.array", "Prims.bool", "Steel.ST.Reference.ref", "Steel.FractionalPermission.perm", "FStar.Ghost.erased", "FStar.Seq.Base.seq", "Prims.squash", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "FStar.Ghost.reveal", "FStar.SizeT.v", "Prims.unit", "Steel.ST.Util.intro_exists", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Prims.op_AmpAmp", "FStar.SizeT.lt", "FStar.SizeT.add", "FStar.SizeT.__uint_to_t", "FStar.Seq.Base.index", "Steel.ST.Array.Util.forall_inv", "Steel.ST.Array.Util.forall_pred", "Steel.ST.Util.intro_pure", "Steel.ST.Array.Util.forall_pure_inv_b", "Steel.ST.Array.Util.forall_pure_inv", "Steel.ST.Reference.write", "Steel.ST.Reference.read", "Steel.FractionalPermission.full_perm", "Steel.ST.Util.elim_pure", "Steel.ST.Util.elim_exists", "Steel.Effect.Common.VStar", "Steel.ST.Array.pts_to", "Steel.ST.Reference.pts_to", "Steel.ST.Util.pure", "Steel.Effect.Common.vprop", "Steel.ST.Util.exists_" ]
[]
(* Copyright 2021 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.Util module G = FStar.Ghost module US = FStar.SizeT module R = Steel.ST.Reference module A = Steel.ST.Array module Loops = Steel.ST.Loops open Steel.FractionalPermission open Steel.ST.Effect open Steel.ST.Util /// Implementation of array_literal using a for loop let array_literal_inv_pure (#a:Type0) (n:US.t) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) (s:Seq.seq a) : prop = forall (j:nat). (j < i /\ j < Seq.length s) ==> Seq.index s j == f (US.uint_to_t j) [@@ __reduce__] let array_literal_inv (#a:Type0) (n:US.t) (arr:A.array a) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) : Seq.seq a -> vprop = fun s -> A.pts_to arr full_perm s `star` pure (array_literal_inv_pure n f i s) inline_for_extraction let array_literal_loop_body (#a:Type0) (n:US.t) (arr:A.array a{A.length arr == US.v n}) (f:(i:US.t{US.v i < US.v n} -> a)) : i:Loops.u32_between 0sz n -> STT unit (exists_ (array_literal_inv n arr f (US.v i))) (fun _ -> exists_ (array_literal_inv n arr f (US.v i + 1))) = fun i -> let s = elim_exists () in (); A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v i) s); A.write arr i (f i); intro_pure (array_literal_inv_pure n f (US.v i + 1) (Seq.upd s (US.v i) (f i))); intro_exists (Seq.upd s (US.v i) (f i)) (array_literal_inv n arr f (US.v i + 1)) let array_literal #a n f = let arr = A.alloc (f 0sz) n in intro_pure (array_literal_inv_pure n f 1 (Seq.create (US.v n) (f 0sz))); intro_exists (Seq.create (US.v n) (f 0sz)) (array_literal_inv n arr f 1); Loops.for_loop 1sz n (fun i -> exists_ (array_literal_inv n arr f i)) (array_literal_loop_body n arr f); let s = elim_exists () in A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v n) s); assert (Seq.equal s (Seq.init (US.v n) (fun i -> f (US.uint_to_t i)))); rewrite (A.pts_to arr full_perm s) _; return arr /// Implementation of for_all using a while loop let forall_pure_inv (#a:Type0) (n:US.t) (p:a -> bool) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (i:US.t) : prop = i `US.lte` n /\ (forall (j:nat). j < US.v i ==> p (Seq.index s j)) let forall_pure_inv_b (#a:Type0) (n:US.t) (p:a -> bool) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (i:US.t) (b:bool) : prop = b == (i `US.lt` n && p (Seq.index s (US.v i))) [@@ __reduce__] let forall_pred (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (b:bool) : US.t -> vprop = fun i -> A.pts_to arr perm s `star` R.pts_to r full_perm i `star` pure (forall_pure_inv n p s () i) `star` pure (forall_pure_inv_b n p s () i b) [@@ __reduce__] let forall_inv (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) : bool -> vprop = fun b -> exists_ (forall_pred n arr p r perm s () b) inline_for_extraction let forall_cond (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:G.erased (Seq.seq a)) (_:squash (Seq.length s == US.v n)) : unit -> STT bool (exists_ (forall_inv n arr p r perm s ())) (forall_inv n arr p r perm s ()) = fun _ -> let _ = elim_exists () in let _ = elim_exists () in elim_pure _; elim_pure _; let i = R.read r in let b = i = n in let res = if b then return false else let elt = A.read arr i in return (p elt) in intro_pure (forall_pure_inv n p s () i); intro_pure (forall_pure_inv_b n p s () i res); intro_exists i (forall_pred n arr p r perm s () res); return res inline_for_extraction let forall_body (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:G.erased (Seq.seq a)) (_:squash (Seq.length s == US.v n)) : unit -> STT unit (forall_inv n arr p r perm s () true)
false
false
Steel.ST.Array.Util.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val forall_body: #a: Type0 -> n: US.t -> arr: A.array a -> p: (a -> bool) -> r: R.ref US.t -> perm: perm -> s: G.erased (Seq.seq a) -> squash (Seq.length s == US.v n) -> unit -> STT unit (forall_inv n arr p r perm s () true) (fun _ -> exists_ (forall_inv n arr p r perm s ()))
[]
Steel.ST.Array.Util.forall_body
{ "file_name": "lib/steel/Steel.ST.Array.Util.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: FStar.SizeT.t -> arr: Steel.ST.Array.array a -> p: (_: a -> Prims.bool) -> r: Steel.ST.Reference.ref FStar.SizeT.t -> perm: Steel.FractionalPermission.perm -> s: FStar.Ghost.erased (FStar.Seq.Base.seq a) -> _: Prims.squash (FStar.Seq.Base.length (FStar.Ghost.reveal s) == FStar.SizeT.v n) -> _: Prims.unit -> Steel.ST.Effect.STT Prims.unit
{ "end_col": 38, "end_line": 225, "start_col": 4, "start_line": 206 }
Steel.ST.Effect.STT
val forall2_body: #a: Type0 -> #b: Type0 -> n: US.t -> a0: A.array a -> a1: A.array b -> p: (a -> b -> bool) -> r: R.ref US.t -> p0: perm -> p1: perm -> s0: G.erased (Seq.seq a) -> s1: G.erased (Seq.seq b) -> squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1) -> unit -> STT unit (forall2_inv n a0 a1 p r p0 p1 s0 s1 () true) (fun _ -> exists_ (forall2_inv n a0 a1 p r p0 p1 s0 s1 ()))
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Loops", "short_module": "Loops" }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let forall2_body (#a #b:Type0) (n:US.t) (a0:A.array a) (a1:A.array b) (p:a -> b -> bool) (r:R.ref US.t) (p0 p1:perm) (s0:G.erased (Seq.seq a)) (s1:G.erased (Seq.seq b)) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) : unit -> STT unit (forall2_inv n a0 a1 p r p0 p1 s0 s1 () true) (fun _ -> exists_ (forall2_inv n a0 a1 p r p0 p1 s0 s1 ())) = fun _ -> let _ = elim_exists () in elim_pure _; elim_pure _; //atomic increment? let i = R.read r in R.write r (US.add i 1sz); intro_pure (forall2_pure_inv n p s0 s1 () (US.add i 1sz)); intro_pure (forall2_pure_inv_b n p s0 s1 () (US.add i 1sz) ((US.add i 1sz) `US.lt` n && p (Seq.index s0 (US.v (US.add i 1sz))) (Seq.index s1 (US.v (US.add i 1sz))))); intro_exists (US.add i 1sz) (forall2_pred n a0 a1 p r p0 p1 s0 s1 () ((US.add i 1sz) `US.lt` n && p (Seq.index s0 (US.v (US.add i 1sz))) (Seq.index s1 (US.v (US.add i 1sz))))); intro_exists ((US.add i 1sz) `US.lt` n && p (Seq.index s0 (US.v (US.add i 1sz))) (Seq.index s1 (US.v (US.add i 1sz)))) (forall2_inv n a0 a1 p r p0 p1 s0 s1 ())
val forall2_body: #a: Type0 -> #b: Type0 -> n: US.t -> a0: A.array a -> a1: A.array b -> p: (a -> b -> bool) -> r: R.ref US.t -> p0: perm -> p1: perm -> s0: G.erased (Seq.seq a) -> s1: G.erased (Seq.seq b) -> squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1) -> unit -> STT unit (forall2_inv n a0 a1 p r p0 p1 s0 s1 () true) (fun _ -> exists_ (forall2_inv n a0 a1 p r p0 p1 s0 s1 ())) let forall2_body (#a: Type0) (#b: Type0) (n: US.t) (a0: A.array a) (a1: A.array b) (p: (a -> b -> bool)) (r: R.ref US.t) (p0: perm) (p1: perm) (s0: G.erased (Seq.seq a)) (s1: G.erased (Seq.seq b)) (_: squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) : unit -> STT unit (forall2_inv n a0 a1 p r p0 p1 s0 s1 () true) (fun _ -> exists_ (forall2_inv n a0 a1 p r p0 p1 s0 s1 ())) =
true
null
false
fun _ -> let _ = elim_exists () in elim_pure _; elim_pure _; let i = R.read r in R.write r (US.add i 1sz); intro_pure (forall2_pure_inv n p s0 s1 () (US.add i 1sz)); intro_pure (forall2_pure_inv_b n p s0 s1 () (US.add i 1sz) ((US.add i 1sz) `US.lt` n && p (Seq.index s0 (US.v (US.add i 1sz))) (Seq.index s1 (US.v (US.add i 1sz))))); intro_exists (US.add i 1sz) (forall2_pred n a0 a1 p r p0 p1 s0 s1 () ((US.add i 1sz) `US.lt` n && p (Seq.index s0 (US.v (US.add i 1sz))) (Seq.index s1 (US.v (US.add i 1sz))))); intro_exists ((US.add i 1sz) `US.lt` n && p (Seq.index s0 (US.v (US.add i 1sz))) (Seq.index s1 (US.v (US.add i 1sz)))) (forall2_inv n a0 a1 p r p0 p1 s0 s1 ())
{ "checked_file": "Steel.ST.Array.Util.fst.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.Reference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.ST.Effect.fsti.checked", "Steel.ST.Array.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Array.Util.fst" }
[]
[ "FStar.SizeT.t", "Steel.ST.Array.array", "Prims.bool", "Steel.ST.Reference.ref", "Steel.FractionalPermission.perm", "FStar.Ghost.erased", "FStar.Seq.Base.seq", "Prims.squash", "Prims.l_and", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "FStar.Ghost.reveal", "FStar.SizeT.v", "Prims.unit", "Steel.ST.Util.intro_exists", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Prims.op_AmpAmp", "FStar.SizeT.lt", "FStar.SizeT.add", "FStar.SizeT.__uint_to_t", "FStar.Seq.Base.index", "Steel.ST.Array.Util.forall2_inv", "Steel.ST.Array.Util.forall2_pred", "Steel.ST.Util.intro_pure", "Steel.ST.Array.Util.forall2_pure_inv_b", "Steel.ST.Array.Util.forall2_pure_inv", "Steel.ST.Reference.write", "Steel.ST.Reference.read", "Steel.FractionalPermission.full_perm", "Steel.ST.Util.elim_pure", "Steel.ST.Util.elim_exists", "Steel.Effect.Common.VStar", "Steel.ST.Array.pts_to", "Steel.ST.Reference.pts_to", "Steel.ST.Util.pure", "Steel.Effect.Common.vprop", "Steel.ST.Util.exists_" ]
[]
(* Copyright 2021 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.Util module G = FStar.Ghost module US = FStar.SizeT module R = Steel.ST.Reference module A = Steel.ST.Array module Loops = Steel.ST.Loops open Steel.FractionalPermission open Steel.ST.Effect open Steel.ST.Util /// Implementation of array_literal using a for loop let array_literal_inv_pure (#a:Type0) (n:US.t) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) (s:Seq.seq a) : prop = forall (j:nat). (j < i /\ j < Seq.length s) ==> Seq.index s j == f (US.uint_to_t j) [@@ __reduce__] let array_literal_inv (#a:Type0) (n:US.t) (arr:A.array a) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) : Seq.seq a -> vprop = fun s -> A.pts_to arr full_perm s `star` pure (array_literal_inv_pure n f i s) inline_for_extraction let array_literal_loop_body (#a:Type0) (n:US.t) (arr:A.array a{A.length arr == US.v n}) (f:(i:US.t{US.v i < US.v n} -> a)) : i:Loops.u32_between 0sz n -> STT unit (exists_ (array_literal_inv n arr f (US.v i))) (fun _ -> exists_ (array_literal_inv n arr f (US.v i + 1))) = fun i -> let s = elim_exists () in (); A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v i) s); A.write arr i (f i); intro_pure (array_literal_inv_pure n f (US.v i + 1) (Seq.upd s (US.v i) (f i))); intro_exists (Seq.upd s (US.v i) (f i)) (array_literal_inv n arr f (US.v i + 1)) let array_literal #a n f = let arr = A.alloc (f 0sz) n in intro_pure (array_literal_inv_pure n f 1 (Seq.create (US.v n) (f 0sz))); intro_exists (Seq.create (US.v n) (f 0sz)) (array_literal_inv n arr f 1); Loops.for_loop 1sz n (fun i -> exists_ (array_literal_inv n arr f i)) (array_literal_loop_body n arr f); let s = elim_exists () in A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v n) s); assert (Seq.equal s (Seq.init (US.v n) (fun i -> f (US.uint_to_t i)))); rewrite (A.pts_to arr full_perm s) _; return arr /// Implementation of for_all using a while loop let forall_pure_inv (#a:Type0) (n:US.t) (p:a -> bool) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (i:US.t) : prop = i `US.lte` n /\ (forall (j:nat). j < US.v i ==> p (Seq.index s j)) let forall_pure_inv_b (#a:Type0) (n:US.t) (p:a -> bool) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (i:US.t) (b:bool) : prop = b == (i `US.lt` n && p (Seq.index s (US.v i))) [@@ __reduce__] let forall_pred (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (b:bool) : US.t -> vprop = fun i -> A.pts_to arr perm s `star` R.pts_to r full_perm i `star` pure (forall_pure_inv n p s () i) `star` pure (forall_pure_inv_b n p s () i b) [@@ __reduce__] let forall_inv (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) : bool -> vprop = fun b -> exists_ (forall_pred n arr p r perm s () b) inline_for_extraction let forall_cond (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:G.erased (Seq.seq a)) (_:squash (Seq.length s == US.v n)) : unit -> STT bool (exists_ (forall_inv n arr p r perm s ())) (forall_inv n arr p r perm s ()) = fun _ -> let _ = elim_exists () in let _ = elim_exists () in elim_pure _; elim_pure _; let i = R.read r in let b = i = n in let res = if b then return false else let elt = A.read arr i in return (p elt) in intro_pure (forall_pure_inv n p s () i); intro_pure (forall_pure_inv_b n p s () i res); intro_exists i (forall_pred n arr p r perm s () res); return res inline_for_extraction let forall_body (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:G.erased (Seq.seq a)) (_:squash (Seq.length s == US.v n)) : unit -> STT unit (forall_inv n arr p r perm s () true) (fun _ -> exists_ (forall_inv n arr p r perm s ())) = fun _ -> let _ = elim_exists () in elim_pure _; elim_pure _; //atomic increment? let i = R.read r in R.write r (US.add i 1sz); intro_pure (forall_pure_inv n p s () (US.add i 1sz)); intro_pure (forall_pure_inv_b n p s () (US.add i 1sz) ((US.add i 1sz) `US.lt` n && p (Seq.index s (US.v (US.add i 1sz))))); intro_exists (US.add i 1sz) (forall_pred n arr p r perm s () ((US.add i 1sz) `US.lt` n && p (Seq.index s (US.v (US.add i 1sz))))); intro_exists ((US.add i 1sz) `US.lt` n && p (Seq.index s (US.v (US.add i 1sz)))) (forall_inv n arr p r perm s ()) let for_all #a #perm #s n arr p = A.pts_to_length arr s; let b = n = 0sz in if b then return true else begin //This could be stack allocated let r = R.alloc 0sz in intro_pure (forall_pure_inv n p s () 0sz); intro_pure (forall_pure_inv_b n p s () 0sz (0sz `US.lt` n && p (Seq.index s (US.v 0sz)))); intro_exists 0sz (forall_pred n arr p r perm s () (0sz `US.lt` n && p (Seq.index s (US.v 0sz)))); intro_exists (0sz `US.lt` n && p (Seq.index s (US.v 0sz))) (forall_inv n arr p r perm s ()); Loops.while_loop (forall_inv n arr p r perm s ()) (forall_cond n arr p r perm s ()) (forall_body n arr p r perm s ()); let _ = elim_exists () in let _ = elim_pure _ in let _ = elim_pure _ in let i = R.read r in //This free would go away if we had stack allocations R.free r; return (i = n) end /// Implementation of for_all2 using a while loop let forall2_pure_inv (#a #b:Type0) (n:US.t) (p:a -> b -> bool) (s0:Seq.seq a) (s1:Seq.seq b) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) (i:US.t) : prop = i `US.lte` n /\ (forall (j:nat). j < US.v i ==> p (Seq.index s0 j) (Seq.index s1 j)) let forall2_pure_inv_b (#a #b:Type0) (n:US.t) (p:a -> b -> bool) (s0:Seq.seq a) (s1:Seq.seq b) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) (i:US.t) (g:bool) : prop = g == (i `US.lt` n && p (Seq.index s0 (US.v i)) (Seq.index s1 (US.v i))) [@@ __reduce__] let forall2_pred (#a #b:Type0) (n:US.t) (a0:A.array a) (a1:A.array b) (p:a -> b -> bool) (r:R.ref US.t) (p0 p1:perm) (s0:Seq.seq a) (s1:Seq.seq b) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) (g:bool) : US.t -> vprop = fun i -> A.pts_to a0 p0 s0 `star` A.pts_to a1 p1 s1 `star` R.pts_to r full_perm i `star` pure (forall2_pure_inv n p s0 s1 () i) `star` pure (forall2_pure_inv_b n p s0 s1 () i g) [@@ __reduce__] let forall2_inv (#a #b:Type0) (n:US.t) (a0:A.array a) (a1:A.array b) (p:a -> b -> bool) (r:R.ref US.t) (p0 p1:perm) (s0:Seq.seq a) (s1:Seq.seq b) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) : bool -> vprop = fun g -> exists_ (forall2_pred n a0 a1 p r p0 p1 s0 s1 () g) inline_for_extraction let forall2_cond (#a #b:Type0) (n:US.t) (a0:A.array a) (a1:A.array b) (p:a -> b -> bool) (r:R.ref US.t) (p0 p1:perm) (s0:G.erased (Seq.seq a)) (s1:G.erased (Seq.seq b)) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) : unit -> STT bool (exists_ (forall2_inv n a0 a1 p r p0 p1 s0 s1 ())) (forall2_inv n a0 a1 p r p0 p1 s0 s1 ()) = fun _ -> let _ = elim_exists () in let _ = elim_exists () in elim_pure _; elim_pure _; let i = R.read r in let b = i = n in let res = if b then return false else let elt0 = A.read a0 i in let elt1 = A.read a1 i in return (p elt0 elt1) in intro_pure (forall2_pure_inv n p s0 s1 () i); intro_pure (forall2_pure_inv_b n p s0 s1 () i res); intro_exists i (forall2_pred n a0 a1 p r p0 p1 s0 s1 () res); return res inline_for_extraction let forall2_body (#a #b:Type0) (n:US.t) (a0:A.array a) (a1:A.array b) (p:a -> b -> bool) (r:R.ref US.t) (p0 p1:perm) (s0:G.erased (Seq.seq a)) (s1:G.erased (Seq.seq b)) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) : unit -> STT unit (forall2_inv n a0 a1 p r p0 p1 s0 s1 () true)
false
false
Steel.ST.Array.Util.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val forall2_body: #a: Type0 -> #b: Type0 -> n: US.t -> a0: A.array a -> a1: A.array b -> p: (a -> b -> bool) -> r: R.ref US.t -> p0: perm -> p1: perm -> s0: G.erased (Seq.seq a) -> s1: G.erased (Seq.seq b) -> squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1) -> unit -> STT unit (forall2_inv n a0 a1 p r p0 p1 s0 s1 () true) (fun _ -> exists_ (forall2_inv n a0 a1 p r p0 p1 s0 s1 ()))
[]
Steel.ST.Array.Util.forall2_body
{ "file_name": "lib/steel/Steel.ST.Array.Util.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: FStar.SizeT.t -> a0: Steel.ST.Array.array a -> a1: Steel.ST.Array.array b -> p: (_: a -> _: b -> Prims.bool) -> r: Steel.ST.Reference.ref FStar.SizeT.t -> p0: Steel.FractionalPermission.perm -> p1: Steel.FractionalPermission.perm -> s0: FStar.Ghost.erased (FStar.Seq.Base.seq a) -> s1: FStar.Ghost.erased (FStar.Seq.Base.seq b) -> _: Prims.squash (FStar.Seq.Base.length (FStar.Ghost.reveal s0) == FStar.SizeT.v n /\ FStar.Seq.Base.length (FStar.Ghost.reveal s0) == FStar.Seq.Base.length (FStar.Ghost.reveal s1)) -> _: Prims.unit -> Steel.ST.Effect.STT Prims.unit
{ "end_col": 46, "end_line": 404, "start_col": 4, "start_line": 382 }
Steel.ST.Effect.STT
val forall_cond: #a: Type0 -> n: US.t -> arr: A.array a -> p: (a -> bool) -> r: R.ref US.t -> perm: perm -> s: G.erased (Seq.seq a) -> squash (Seq.length s == US.v n) -> unit -> STT bool (exists_ (forall_inv n arr p r perm s ())) (forall_inv n arr p r perm s ())
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Loops", "short_module": "Loops" }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let forall_cond (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:G.erased (Seq.seq a)) (_:squash (Seq.length s == US.v n)) : unit -> STT bool (exists_ (forall_inv n arr p r perm s ())) (forall_inv n arr p r perm s ()) = fun _ -> let _ = elim_exists () in let _ = elim_exists () in elim_pure _; elim_pure _; let i = R.read r in let b = i = n in let res = if b then return false else let elt = A.read arr i in return (p elt) in intro_pure (forall_pure_inv n p s () i); intro_pure (forall_pure_inv_b n p s () i res); intro_exists i (forall_pred n arr p r perm s () res); return res
val forall_cond: #a: Type0 -> n: US.t -> arr: A.array a -> p: (a -> bool) -> r: R.ref US.t -> perm: perm -> s: G.erased (Seq.seq a) -> squash (Seq.length s == US.v n) -> unit -> STT bool (exists_ (forall_inv n arr p r perm s ())) (forall_inv n arr p r perm s ()) let forall_cond (#a: Type0) (n: US.t) (arr: A.array a) (p: (a -> bool)) (r: R.ref US.t) (perm: perm) (s: G.erased (Seq.seq a)) (_: squash (Seq.length s == US.v n)) : unit -> STT bool (exists_ (forall_inv n arr p r perm s ())) (forall_inv n arr p r perm s ()) =
true
null
false
fun _ -> let _ = elim_exists () in let _ = elim_exists () in elim_pure _; elim_pure _; let i = R.read r in let b = i = n in let res = if b then return false else let elt = A.read arr i in return (p elt) in intro_pure (forall_pure_inv n p s () i); intro_pure (forall_pure_inv_b n p s () i res); intro_exists i (forall_pred n arr p r perm s () res); return res
{ "checked_file": "Steel.ST.Array.Util.fst.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.Reference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.ST.Effect.fsti.checked", "Steel.ST.Array.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Array.Util.fst" }
[]
[ "FStar.SizeT.t", "Steel.ST.Array.array", "Prims.bool", "Steel.ST.Reference.ref", "Steel.FractionalPermission.perm", "FStar.Ghost.erased", "FStar.Seq.Base.seq", "Prims.squash", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "FStar.Ghost.reveal", "FStar.SizeT.v", "Prims.unit", "Steel.ST.Util.return", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.ST.Util.exists_", "Steel.Effect.Common.VStar", "Steel.ST.Array.pts_to", "Steel.ST.Reference.pts_to", "Steel.FractionalPermission.full_perm", "Steel.ST.Util.pure", "Steel.ST.Array.Util.forall_pure_inv", "Steel.ST.Array.Util.forall_pure_inv_b", "Steel.Effect.Common.vprop", "Steel.ST.Util.intro_exists", "Steel.ST.Array.Util.forall_pred", "Steel.ST.Util.intro_pure", "Steel.ST.Array.read", "Prims.op_Equality", "Steel.ST.Reference.read", "Steel.ST.Util.elim_pure", "Steel.ST.Util.elim_exists", "Steel.ST.Array.Util.forall_inv" ]
[]
(* Copyright 2021 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.Util module G = FStar.Ghost module US = FStar.SizeT module R = Steel.ST.Reference module A = Steel.ST.Array module Loops = Steel.ST.Loops open Steel.FractionalPermission open Steel.ST.Effect open Steel.ST.Util /// Implementation of array_literal using a for loop let array_literal_inv_pure (#a:Type0) (n:US.t) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) (s:Seq.seq a) : prop = forall (j:nat). (j < i /\ j < Seq.length s) ==> Seq.index s j == f (US.uint_to_t j) [@@ __reduce__] let array_literal_inv (#a:Type0) (n:US.t) (arr:A.array a) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) : Seq.seq a -> vprop = fun s -> A.pts_to arr full_perm s `star` pure (array_literal_inv_pure n f i s) inline_for_extraction let array_literal_loop_body (#a:Type0) (n:US.t) (arr:A.array a{A.length arr == US.v n}) (f:(i:US.t{US.v i < US.v n} -> a)) : i:Loops.u32_between 0sz n -> STT unit (exists_ (array_literal_inv n arr f (US.v i))) (fun _ -> exists_ (array_literal_inv n arr f (US.v i + 1))) = fun i -> let s = elim_exists () in (); A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v i) s); A.write arr i (f i); intro_pure (array_literal_inv_pure n f (US.v i + 1) (Seq.upd s (US.v i) (f i))); intro_exists (Seq.upd s (US.v i) (f i)) (array_literal_inv n arr f (US.v i + 1)) let array_literal #a n f = let arr = A.alloc (f 0sz) n in intro_pure (array_literal_inv_pure n f 1 (Seq.create (US.v n) (f 0sz))); intro_exists (Seq.create (US.v n) (f 0sz)) (array_literal_inv n arr f 1); Loops.for_loop 1sz n (fun i -> exists_ (array_literal_inv n arr f i)) (array_literal_loop_body n arr f); let s = elim_exists () in A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v n) s); assert (Seq.equal s (Seq.init (US.v n) (fun i -> f (US.uint_to_t i)))); rewrite (A.pts_to arr full_perm s) _; return arr /// Implementation of for_all using a while loop let forall_pure_inv (#a:Type0) (n:US.t) (p:a -> bool) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (i:US.t) : prop = i `US.lte` n /\ (forall (j:nat). j < US.v i ==> p (Seq.index s j)) let forall_pure_inv_b (#a:Type0) (n:US.t) (p:a -> bool) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (i:US.t) (b:bool) : prop = b == (i `US.lt` n && p (Seq.index s (US.v i))) [@@ __reduce__] let forall_pred (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (b:bool) : US.t -> vprop = fun i -> A.pts_to arr perm s `star` R.pts_to r full_perm i `star` pure (forall_pure_inv n p s () i) `star` pure (forall_pure_inv_b n p s () i b) [@@ __reduce__] let forall_inv (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) : bool -> vprop = fun b -> exists_ (forall_pred n arr p r perm s () b) inline_for_extraction let forall_cond (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:G.erased (Seq.seq a)) (_:squash (Seq.length s == US.v n)) : unit -> STT bool (exists_ (forall_inv n arr p r perm s ()))
false
false
Steel.ST.Array.Util.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val forall_cond: #a: Type0 -> n: US.t -> arr: A.array a -> p: (a -> bool) -> r: R.ref US.t -> perm: perm -> s: G.erased (Seq.seq a) -> squash (Seq.length s == US.v n) -> unit -> STT bool (exists_ (forall_inv n arr p r perm s ())) (forall_inv n arr p r perm s ())
[]
Steel.ST.Array.Util.forall_cond
{ "file_name": "lib/steel/Steel.ST.Array.Util.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: FStar.SizeT.t -> arr: Steel.ST.Array.array a -> p: (_: a -> Prims.bool) -> r: Steel.ST.Reference.ref FStar.SizeT.t -> perm: Steel.FractionalPermission.perm -> s: FStar.Ghost.erased (FStar.Seq.Base.seq a) -> _: Prims.squash (FStar.Seq.Base.length (FStar.Ghost.reveal s) == FStar.SizeT.v n) -> _: Prims.unit -> Steel.ST.Effect.STT Prims.bool
{ "end_col": 14, "end_line": 190, "start_col": 4, "start_line": 174 }
Steel.ST.Effect.STT
val forall2_cond: #a: Type0 -> #b: Type0 -> n: US.t -> a0: A.array a -> a1: A.array b -> p: (a -> b -> bool) -> r: R.ref US.t -> p0: perm -> p1: perm -> s0: G.erased (Seq.seq a) -> s1: G.erased (Seq.seq b) -> squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1) -> unit -> STT bool (exists_ (forall2_inv n a0 a1 p r p0 p1 s0 s1 ())) (forall2_inv n a0 a1 p r p0 p1 s0 s1 ())
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Loops", "short_module": "Loops" }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.ST.Array", "short_module": "A" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.Array", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let forall2_cond (#a #b:Type0) (n:US.t) (a0:A.array a) (a1:A.array b) (p:a -> b -> bool) (r:R.ref US.t) (p0 p1:perm) (s0:G.erased (Seq.seq a)) (s1:G.erased (Seq.seq b)) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) : unit -> STT bool (exists_ (forall2_inv n a0 a1 p r p0 p1 s0 s1 ())) (forall2_inv n a0 a1 p r p0 p1 s0 s1 ()) = fun _ -> let _ = elim_exists () in let _ = elim_exists () in elim_pure _; elim_pure _; let i = R.read r in let b = i = n in let res = if b then return false else let elt0 = A.read a0 i in let elt1 = A.read a1 i in return (p elt0 elt1) in intro_pure (forall2_pure_inv n p s0 s1 () i); intro_pure (forall2_pure_inv_b n p s0 s1 () i res); intro_exists i (forall2_pred n a0 a1 p r p0 p1 s0 s1 () res); return res
val forall2_cond: #a: Type0 -> #b: Type0 -> n: US.t -> a0: A.array a -> a1: A.array b -> p: (a -> b -> bool) -> r: R.ref US.t -> p0: perm -> p1: perm -> s0: G.erased (Seq.seq a) -> s1: G.erased (Seq.seq b) -> squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1) -> unit -> STT bool (exists_ (forall2_inv n a0 a1 p r p0 p1 s0 s1 ())) (forall2_inv n a0 a1 p r p0 p1 s0 s1 ()) let forall2_cond (#a: Type0) (#b: Type0) (n: US.t) (a0: A.array a) (a1: A.array b) (p: (a -> b -> bool)) (r: R.ref US.t) (p0: perm) (p1: perm) (s0: G.erased (Seq.seq a)) (s1: G.erased (Seq.seq b)) (_: squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) : unit -> STT bool (exists_ (forall2_inv n a0 a1 p r p0 p1 s0 s1 ())) (forall2_inv n a0 a1 p r p0 p1 s0 s1 ()) =
true
null
false
fun _ -> let _ = elim_exists () in let _ = elim_exists () in elim_pure _; elim_pure _; let i = R.read r in let b = i = n in let res = if b then return false else let elt0 = A.read a0 i in let elt1 = A.read a1 i in return (p elt0 elt1) in intro_pure (forall2_pure_inv n p s0 s1 () i); intro_pure (forall2_pure_inv_b n p s0 s1 () i res); intro_exists i (forall2_pred n a0 a1 p r p0 p1 s0 s1 () res); return res
{ "checked_file": "Steel.ST.Array.Util.fst.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.ST.Reference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.ST.Effect.fsti.checked", "Steel.ST.Array.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Array.Util.fst" }
[]
[ "FStar.SizeT.t", "Steel.ST.Array.array", "Prims.bool", "Steel.ST.Reference.ref", "Steel.FractionalPermission.perm", "FStar.Ghost.erased", "FStar.Seq.Base.seq", "Prims.squash", "Prims.l_and", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "FStar.Ghost.reveal", "FStar.SizeT.v", "Prims.unit", "Steel.ST.Util.return", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.ST.Util.exists_", "Steel.Effect.Common.VStar", "Steel.ST.Array.pts_to", "Steel.ST.Reference.pts_to", "Steel.FractionalPermission.full_perm", "Steel.ST.Util.pure", "Steel.ST.Array.Util.forall2_pure_inv", "Steel.ST.Array.Util.forall2_pure_inv_b", "Steel.Effect.Common.vprop", "Steel.ST.Util.intro_exists", "Steel.ST.Array.Util.forall2_pred", "Steel.ST.Util.intro_pure", "Steel.ST.Array.read", "Prims.op_Equality", "Steel.ST.Reference.read", "Steel.ST.Util.elim_pure", "Steel.ST.Util.elim_exists", "Steel.ST.Array.Util.forall2_inv" ]
[]
(* Copyright 2021 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.Util module G = FStar.Ghost module US = FStar.SizeT module R = Steel.ST.Reference module A = Steel.ST.Array module Loops = Steel.ST.Loops open Steel.FractionalPermission open Steel.ST.Effect open Steel.ST.Util /// Implementation of array_literal using a for loop let array_literal_inv_pure (#a:Type0) (n:US.t) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) (s:Seq.seq a) : prop = forall (j:nat). (j < i /\ j < Seq.length s) ==> Seq.index s j == f (US.uint_to_t j) [@@ __reduce__] let array_literal_inv (#a:Type0) (n:US.t) (arr:A.array a) (f:(i:US.t{US.v i < US.v n} -> a)) (i:Loops.nat_at_most n) : Seq.seq a -> vprop = fun s -> A.pts_to arr full_perm s `star` pure (array_literal_inv_pure n f i s) inline_for_extraction let array_literal_loop_body (#a:Type0) (n:US.t) (arr:A.array a{A.length arr == US.v n}) (f:(i:US.t{US.v i < US.v n} -> a)) : i:Loops.u32_between 0sz n -> STT unit (exists_ (array_literal_inv n arr f (US.v i))) (fun _ -> exists_ (array_literal_inv n arr f (US.v i + 1))) = fun i -> let s = elim_exists () in (); A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v i) s); A.write arr i (f i); intro_pure (array_literal_inv_pure n f (US.v i + 1) (Seq.upd s (US.v i) (f i))); intro_exists (Seq.upd s (US.v i) (f i)) (array_literal_inv n arr f (US.v i + 1)) let array_literal #a n f = let arr = A.alloc (f 0sz) n in intro_pure (array_literal_inv_pure n f 1 (Seq.create (US.v n) (f 0sz))); intro_exists (Seq.create (US.v n) (f 0sz)) (array_literal_inv n arr f 1); Loops.for_loop 1sz n (fun i -> exists_ (array_literal_inv n arr f i)) (array_literal_loop_body n arr f); let s = elim_exists () in A.pts_to_length arr s; elim_pure (array_literal_inv_pure n f (US.v n) s); assert (Seq.equal s (Seq.init (US.v n) (fun i -> f (US.uint_to_t i)))); rewrite (A.pts_to arr full_perm s) _; return arr /// Implementation of for_all using a while loop let forall_pure_inv (#a:Type0) (n:US.t) (p:a -> bool) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (i:US.t) : prop = i `US.lte` n /\ (forall (j:nat). j < US.v i ==> p (Seq.index s j)) let forall_pure_inv_b (#a:Type0) (n:US.t) (p:a -> bool) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (i:US.t) (b:bool) : prop = b == (i `US.lt` n && p (Seq.index s (US.v i))) [@@ __reduce__] let forall_pred (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) (b:bool) : US.t -> vprop = fun i -> A.pts_to arr perm s `star` R.pts_to r full_perm i `star` pure (forall_pure_inv n p s () i) `star` pure (forall_pure_inv_b n p s () i b) [@@ __reduce__] let forall_inv (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:Seq.seq a) (_:squash (Seq.length s == US.v n)) : bool -> vprop = fun b -> exists_ (forall_pred n arr p r perm s () b) inline_for_extraction let forall_cond (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:G.erased (Seq.seq a)) (_:squash (Seq.length s == US.v n)) : unit -> STT bool (exists_ (forall_inv n arr p r perm s ())) (forall_inv n arr p r perm s ()) = fun _ -> let _ = elim_exists () in let _ = elim_exists () in elim_pure _; elim_pure _; let i = R.read r in let b = i = n in let res = if b then return false else let elt = A.read arr i in return (p elt) in intro_pure (forall_pure_inv n p s () i); intro_pure (forall_pure_inv_b n p s () i res); intro_exists i (forall_pred n arr p r perm s () res); return res inline_for_extraction let forall_body (#a:Type0) (n:US.t) (arr:A.array a) (p:a -> bool) (r:R.ref US.t) (perm:perm) (s:G.erased (Seq.seq a)) (_:squash (Seq.length s == US.v n)) : unit -> STT unit (forall_inv n arr p r perm s () true) (fun _ -> exists_ (forall_inv n arr p r perm s ())) = fun _ -> let _ = elim_exists () in elim_pure _; elim_pure _; //atomic increment? let i = R.read r in R.write r (US.add i 1sz); intro_pure (forall_pure_inv n p s () (US.add i 1sz)); intro_pure (forall_pure_inv_b n p s () (US.add i 1sz) ((US.add i 1sz) `US.lt` n && p (Seq.index s (US.v (US.add i 1sz))))); intro_exists (US.add i 1sz) (forall_pred n arr p r perm s () ((US.add i 1sz) `US.lt` n && p (Seq.index s (US.v (US.add i 1sz))))); intro_exists ((US.add i 1sz) `US.lt` n && p (Seq.index s (US.v (US.add i 1sz)))) (forall_inv n arr p r perm s ()) let for_all #a #perm #s n arr p = A.pts_to_length arr s; let b = n = 0sz in if b then return true else begin //This could be stack allocated let r = R.alloc 0sz in intro_pure (forall_pure_inv n p s () 0sz); intro_pure (forall_pure_inv_b n p s () 0sz (0sz `US.lt` n && p (Seq.index s (US.v 0sz)))); intro_exists 0sz (forall_pred n arr p r perm s () (0sz `US.lt` n && p (Seq.index s (US.v 0sz)))); intro_exists (0sz `US.lt` n && p (Seq.index s (US.v 0sz))) (forall_inv n arr p r perm s ()); Loops.while_loop (forall_inv n arr p r perm s ()) (forall_cond n arr p r perm s ()) (forall_body n arr p r perm s ()); let _ = elim_exists () in let _ = elim_pure _ in let _ = elim_pure _ in let i = R.read r in //This free would go away if we had stack allocations R.free r; return (i = n) end /// Implementation of for_all2 using a while loop let forall2_pure_inv (#a #b:Type0) (n:US.t) (p:a -> b -> bool) (s0:Seq.seq a) (s1:Seq.seq b) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) (i:US.t) : prop = i `US.lte` n /\ (forall (j:nat). j < US.v i ==> p (Seq.index s0 j) (Seq.index s1 j)) let forall2_pure_inv_b (#a #b:Type0) (n:US.t) (p:a -> b -> bool) (s0:Seq.seq a) (s1:Seq.seq b) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) (i:US.t) (g:bool) : prop = g == (i `US.lt` n && p (Seq.index s0 (US.v i)) (Seq.index s1 (US.v i))) [@@ __reduce__] let forall2_pred (#a #b:Type0) (n:US.t) (a0:A.array a) (a1:A.array b) (p:a -> b -> bool) (r:R.ref US.t) (p0 p1:perm) (s0:Seq.seq a) (s1:Seq.seq b) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) (g:bool) : US.t -> vprop = fun i -> A.pts_to a0 p0 s0 `star` A.pts_to a1 p1 s1 `star` R.pts_to r full_perm i `star` pure (forall2_pure_inv n p s0 s1 () i) `star` pure (forall2_pure_inv_b n p s0 s1 () i g) [@@ __reduce__] let forall2_inv (#a #b:Type0) (n:US.t) (a0:A.array a) (a1:A.array b) (p:a -> b -> bool) (r:R.ref US.t) (p0 p1:perm) (s0:Seq.seq a) (s1:Seq.seq b) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) : bool -> vprop = fun g -> exists_ (forall2_pred n a0 a1 p r p0 p1 s0 s1 () g) inline_for_extraction let forall2_cond (#a #b:Type0) (n:US.t) (a0:A.array a) (a1:A.array b) (p:a -> b -> bool) (r:R.ref US.t) (p0 p1:perm) (s0:G.erased (Seq.seq a)) (s1:G.erased (Seq.seq b)) (_:squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1)) : unit -> STT bool (exists_ (forall2_inv n a0 a1 p r p0 p1 s0 s1 ()))
false
false
Steel.ST.Array.Util.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val forall2_cond: #a: Type0 -> #b: Type0 -> n: US.t -> a0: A.array a -> a1: A.array b -> p: (a -> b -> bool) -> r: R.ref US.t -> p0: perm -> p1: perm -> s0: G.erased (Seq.seq a) -> s1: G.erased (Seq.seq b) -> squash (Seq.length s0 == US.v n /\ Seq.length s0 == Seq.length s1) -> unit -> STT bool (exists_ (forall2_inv n a0 a1 p r p0 p1 s0 s1 ())) (forall2_inv n a0 a1 p r p0 p1 s0 s1 ())
[]
Steel.ST.Array.Util.forall2_cond
{ "file_name": "lib/steel/Steel.ST.Array.Util.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: FStar.SizeT.t -> a0: Steel.ST.Array.array a -> a1: Steel.ST.Array.array b -> p: (_: a -> _: b -> Prims.bool) -> r: Steel.ST.Reference.ref FStar.SizeT.t -> p0: Steel.FractionalPermission.perm -> p1: Steel.FractionalPermission.perm -> s0: FStar.Ghost.erased (FStar.Seq.Base.seq a) -> s1: FStar.Ghost.erased (FStar.Seq.Base.seq b) -> _: Prims.squash (FStar.Seq.Base.length (FStar.Ghost.reveal s0) == FStar.SizeT.v n /\ FStar.Seq.Base.length (FStar.Ghost.reveal s0) == FStar.Seq.Base.length (FStar.Ghost.reveal s1)) -> _: Prims.unit -> Steel.ST.Effect.STT Prims.bool
{ "end_col": 14, "end_line": 364, "start_col": 4, "start_line": 347 }
Prims.Tot
val pow_base (#t: Type) (#a_t: BE.inttype_a) (#len: size_t{v len > 0}) (#ctx_len: size_t) (k: mk_precomp_base_table t a_t len ctx_len) (g: t) (i: nat) : k.concr_ops.SE.to.a_spec
[ { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FL" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FL" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let pow_base (#t:Type) (#a_t:BE.inttype_a) (#len:size_t{v len > 0}) (#ctx_len:size_t) (k:mk_precomp_base_table t a_t len ctx_len) (g:t) (i:nat) : k.concr_ops.SE.to.a_spec = LE.pow k.concr_ops.SE.to.comm_monoid (k.concr_ops.SE.to.refl g) i
val pow_base (#t: Type) (#a_t: BE.inttype_a) (#len: size_t{v len > 0}) (#ctx_len: size_t) (k: mk_precomp_base_table t a_t len ctx_len) (g: t) (i: nat) : k.concr_ops.SE.to.a_spec let pow_base (#t: Type) (#a_t: BE.inttype_a) (#len: size_t{v len > 0}) (#ctx_len: size_t) (k: mk_precomp_base_table t a_t len ctx_len) (g: t) (i: nat) : k.concr_ops.SE.to.a_spec =
false
null
false
LE.pow k.concr_ops.SE.to.comm_monoid (k.concr_ops.SE.to.refl g) i
{ "checked_file": "Hacl.Spec.PrecompBaseTable.fsti.checked", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "Hacl.Impl.Exponentiation.Definitions.fst.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.PrecompBaseTable.fsti" }
[ "total" ]
[ "Hacl.Impl.Exponentiation.Definitions.inttype_a", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Spec.PrecompBaseTable.mk_precomp_base_table", "Prims.nat", "Lib.Exponentiation.Definition.pow", "Spec.Exponentiation.__proj__Mkto_comm_monoid__item__a_spec", "Spec.Exponentiation.__proj__Mkconcrete_ops__item__to", "Hacl.Spec.PrecompBaseTable.__proj__Mkmk_precomp_base_table__item__concr_ops", "Spec.Exponentiation.__proj__Mkto_comm_monoid__item__comm_monoid", "Spec.Exponentiation.__proj__Mkto_comm_monoid__item__refl" ]
[]
module Hacl.Spec.PrecompBaseTable open FStar.Mul open Lib.IntTypes module FL = FStar.List.Tot module LSeq = Lib.Sequence module LE = Lib.Exponentiation.Definition module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation.Definitions #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract class mk_precomp_base_table (t:Type) (a_t:BE.inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) = { concr_ops: SE.concrete_ops t; to_cm: x:BE.to_comm_monoid a_t len ctx_len{x.BE.a_spec == concr_ops.SE.to.SE.a_spec}; to_list: t -> x:list (uint_t a_t SEC){FL.length x = v len /\ to_cm.BE.linv (Seq.seq_of_list x)}; lemma_refl: x:t -> Lemma (concr_ops.SE.to.SE.refl x == to_cm.BE.refl (Seq.seq_of_list (to_list x))); } inline_for_extraction noextract let g_i_acc_t (t:Type) (a_t:BE.inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (i:nat) = t & acc:list (uint_t a_t SEC){FL.length acc == (i + 1) * v len} inline_for_extraction noextract let precomp_base_table_f (#t:Type) (#a_t:BE.inttype_a) (#len:size_t{v len > 0}) (#ctx_len:size_t) (k:mk_precomp_base_table t a_t len ctx_len) (g:t) (i:nat) ((g_i,acc): g_i_acc_t t a_t len ctx_len i) : g_i_acc_t t a_t len ctx_len (i + 1) = let acc = FL.(acc @ k.to_list g_i) in let g_i = k.concr_ops.SE.mul g_i g in g_i, acc let rec precomp_base_table_list_rec (#t:Type) (#a_t:BE.inttype_a) (#len:size_t{v len > 0}) (#ctx_len:size_t) (k:mk_precomp_base_table t a_t len ctx_len) (g:t) (n:nat) (acc:g_i_acc_t t a_t len ctx_len 0) : Tot (g_i_acc_t t a_t len ctx_len n) (decreases n) = if n = 0 then acc else precomp_base_table_f k g (n - 1) (precomp_base_table_list_rec k g (n - 1) acc) let precomp_base_table_list (#t:Type) (#a_t:BE.inttype_a) (#len:size_t{v len > 0}) (#ctx_len:size_t) (k:mk_precomp_base_table t a_t len ctx_len) (g:t) (n:nat) : x:list (uint_t a_t SEC){FL.length x = (n + 1) * v len} = snd (precomp_base_table_list_rec k g n (g, k.to_list (k.concr_ops.SE.one ()))) let precomp_base_table_lseq (#t:Type) (#a_t:BE.inttype_a) (#len:size_t{v len > 0}) (#ctx_len:size_t) (k:mk_precomp_base_table t a_t len ctx_len) (g:t) (n:nat{(n + 1) * v len <= max_size_t}) : LSeq.lseq (uint_t a_t SEC) ((n + 1) * v len) = Seq.seq_of_list (precomp_base_table_list k g n) //-------------------------------------------- val seq_of_list_append_lemma: #a:Type -> x:list a -> y:list a -> Lemma (let xy_lseq = Seq.seq_of_list FL.(x @ y) in Seq.slice xy_lseq 0 (FL.length x) == Seq.seq_of_list x /\ Seq.slice xy_lseq (FL.length x) (FL.length x + FL.length y) == Seq.seq_of_list y) //-------------------------------------------- let pow_base (#t:Type) (#a_t:BE.inttype_a) (#len:size_t{v len > 0}) (#ctx_len:size_t)
false
false
Hacl.Spec.PrecompBaseTable.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val pow_base (#t: Type) (#a_t: BE.inttype_a) (#len: size_t{v len > 0}) (#ctx_len: size_t) (k: mk_precomp_base_table t a_t len ctx_len) (g: t) (i: nat) : k.concr_ops.SE.to.a_spec
[]
Hacl.Spec.PrecompBaseTable.pow_base
{ "file_name": "code/bignum/Hacl.Spec.PrecompBaseTable.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Spec.PrecompBaseTable.mk_precomp_base_table t a_t len ctx_len -> g: t -> i: Prims.nat -> Mkto_comm_monoid?.a_spec (Mkconcrete_ops?.to (Mkmk_precomp_base_table?.concr_ops k))
{ "end_col": 67, "end_line": 69, "start_col": 2, "start_line": 69 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FL" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let g_i_acc_t (t:Type) (a_t:BE.inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (i:nat) = t & acc:list (uint_t a_t SEC){FL.length acc == (i + 1) * v len}
let g_i_acc_t (t: Type) (a_t: BE.inttype_a) (len: size_t{v len > 0}) (ctx_len: size_t) (i: nat) =
false
null
false
t & acc: list (uint_t a_t SEC) {FL.length acc == (i + 1) * v len}
{ "checked_file": "Hacl.Spec.PrecompBaseTable.fsti.checked", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "Hacl.Impl.Exponentiation.Definitions.fst.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.PrecompBaseTable.fsti" }
[ "total" ]
[ "Hacl.Impl.Exponentiation.Definitions.inttype_a", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.nat", "FStar.Pervasives.Native.tuple2", "Prims.list", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "FStar.Mul.op_Star", "Prims.op_Addition" ]
[]
module Hacl.Spec.PrecompBaseTable open FStar.Mul open Lib.IntTypes module FL = FStar.List.Tot module LSeq = Lib.Sequence module LE = Lib.Exponentiation.Definition module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation.Definitions #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract class mk_precomp_base_table (t:Type) (a_t:BE.inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) = { concr_ops: SE.concrete_ops t; to_cm: x:BE.to_comm_monoid a_t len ctx_len{x.BE.a_spec == concr_ops.SE.to.SE.a_spec}; to_list: t -> x:list (uint_t a_t SEC){FL.length x = v len /\ to_cm.BE.linv (Seq.seq_of_list x)}; lemma_refl: x:t -> Lemma (concr_ops.SE.to.SE.refl x == to_cm.BE.refl (Seq.seq_of_list (to_list x))); } inline_for_extraction noextract
false
false
Hacl.Spec.PrecompBaseTable.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val g_i_acc_t : t: Type -> a_t: Hacl.Impl.Exponentiation.Definitions.inttype_a -> len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} -> ctx_len: Lib.IntTypes.size_t -> i: Prims.nat -> Type
[]
Hacl.Spec.PrecompBaseTable.g_i_acc_t
{ "file_name": "code/bignum/Hacl.Spec.PrecompBaseTable.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Type -> a_t: Hacl.Impl.Exponentiation.Definitions.inttype_a -> len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} -> ctx_len: Lib.IntTypes.size_t -> i: Prims.nat -> Type
{ "end_col": 65, "end_line": 27, "start_col": 2, "start_line": 27 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FL" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let precomp_base_table_f (#t:Type) (#a_t:BE.inttype_a) (#len:size_t{v len > 0}) (#ctx_len:size_t) (k:mk_precomp_base_table t a_t len ctx_len) (g:t) (i:nat) ((g_i,acc): g_i_acc_t t a_t len ctx_len i) : g_i_acc_t t a_t len ctx_len (i + 1) = let acc = FL.(acc @ k.to_list g_i) in let g_i = k.concr_ops.SE.mul g_i g in g_i, acc
let precomp_base_table_f (#t: Type) (#a_t: BE.inttype_a) (#len: size_t{v len > 0}) (#ctx_len: size_t) (k: mk_precomp_base_table t a_t len ctx_len) (g: t) (i: nat) (g_i, acc: g_i_acc_t t a_t len ctx_len i) : g_i_acc_t t a_t len ctx_len (i + 1) =
false
null
false
let acc = let open FL in acc @ k.to_list g_i in let g_i = k.concr_ops.SE.mul g_i g in g_i, acc
{ "checked_file": "Hacl.Spec.PrecompBaseTable.fsti.checked", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "Hacl.Impl.Exponentiation.Definitions.fst.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.PrecompBaseTable.fsti" }
[ "total" ]
[ "Hacl.Impl.Exponentiation.Definitions.inttype_a", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Spec.PrecompBaseTable.mk_precomp_base_table", "Prims.nat", "Hacl.Spec.PrecompBaseTable.g_i_acc_t", "Prims.list", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "FStar.Mul.op_Star", "Prims.op_Addition", "FStar.Pervasives.Native.Mktuple2", "Spec.Exponentiation.__proj__Mkconcrete_ops__item__mul", "Hacl.Spec.PrecompBaseTable.__proj__Mkmk_precomp_base_table__item__concr_ops", "Lib.IntTypes.int_t", "FStar.List.Tot.Base.op_At", "Hacl.Spec.PrecompBaseTable.__proj__Mkmk_precomp_base_table__item__to_list" ]
[]
module Hacl.Spec.PrecompBaseTable open FStar.Mul open Lib.IntTypes module FL = FStar.List.Tot module LSeq = Lib.Sequence module LE = Lib.Exponentiation.Definition module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation.Definitions #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract class mk_precomp_base_table (t:Type) (a_t:BE.inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) = { concr_ops: SE.concrete_ops t; to_cm: x:BE.to_comm_monoid a_t len ctx_len{x.BE.a_spec == concr_ops.SE.to.SE.a_spec}; to_list: t -> x:list (uint_t a_t SEC){FL.length x = v len /\ to_cm.BE.linv (Seq.seq_of_list x)}; lemma_refl: x:t -> Lemma (concr_ops.SE.to.SE.refl x == to_cm.BE.refl (Seq.seq_of_list (to_list x))); } inline_for_extraction noextract let g_i_acc_t (t:Type) (a_t:BE.inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (i:nat) = t & acc:list (uint_t a_t SEC){FL.length acc == (i + 1) * v len} inline_for_extraction noextract let precomp_base_table_f (#t:Type) (#a_t:BE.inttype_a) (#len:size_t{v len > 0}) (#ctx_len:size_t)
false
false
Hacl.Spec.PrecompBaseTable.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val precomp_base_table_f : k: Hacl.Spec.PrecompBaseTable.mk_precomp_base_table t a_t len ctx_len -> g: t -> i: Prims.nat -> _: Hacl.Spec.PrecompBaseTable.g_i_acc_t t a_t len ctx_len i -> Hacl.Spec.PrecompBaseTable.g_i_acc_t t a_t len ctx_len (i + 1)
[]
Hacl.Spec.PrecompBaseTable.precomp_base_table_f
{ "file_name": "code/bignum/Hacl.Spec.PrecompBaseTable.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Spec.PrecompBaseTable.mk_precomp_base_table t a_t len ctx_len -> g: t -> i: Prims.nat -> _: Hacl.Spec.PrecompBaseTable.g_i_acc_t t a_t len ctx_len i -> Hacl.Spec.PrecompBaseTable.g_i_acc_t t a_t len ctx_len (i + 1)
{ "end_col": 10, "end_line": 35, "start_col": 92, "start_line": 32 }
Prims.Tot
val precomp_base_table_list_rec (#t: Type) (#a_t: BE.inttype_a) (#len: size_t{v len > 0}) (#ctx_len: size_t) (k: mk_precomp_base_table t a_t len ctx_len) (g: t) (n: nat) (acc: g_i_acc_t t a_t len ctx_len 0) : Tot (g_i_acc_t t a_t len ctx_len n) (decreases n)
[ { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FL" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec precomp_base_table_list_rec (#t:Type) (#a_t:BE.inttype_a) (#len:size_t{v len > 0}) (#ctx_len:size_t) (k:mk_precomp_base_table t a_t len ctx_len) (g:t) (n:nat) (acc:g_i_acc_t t a_t len ctx_len 0) : Tot (g_i_acc_t t a_t len ctx_len n) (decreases n) = if n = 0 then acc else precomp_base_table_f k g (n - 1) (precomp_base_table_list_rec k g (n - 1) acc)
val precomp_base_table_list_rec (#t: Type) (#a_t: BE.inttype_a) (#len: size_t{v len > 0}) (#ctx_len: size_t) (k: mk_precomp_base_table t a_t len ctx_len) (g: t) (n: nat) (acc: g_i_acc_t t a_t len ctx_len 0) : Tot (g_i_acc_t t a_t len ctx_len n) (decreases n) let rec precomp_base_table_list_rec (#t: Type) (#a_t: BE.inttype_a) (#len: size_t{v len > 0}) (#ctx_len: size_t) (k: mk_precomp_base_table t a_t len ctx_len) (g: t) (n: nat) (acc: g_i_acc_t t a_t len ctx_len 0) : Tot (g_i_acc_t t a_t len ctx_len n) (decreases n) =
false
null
false
if n = 0 then acc else precomp_base_table_f k g (n - 1) (precomp_base_table_list_rec k g (n - 1) acc)
{ "checked_file": "Hacl.Spec.PrecompBaseTable.fsti.checked", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "Hacl.Impl.Exponentiation.Definitions.fst.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.PrecompBaseTable.fsti" }
[ "total", "" ]
[ "Hacl.Impl.Exponentiation.Definitions.inttype_a", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Spec.PrecompBaseTable.mk_precomp_base_table", "Prims.nat", "Hacl.Spec.PrecompBaseTable.g_i_acc_t", "Prims.op_Equality", "Prims.int", "Prims.bool", "Hacl.Spec.PrecompBaseTable.precomp_base_table_f", "Prims.op_Subtraction", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list_rec" ]
[]
module Hacl.Spec.PrecompBaseTable open FStar.Mul open Lib.IntTypes module FL = FStar.List.Tot module LSeq = Lib.Sequence module LE = Lib.Exponentiation.Definition module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation.Definitions #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract class mk_precomp_base_table (t:Type) (a_t:BE.inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) = { concr_ops: SE.concrete_ops t; to_cm: x:BE.to_comm_monoid a_t len ctx_len{x.BE.a_spec == concr_ops.SE.to.SE.a_spec}; to_list: t -> x:list (uint_t a_t SEC){FL.length x = v len /\ to_cm.BE.linv (Seq.seq_of_list x)}; lemma_refl: x:t -> Lemma (concr_ops.SE.to.SE.refl x == to_cm.BE.refl (Seq.seq_of_list (to_list x))); } inline_for_extraction noextract let g_i_acc_t (t:Type) (a_t:BE.inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (i:nat) = t & acc:list (uint_t a_t SEC){FL.length acc == (i + 1) * v len} inline_for_extraction noextract let precomp_base_table_f (#t:Type) (#a_t:BE.inttype_a) (#len:size_t{v len > 0}) (#ctx_len:size_t) (k:mk_precomp_base_table t a_t len ctx_len) (g:t) (i:nat) ((g_i,acc): g_i_acc_t t a_t len ctx_len i) : g_i_acc_t t a_t len ctx_len (i + 1) = let acc = FL.(acc @ k.to_list g_i) in let g_i = k.concr_ops.SE.mul g_i g in g_i, acc let rec precomp_base_table_list_rec (#t:Type) (#a_t:BE.inttype_a) (#len:size_t{v len > 0}) (#ctx_len:size_t) (k:mk_precomp_base_table t a_t len ctx_len) (g:t) (n:nat) (acc:g_i_acc_t t a_t len ctx_len 0) : Tot (g_i_acc_t t a_t len ctx_len n) (decreases n) =
false
false
Hacl.Spec.PrecompBaseTable.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val precomp_base_table_list_rec (#t: Type) (#a_t: BE.inttype_a) (#len: size_t{v len > 0}) (#ctx_len: size_t) (k: mk_precomp_base_table t a_t len ctx_len) (g: t) (n: nat) (acc: g_i_acc_t t a_t len ctx_len 0) : Tot (g_i_acc_t t a_t len ctx_len n) (decreases n)
[ "recursion" ]
Hacl.Spec.PrecompBaseTable.precomp_base_table_list_rec
{ "file_name": "code/bignum/Hacl.Spec.PrecompBaseTable.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Spec.PrecompBaseTable.mk_precomp_base_table t a_t len ctx_len -> g: t -> n: Prims.nat -> acc: Hacl.Spec.PrecompBaseTable.g_i_acc_t t a_t len ctx_len 0 -> Prims.Tot (Hacl.Spec.PrecompBaseTable.g_i_acc_t t a_t len ctx_len n)
{ "end_col": 85, "end_line": 44, "start_col": 2, "start_line": 43 }
Prims.Tot
val precomp_base_table_lseq (#t: Type) (#a_t: BE.inttype_a) (#len: size_t{v len > 0}) (#ctx_len: size_t) (k: mk_precomp_base_table t a_t len ctx_len) (g: t) (n: nat{(n + 1) * v len <= max_size_t}) : LSeq.lseq (uint_t a_t SEC) ((n + 1) * v len)
[ { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FL" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let precomp_base_table_lseq (#t:Type) (#a_t:BE.inttype_a) (#len:size_t{v len > 0}) (#ctx_len:size_t) (k:mk_precomp_base_table t a_t len ctx_len) (g:t) (n:nat{(n + 1) * v len <= max_size_t}) : LSeq.lseq (uint_t a_t SEC) ((n + 1) * v len) = Seq.seq_of_list (precomp_base_table_list k g n)
val precomp_base_table_lseq (#t: Type) (#a_t: BE.inttype_a) (#len: size_t{v len > 0}) (#ctx_len: size_t) (k: mk_precomp_base_table t a_t len ctx_len) (g: t) (n: nat{(n + 1) * v len <= max_size_t}) : LSeq.lseq (uint_t a_t SEC) ((n + 1) * v len) let precomp_base_table_lseq (#t: Type) (#a_t: BE.inttype_a) (#len: size_t{v len > 0}) (#ctx_len: size_t) (k: mk_precomp_base_table t a_t len ctx_len) (g: t) (n: nat{(n + 1) * v len <= max_size_t}) : LSeq.lseq (uint_t a_t SEC) ((n + 1) * v len) =
false
null
false
Seq.seq_of_list (precomp_base_table_list k g n)
{ "checked_file": "Hacl.Spec.PrecompBaseTable.fsti.checked", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "Hacl.Impl.Exponentiation.Definitions.fst.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.PrecompBaseTable.fsti" }
[ "total" ]
[ "Hacl.Impl.Exponentiation.Definitions.inttype_a", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Spec.PrecompBaseTable.mk_precomp_base_table", "Prims.nat", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Prims.op_Addition", "Lib.IntTypes.max_size_t", "FStar.Seq.Properties.seq_of_list", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list", "Lib.Sequence.lseq" ]
[]
module Hacl.Spec.PrecompBaseTable open FStar.Mul open Lib.IntTypes module FL = FStar.List.Tot module LSeq = Lib.Sequence module LE = Lib.Exponentiation.Definition module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation.Definitions #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract class mk_precomp_base_table (t:Type) (a_t:BE.inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) = { concr_ops: SE.concrete_ops t; to_cm: x:BE.to_comm_monoid a_t len ctx_len{x.BE.a_spec == concr_ops.SE.to.SE.a_spec}; to_list: t -> x:list (uint_t a_t SEC){FL.length x = v len /\ to_cm.BE.linv (Seq.seq_of_list x)}; lemma_refl: x:t -> Lemma (concr_ops.SE.to.SE.refl x == to_cm.BE.refl (Seq.seq_of_list (to_list x))); } inline_for_extraction noextract let g_i_acc_t (t:Type) (a_t:BE.inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (i:nat) = t & acc:list (uint_t a_t SEC){FL.length acc == (i + 1) * v len} inline_for_extraction noextract let precomp_base_table_f (#t:Type) (#a_t:BE.inttype_a) (#len:size_t{v len > 0}) (#ctx_len:size_t) (k:mk_precomp_base_table t a_t len ctx_len) (g:t) (i:nat) ((g_i,acc): g_i_acc_t t a_t len ctx_len i) : g_i_acc_t t a_t len ctx_len (i + 1) = let acc = FL.(acc @ k.to_list g_i) in let g_i = k.concr_ops.SE.mul g_i g in g_i, acc let rec precomp_base_table_list_rec (#t:Type) (#a_t:BE.inttype_a) (#len:size_t{v len > 0}) (#ctx_len:size_t) (k:mk_precomp_base_table t a_t len ctx_len) (g:t) (n:nat) (acc:g_i_acc_t t a_t len ctx_len 0) : Tot (g_i_acc_t t a_t len ctx_len n) (decreases n) = if n = 0 then acc else precomp_base_table_f k g (n - 1) (precomp_base_table_list_rec k g (n - 1) acc) let precomp_base_table_list (#t:Type) (#a_t:BE.inttype_a) (#len:size_t{v len > 0}) (#ctx_len:size_t) (k:mk_precomp_base_table t a_t len ctx_len) (g:t) (n:nat) : x:list (uint_t a_t SEC){FL.length x = (n + 1) * v len} = snd (precomp_base_table_list_rec k g n (g, k.to_list (k.concr_ops.SE.one ()))) let precomp_base_table_lseq (#t:Type) (#a_t:BE.inttype_a) (#len:size_t{v len > 0}) (#ctx_len:size_t) (k:mk_precomp_base_table t a_t len ctx_len) (g:t)
false
false
Hacl.Spec.PrecompBaseTable.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val precomp_base_table_lseq (#t: Type) (#a_t: BE.inttype_a) (#len: size_t{v len > 0}) (#ctx_len: size_t) (k: mk_precomp_base_table t a_t len ctx_len) (g: t) (n: nat{(n + 1) * v len <= max_size_t}) : LSeq.lseq (uint_t a_t SEC) ((n + 1) * v len)
[]
Hacl.Spec.PrecompBaseTable.precomp_base_table_lseq
{ "file_name": "code/bignum/Hacl.Spec.PrecompBaseTable.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Spec.PrecompBaseTable.mk_precomp_base_table t a_t len ctx_len -> g: t -> n: Prims.nat{(n + 1) * Lib.IntTypes.v len <= Lib.IntTypes.max_size_t} -> Lib.Sequence.lseq (Lib.IntTypes.uint_t a_t Lib.IntTypes.SEC) ((n + 1) * Lib.IntTypes.v len)
{ "end_col": 49, "end_line": 56, "start_col": 2, "start_line": 56 }
Prims.Tot
val precomp_base_table_list (#t: Type) (#a_t: BE.inttype_a) (#len: size_t{v len > 0}) (#ctx_len: size_t) (k: mk_precomp_base_table t a_t len ctx_len) (g: t) (n: nat) : x: list (uint_t a_t SEC) {FL.length x = (n + 1) * v len}
[ { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FL" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let precomp_base_table_list (#t:Type) (#a_t:BE.inttype_a) (#len:size_t{v len > 0}) (#ctx_len:size_t) (k:mk_precomp_base_table t a_t len ctx_len) (g:t) (n:nat) : x:list (uint_t a_t SEC){FL.length x = (n + 1) * v len} = snd (precomp_base_table_list_rec k g n (g, k.to_list (k.concr_ops.SE.one ())))
val precomp_base_table_list (#t: Type) (#a_t: BE.inttype_a) (#len: size_t{v len > 0}) (#ctx_len: size_t) (k: mk_precomp_base_table t a_t len ctx_len) (g: t) (n: nat) : x: list (uint_t a_t SEC) {FL.length x = (n + 1) * v len} let precomp_base_table_list (#t: Type) (#a_t: BE.inttype_a) (#len: size_t{v len > 0}) (#ctx_len: size_t) (k: mk_precomp_base_table t a_t len ctx_len) (g: t) (n: nat) : x: list (uint_t a_t SEC) {FL.length x = (n + 1) * v len} =
false
null
false
snd (precomp_base_table_list_rec k g n (g, k.to_list (k.concr_ops.SE.one ())))
{ "checked_file": "Hacl.Spec.PrecompBaseTable.fsti.checked", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "Hacl.Impl.Exponentiation.Definitions.fst.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.PrecompBaseTable.fsti" }
[ "total" ]
[ "Hacl.Impl.Exponentiation.Definitions.inttype_a", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Spec.PrecompBaseTable.mk_precomp_base_table", "Prims.nat", "FStar.Pervasives.Native.snd", "Prims.list", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "FStar.Mul.op_Star", "Prims.op_Addition", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list_rec", "FStar.Pervasives.Native.Mktuple2", "Hacl.Spec.PrecompBaseTable.__proj__Mkmk_precomp_base_table__item__to_list", "Spec.Exponentiation.__proj__Mkconcrete_ops__item__one", "Hacl.Spec.PrecompBaseTable.__proj__Mkmk_precomp_base_table__item__concr_ops", "Prims.op_Equality" ]
[]
module Hacl.Spec.PrecompBaseTable open FStar.Mul open Lib.IntTypes module FL = FStar.List.Tot module LSeq = Lib.Sequence module LE = Lib.Exponentiation.Definition module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation.Definitions #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract class mk_precomp_base_table (t:Type) (a_t:BE.inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) = { concr_ops: SE.concrete_ops t; to_cm: x:BE.to_comm_monoid a_t len ctx_len{x.BE.a_spec == concr_ops.SE.to.SE.a_spec}; to_list: t -> x:list (uint_t a_t SEC){FL.length x = v len /\ to_cm.BE.linv (Seq.seq_of_list x)}; lemma_refl: x:t -> Lemma (concr_ops.SE.to.SE.refl x == to_cm.BE.refl (Seq.seq_of_list (to_list x))); } inline_for_extraction noextract let g_i_acc_t (t:Type) (a_t:BE.inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (i:nat) = t & acc:list (uint_t a_t SEC){FL.length acc == (i + 1) * v len} inline_for_extraction noextract let precomp_base_table_f (#t:Type) (#a_t:BE.inttype_a) (#len:size_t{v len > 0}) (#ctx_len:size_t) (k:mk_precomp_base_table t a_t len ctx_len) (g:t) (i:nat) ((g_i,acc): g_i_acc_t t a_t len ctx_len i) : g_i_acc_t t a_t len ctx_len (i + 1) = let acc = FL.(acc @ k.to_list g_i) in let g_i = k.concr_ops.SE.mul g_i g in g_i, acc let rec precomp_base_table_list_rec (#t:Type) (#a_t:BE.inttype_a) (#len:size_t{v len > 0}) (#ctx_len:size_t) (k:mk_precomp_base_table t a_t len ctx_len) (g:t) (n:nat) (acc:g_i_acc_t t a_t len ctx_len 0) : Tot (g_i_acc_t t a_t len ctx_len n) (decreases n) = if n = 0 then acc else precomp_base_table_f k g (n - 1) (precomp_base_table_list_rec k g (n - 1) acc) let precomp_base_table_list (#t:Type) (#a_t:BE.inttype_a) (#len:size_t{v len > 0}) (#ctx_len:size_t) (k:mk_precomp_base_table t a_t len ctx_len) (g:t) (n:nat) :
false
false
Hacl.Spec.PrecompBaseTable.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val precomp_base_table_list (#t: Type) (#a_t: BE.inttype_a) (#len: size_t{v len > 0}) (#ctx_len: size_t) (k: mk_precomp_base_table t a_t len ctx_len) (g: t) (n: nat) : x: list (uint_t a_t SEC) {FL.length x = (n + 1) * v len}
[]
Hacl.Spec.PrecompBaseTable.precomp_base_table_list
{ "file_name": "code/bignum/Hacl.Spec.PrecompBaseTable.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Spec.PrecompBaseTable.mk_precomp_base_table t a_t len ctx_len -> g: t -> n: Prims.nat -> x: Prims.list (Lib.IntTypes.uint_t a_t Lib.IntTypes.SEC) {FStar.List.Tot.Base.length x = (n + 1) * Lib.IntTypes.v len}
{ "end_col": 80, "end_line": 50, "start_col": 2, "start_line": 50 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FL" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "FL" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let precomp_base_table_acc_inv (#t:Type) (#a_t:BE.inttype_a) (#len:size_t{v len > 0}) (#ctx_len:size_t) (k:mk_precomp_base_table t a_t len ctx_len) (g:t) (table_len:nat{table_len * v len <= max_size_t}) (table:LSeq.lseq (uint_t a_t SEC) (table_len * v len)) (j:nat{j < table_len}) = Math.Lemmas.lemma_mult_lt_right (v len) j table_len; Math.Lemmas.lemma_mult_le_right (v len) (j + 1) table_len; let bj = LSeq.sub table (j * v len) (v len) in k.to_cm.BE.linv bj /\ k.to_cm.BE.refl bj == pow_base k g j
let precomp_base_table_acc_inv (#t: Type) (#a_t: BE.inttype_a) (#len: size_t{v len > 0}) (#ctx_len: size_t) (k: mk_precomp_base_table t a_t len ctx_len) (g: t) (table_len: nat{table_len * v len <= max_size_t}) (table: LSeq.lseq (uint_t a_t SEC) (table_len * v len)) (j: nat{j < table_len}) =
false
null
false
Math.Lemmas.lemma_mult_lt_right (v len) j table_len; Math.Lemmas.lemma_mult_le_right (v len) (j + 1) table_len; let bj = LSeq.sub table (j * v len) (v len) in k.to_cm.BE.linv bj /\ k.to_cm.BE.refl bj == pow_base k g j
{ "checked_file": "Hacl.Spec.PrecompBaseTable.fsti.checked", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "Hacl.Impl.Exponentiation.Definitions.fst.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.PrecompBaseTable.fsti" }
[ "total" ]
[ "Hacl.Impl.Exponentiation.Definitions.inttype_a", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Spec.PrecompBaseTable.mk_precomp_base_table", "Prims.nat", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Lib.Sequence.lseq", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Prims.op_LessThan", "Prims.l_and", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__linv", "Hacl.Spec.PrecompBaseTable.__proj__Mkmk_precomp_base_table__item__to_cm", "Prims.eq2", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__a_spec", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__refl", "Hacl.Spec.PrecompBaseTable.pow_base", "Lib.IntTypes.int_t", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.slice", "Prims.op_Multiply", "Prims.op_Addition", "Prims.l_Forall", "Prims.l_or", "FStar.Seq.Base.index", "Lib.Sequence.index", "Lib.Sequence.sub", "Prims.unit", "FStar.Math.Lemmas.lemma_mult_le_right", "FStar.Math.Lemmas.lemma_mult_lt_right", "Prims.logical" ]
[]
module Hacl.Spec.PrecompBaseTable open FStar.Mul open Lib.IntTypes module FL = FStar.List.Tot module LSeq = Lib.Sequence module LE = Lib.Exponentiation.Definition module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation.Definitions #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract class mk_precomp_base_table (t:Type) (a_t:BE.inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) = { concr_ops: SE.concrete_ops t; to_cm: x:BE.to_comm_monoid a_t len ctx_len{x.BE.a_spec == concr_ops.SE.to.SE.a_spec}; to_list: t -> x:list (uint_t a_t SEC){FL.length x = v len /\ to_cm.BE.linv (Seq.seq_of_list x)}; lemma_refl: x:t -> Lemma (concr_ops.SE.to.SE.refl x == to_cm.BE.refl (Seq.seq_of_list (to_list x))); } inline_for_extraction noextract let g_i_acc_t (t:Type) (a_t:BE.inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (i:nat) = t & acc:list (uint_t a_t SEC){FL.length acc == (i + 1) * v len} inline_for_extraction noextract let precomp_base_table_f (#t:Type) (#a_t:BE.inttype_a) (#len:size_t{v len > 0}) (#ctx_len:size_t) (k:mk_precomp_base_table t a_t len ctx_len) (g:t) (i:nat) ((g_i,acc): g_i_acc_t t a_t len ctx_len i) : g_i_acc_t t a_t len ctx_len (i + 1) = let acc = FL.(acc @ k.to_list g_i) in let g_i = k.concr_ops.SE.mul g_i g in g_i, acc let rec precomp_base_table_list_rec (#t:Type) (#a_t:BE.inttype_a) (#len:size_t{v len > 0}) (#ctx_len:size_t) (k:mk_precomp_base_table t a_t len ctx_len) (g:t) (n:nat) (acc:g_i_acc_t t a_t len ctx_len 0) : Tot (g_i_acc_t t a_t len ctx_len n) (decreases n) = if n = 0 then acc else precomp_base_table_f k g (n - 1) (precomp_base_table_list_rec k g (n - 1) acc) let precomp_base_table_list (#t:Type) (#a_t:BE.inttype_a) (#len:size_t{v len > 0}) (#ctx_len:size_t) (k:mk_precomp_base_table t a_t len ctx_len) (g:t) (n:nat) : x:list (uint_t a_t SEC){FL.length x = (n + 1) * v len} = snd (precomp_base_table_list_rec k g n (g, k.to_list (k.concr_ops.SE.one ()))) let precomp_base_table_lseq (#t:Type) (#a_t:BE.inttype_a) (#len:size_t{v len > 0}) (#ctx_len:size_t) (k:mk_precomp_base_table t a_t len ctx_len) (g:t) (n:nat{(n + 1) * v len <= max_size_t}) : LSeq.lseq (uint_t a_t SEC) ((n + 1) * v len) = Seq.seq_of_list (precomp_base_table_list k g n) //-------------------------------------------- val seq_of_list_append_lemma: #a:Type -> x:list a -> y:list a -> Lemma (let xy_lseq = Seq.seq_of_list FL.(x @ y) in Seq.slice xy_lseq 0 (FL.length x) == Seq.seq_of_list x /\ Seq.slice xy_lseq (FL.length x) (FL.length x + FL.length y) == Seq.seq_of_list y) //-------------------------------------------- let pow_base (#t:Type) (#a_t:BE.inttype_a) (#len:size_t{v len > 0}) (#ctx_len:size_t) (k:mk_precomp_base_table t a_t len ctx_len) (g:t) (i:nat) : k.concr_ops.SE.to.a_spec = LE.pow k.concr_ops.SE.to.comm_monoid (k.concr_ops.SE.to.refl g) i unfold let precomp_base_table_acc_inv (#t:Type) (#a_t:BE.inttype_a) (#len:size_t{v len > 0}) (#ctx_len:size_t) (k:mk_precomp_base_table t a_t len ctx_len) (g:t) (table_len:nat{table_len * v len <= max_size_t}) (table:LSeq.lseq (uint_t a_t SEC) (table_len * v len)) (j:nat{j < table_len})
false
false
Hacl.Spec.PrecompBaseTable.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val precomp_base_table_acc_inv : k: Hacl.Spec.PrecompBaseTable.mk_precomp_base_table t a_t len ctx_len -> g: t -> table_len: Prims.nat{table_len * Lib.IntTypes.v len <= Lib.IntTypes.max_size_t} -> table: Lib.Sequence.lseq (Lib.IntTypes.uint_t a_t Lib.IntTypes.SEC) (table_len * Lib.IntTypes.v len) -> j: Prims.nat{j < table_len} -> Prims.logical
[]
Hacl.Spec.PrecompBaseTable.precomp_base_table_acc_inv
{ "file_name": "code/bignum/Hacl.Spec.PrecompBaseTable.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Spec.PrecompBaseTable.mk_precomp_base_table t a_t len ctx_len -> g: t -> table_len: Prims.nat{table_len * Lib.IntTypes.v len <= Lib.IntTypes.max_size_t} -> table: Lib.Sequence.lseq (Lib.IntTypes.uint_t a_t Lib.IntTypes.SEC) (table_len * Lib.IntTypes.v len) -> j: Prims.nat{j < table_len} -> Prims.logical
{ "end_col": 60, "end_line": 82, "start_col": 2, "start_line": 79 }
Prims.Tot
val vdep_hp (v: vprop) (p: ( (t_of v) -> Tot vprop)) : Tot (slprop u#1)
[ { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": true, "full_module": "FStar.Algebra.CommMonoid.Equiv", "short_module": "CE" }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommMonoidSimple.Equiv", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let vdep_hp v p = sdep (hp_of v) (vdep_hp_payload v p)
val vdep_hp (v: vprop) (p: ( (t_of v) -> Tot vprop)) : Tot (slprop u#1) let vdep_hp v p =
false
null
false
sdep (hp_of v) (vdep_hp_payload v p)
{ "checked_file": "Steel.Effect.Common.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "prims.fst.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.Common.fst" }
[ "total" ]
[ "Steel.Effect.Common.vprop", "Steel.Effect.Common.t_of", "Steel.Memory.sdep", "Steel.Effect.Common.hp_of", "Steel.Effect.Common.vdep_hp_payload", "Steel.Memory.slprop" ]
[]
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Effect.Common module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality let h_exists #a f = VUnit ({hp = Mem.h_exists (fun x -> hp_of (f x)); t = unit; sel = fun _ -> ()}) let can_be_split (p q:vprop) : prop = Mem.slimp (hp_of p) (hp_of q) let reveal_can_be_split () = () let can_be_split_interp r r' h = () let can_be_split_trans p q r = () let can_be_split_star_l p q = () let can_be_split_star_r p q = () let can_be_split_refl p = () let can_be_split_congr_l p q r = Classical.forall_intro (interp_star (hp_of p) (hp_of r)); Classical.forall_intro (interp_star (hp_of q) (hp_of r)) let can_be_split_congr_r p q r = Classical.forall_intro (interp_star (hp_of r) (hp_of p)); Classical.forall_intro (interp_star (hp_of r) (hp_of q)) let equiv (p q:vprop) : prop = Mem.equiv (hp_of p) (hp_of q) /\ True let reveal_equiv p q = () let valid_rmem (#frame:vprop) (h:rmem' frame) : prop = forall (p p1 p2:vprop). can_be_split frame p /\ p == VStar p1 p2 ==> (h p1, h p2) == h (VStar p1 p2) let lemma_valid_mk_rmem (r:vprop) (h:hmem r) = () let reveal_mk_rmem (r:vprop) (h:hmem r) (r0:vprop{r `can_be_split` r0}) : Lemma ((mk_rmem r h) r0 == sel_of r0 h) = FExt.feq_on_domain_g (unrestricted_mk_rmem r h) let emp':vprop' = { hp = emp; t = unit; sel = fun _ -> ()} let emp = VUnit emp' let reveal_emp () = () let lemma_valid_focus_rmem #r h r0 = Classical.forall_intro (Classical.move_requires (can_be_split_trans r r0)) let rec lemma_frame_refl' (frame:vprop) (h0:rmem frame) (h1:rmem frame) : Lemma ((h0 frame == h1 frame) <==> frame_equalities' frame h0 h1) = match frame with | VUnit _ -> () | VStar p1 p2 -> can_be_split_star_l p1 p2; can_be_split_star_r p1 p2; let h01 : rmem p1 = focus_rmem h0 p1 in let h11 : rmem p1 = focus_rmem h1 p1 in let h02 = focus_rmem h0 p2 in let h12 = focus_rmem h1 p2 in lemma_frame_refl' p1 h01 h11; lemma_frame_refl' p2 h02 h12 let lemma_frame_equalities frame h0 h1 p = let p1 : prop = h0 frame == h1 frame in let p2 : prop = frame_equalities' frame h0 h1 in lemma_frame_refl' frame h0 h1; FStar.PropositionalExtensionality.apply p1 p2 let lemma_frame_emp h0 h1 p = FStar.PropositionalExtensionality.apply True (h0 (VUnit emp') == h1 (VUnit emp')) let elim_conjunction p1 p1' p2 p2' = () let can_be_split_dep_refl p = () let equiv_can_be_split p1 p2 = () let intro_can_be_split_frame p q frame = () let can_be_split_post_elim t1 t2 = () let equiv_forall_refl t = () let equiv_forall_elim t1 t2 = () let equiv_refl x = () let equiv_sym x y = () let equiv_trans x y z = () let cm_identity x = Mem.emp_unit (hp_of x); Mem.star_commutative (hp_of x) Mem.emp let star_commutative p1 p2 = Mem.star_commutative (hp_of p1) (hp_of p2) let star_associative p1 p2 p3 = Mem.star_associative (hp_of p1) (hp_of p2) (hp_of p3) let star_congruence p1 p2 p3 p4 = Mem.star_congruence (hp_of p1) (hp_of p2) (hp_of p3) (hp_of p4) let vrefine_am (v: vprop) (p: (t_of v -> Tot prop)) : Tot (a_mem_prop (hp_of v)) = fun h -> p (sel_of v h) let vrefine_hp v p = refine_slprop (hp_of v) (vrefine_am v p) let interp_vrefine_hp v p m = () let vrefine_sel' (v: vprop) (p: (t_of v -> Tot prop)) : Tot (selector' (vrefine_t v p) (vrefine_hp v p)) = fun (h: Mem.hmem (vrefine_hp v p)) -> interp_refine_slprop (hp_of v) (vrefine_am v p) h; sel_of v h let vrefine_sel v p = assert (sel_depends_only_on (vrefine_sel' v p)); assert (sel_depends_only_on_core (vrefine_sel' v p)); vrefine_sel' v p let vrefine_sel_eq v p m = () let vdep_hp_payload (v: vprop) (p: (t_of v -> Tot vprop)) (h: Mem.hmem (hp_of v)) : Tot slprop = hp_of (p (sel_of v h)) let vdep_hp v p
false
false
Steel.Effect.Common.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val vdep_hp (v: vprop) (p: ( (t_of v) -> Tot vprop)) : Tot (slprop u#1)
[]
Steel.Effect.Common.vdep_hp
{ "file_name": "lib/steel/Steel.Effect.Common.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
v: Steel.Effect.Common.vprop -> p: (_: Steel.Effect.Common.t_of v -> Steel.Effect.Common.vprop) -> Steel.Memory.slprop
{ "end_col": 38, "end_line": 151, "start_col": 2, "start_line": 151 }
Prims.Tot
val emp : vprop
[ { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let emp = VUnit emp'
val emp : vprop let emp =
false
null
false
VUnit emp'
{ "checked_file": "Steel.Effect.Common.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "prims.fst.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.Common.fst" }
[ "total" ]
[ "Steel.Effect.Common.VUnit", "Steel.Effect.Common.emp'" ]
[]
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Effect.Common module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality let h_exists #a f = VUnit ({hp = Mem.h_exists (fun x -> hp_of (f x)); t = unit; sel = fun _ -> ()}) let can_be_split (p q:vprop) : prop = Mem.slimp (hp_of p) (hp_of q) let reveal_can_be_split () = () let can_be_split_interp r r' h = () let can_be_split_trans p q r = () let can_be_split_star_l p q = () let can_be_split_star_r p q = () let can_be_split_refl p = () let can_be_split_congr_l p q r = Classical.forall_intro (interp_star (hp_of p) (hp_of r)); Classical.forall_intro (interp_star (hp_of q) (hp_of r)) let can_be_split_congr_r p q r = Classical.forall_intro (interp_star (hp_of r) (hp_of p)); Classical.forall_intro (interp_star (hp_of r) (hp_of q)) let equiv (p q:vprop) : prop = Mem.equiv (hp_of p) (hp_of q) /\ True let reveal_equiv p q = () let valid_rmem (#frame:vprop) (h:rmem' frame) : prop = forall (p p1 p2:vprop). can_be_split frame p /\ p == VStar p1 p2 ==> (h p1, h p2) == h (VStar p1 p2) let lemma_valid_mk_rmem (r:vprop) (h:hmem r) = () let reveal_mk_rmem (r:vprop) (h:hmem r) (r0:vprop{r `can_be_split` r0}) : Lemma ((mk_rmem r h) r0 == sel_of r0 h) = FExt.feq_on_domain_g (unrestricted_mk_rmem r h) let emp':vprop' = { hp = emp; t = unit;
false
true
Steel.Effect.Common.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val emp : vprop
[]
Steel.Effect.Common.emp
{ "file_name": "lib/steel/Steel.Effect.Common.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
Steel.Effect.Common.vprop
{ "end_col": 20, "end_line": 61, "start_col": 10, "start_line": 61 }
Prims.Tot
val equiv (p q:vprop) : prop
[ { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let equiv (p q:vprop) : prop = Mem.equiv (hp_of p) (hp_of q) /\ True
val equiv (p q:vprop) : prop let equiv (p q: vprop) : prop =
false
null
false
Mem.equiv (hp_of p) (hp_of q) /\ True
{ "checked_file": "Steel.Effect.Common.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "prims.fst.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.Common.fst" }
[ "total" ]
[ "Steel.Effect.Common.vprop", "Prims.l_and", "Steel.Memory.equiv", "Steel.Effect.Common.hp_of", "Prims.l_True", "Prims.prop" ]
[]
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Effect.Common module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality let h_exists #a f = VUnit ({hp = Mem.h_exists (fun x -> hp_of (f x)); t = unit; sel = fun _ -> ()}) let can_be_split (p q:vprop) : prop = Mem.slimp (hp_of p) (hp_of q) let reveal_can_be_split () = () let can_be_split_interp r r' h = () let can_be_split_trans p q r = () let can_be_split_star_l p q = () let can_be_split_star_r p q = () let can_be_split_refl p = () let can_be_split_congr_l p q r = Classical.forall_intro (interp_star (hp_of p) (hp_of r)); Classical.forall_intro (interp_star (hp_of q) (hp_of r)) let can_be_split_congr_r p q r = Classical.forall_intro (interp_star (hp_of r) (hp_of p)); Classical.forall_intro (interp_star (hp_of r) (hp_of q))
false
true
Steel.Effect.Common.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val equiv (p q:vprop) : prop
[]
Steel.Effect.Common.equiv
{ "file_name": "lib/steel/Steel.Effect.Common.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
p: Steel.Effect.Common.vprop -> q: Steel.Effect.Common.vprop -> Prims.prop
{ "end_col": 68, "end_line": 44, "start_col": 31, "start_line": 44 }
Prims.Tot
val can_be_split (p q:pre_t) : Type0
[ { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let can_be_split (p q:vprop) : prop = Mem.slimp (hp_of p) (hp_of q)
val can_be_split (p q:pre_t) : Type0 let can_be_split (p q: vprop) : prop =
false
null
false
Mem.slimp (hp_of p) (hp_of q)
{ "checked_file": "Steel.Effect.Common.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "prims.fst.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.Common.fst" }
[ "total" ]
[ "Steel.Effect.Common.vprop", "Steel.Memory.slimp", "Steel.Effect.Common.hp_of", "Prims.prop" ]
[]
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Effect.Common module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality let h_exists #a f = VUnit ({hp = Mem.h_exists (fun x -> hp_of (f x)); t = unit; sel = fun _ -> ()})
false
true
Steel.Effect.Common.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val can_be_split (p q:pre_t) : Type0
[]
Steel.Effect.Common.can_be_split
{ "file_name": "lib/steel/Steel.Effect.Common.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
p: Steel.Effect.Common.pre_t -> q: Steel.Effect.Common.pre_t -> Type0
{ "end_col": 67, "end_line": 25, "start_col": 38, "start_line": 25 }
Prims.Tot
val vrefine_sel (v: vprop) (p: (normal (t_of v) -> Tot prop)) : Tot (selector (vrefine_t v p) (vrefine_hp v p))
[ { "abbrev": false, "full_module": "Steel.Semantics.Instantiate", "short_module": null }, { "abbrev": true, "full_module": "Steel.Semantics.Hoare.MST", "short_module": "Sem" }, { "abbrev": true, "full_module": "FStar.Algebra.CommMonoid.Equiv", "short_module": "CE" }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommMonoidSimple.Equiv", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "FExt" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let vrefine_sel v p = assert (sel_depends_only_on (vrefine_sel' v p)); assert (sel_depends_only_on_core (vrefine_sel' v p)); vrefine_sel' v p
val vrefine_sel (v: vprop) (p: (normal (t_of v) -> Tot prop)) : Tot (selector (vrefine_t v p) (vrefine_hp v p)) let vrefine_sel v p =
false
null
false
assert (sel_depends_only_on (vrefine_sel' v p)); assert (sel_depends_only_on_core (vrefine_sel' v p)); vrefine_sel' v p
{ "checked_file": "Steel.Effect.Common.fst.checked", "dependencies": [ "Steel.Semantics.Instantiate.fsti.checked", "Steel.Semantics.Hoare.MST.fst.checked", "Steel.Memory.fsti.checked", "prims.fst.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.Effect.Common.fst" }
[ "total" ]
[ "Steel.Effect.Common.vprop", "Steel.Effect.Common.normal", "Steel.Effect.Common.t_of", "Prims.prop", "Steel.Effect.Common.vrefine_sel'", "Prims.unit", "Prims._assert", "Steel.Effect.Common.sel_depends_only_on_core", "Steel.Effect.Common.vrefine_t", "Steel.Effect.Common.vrefine_hp", "Steel.Effect.Common.sel_depends_only_on", "Steel.Effect.Common.selector" ]
[]
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Effect.Common module Sem = Steel.Semantics.Hoare.MST module Mem = Steel.Memory open Steel.Semantics.Instantiate module FExt = FStar.FunctionalExtensionality let h_exists #a f = VUnit ({hp = Mem.h_exists (fun x -> hp_of (f x)); t = unit; sel = fun _ -> ()}) let can_be_split (p q:vprop) : prop = Mem.slimp (hp_of p) (hp_of q) let reveal_can_be_split () = () let can_be_split_interp r r' h = () let can_be_split_trans p q r = () let can_be_split_star_l p q = () let can_be_split_star_r p q = () let can_be_split_refl p = () let can_be_split_congr_l p q r = Classical.forall_intro (interp_star (hp_of p) (hp_of r)); Classical.forall_intro (interp_star (hp_of q) (hp_of r)) let can_be_split_congr_r p q r = Classical.forall_intro (interp_star (hp_of r) (hp_of p)); Classical.forall_intro (interp_star (hp_of r) (hp_of q)) let equiv (p q:vprop) : prop = Mem.equiv (hp_of p) (hp_of q) /\ True let reveal_equiv p q = () let valid_rmem (#frame:vprop) (h:rmem' frame) : prop = forall (p p1 p2:vprop). can_be_split frame p /\ p == VStar p1 p2 ==> (h p1, h p2) == h (VStar p1 p2) let lemma_valid_mk_rmem (r:vprop) (h:hmem r) = () let reveal_mk_rmem (r:vprop) (h:hmem r) (r0:vprop{r `can_be_split` r0}) : Lemma ((mk_rmem r h) r0 == sel_of r0 h) = FExt.feq_on_domain_g (unrestricted_mk_rmem r h) let emp':vprop' = { hp = emp; t = unit; sel = fun _ -> ()} let emp = VUnit emp' let reveal_emp () = () let lemma_valid_focus_rmem #r h r0 = Classical.forall_intro (Classical.move_requires (can_be_split_trans r r0)) let rec lemma_frame_refl' (frame:vprop) (h0:rmem frame) (h1:rmem frame) : Lemma ((h0 frame == h1 frame) <==> frame_equalities' frame h0 h1) = match frame with | VUnit _ -> () | VStar p1 p2 -> can_be_split_star_l p1 p2; can_be_split_star_r p1 p2; let h01 : rmem p1 = focus_rmem h0 p1 in let h11 : rmem p1 = focus_rmem h1 p1 in let h02 = focus_rmem h0 p2 in let h12 = focus_rmem h1 p2 in lemma_frame_refl' p1 h01 h11; lemma_frame_refl' p2 h02 h12 let lemma_frame_equalities frame h0 h1 p = let p1 : prop = h0 frame == h1 frame in let p2 : prop = frame_equalities' frame h0 h1 in lemma_frame_refl' frame h0 h1; FStar.PropositionalExtensionality.apply p1 p2 let lemma_frame_emp h0 h1 p = FStar.PropositionalExtensionality.apply True (h0 (VUnit emp') == h1 (VUnit emp')) let elim_conjunction p1 p1' p2 p2' = () let can_be_split_dep_refl p = () let equiv_can_be_split p1 p2 = () let intro_can_be_split_frame p q frame = () let can_be_split_post_elim t1 t2 = () let equiv_forall_refl t = () let equiv_forall_elim t1 t2 = () let equiv_refl x = () let equiv_sym x y = () let equiv_trans x y z = () let cm_identity x = Mem.emp_unit (hp_of x); Mem.star_commutative (hp_of x) Mem.emp let star_commutative p1 p2 = Mem.star_commutative (hp_of p1) (hp_of p2) let star_associative p1 p2 p3 = Mem.star_associative (hp_of p1) (hp_of p2) (hp_of p3) let star_congruence p1 p2 p3 p4 = Mem.star_congruence (hp_of p1) (hp_of p2) (hp_of p3) (hp_of p4) let vrefine_am (v: vprop) (p: (t_of v -> Tot prop)) : Tot (a_mem_prop (hp_of v)) = fun h -> p (sel_of v h) let vrefine_hp v p = refine_slprop (hp_of v) (vrefine_am v p) let interp_vrefine_hp v p m = () let vrefine_sel' (v: vprop) (p: (t_of v -> Tot prop)) : Tot (selector' (vrefine_t v p) (vrefine_hp v p)) = fun (h: Mem.hmem (vrefine_hp v p)) -> interp_refine_slprop (hp_of v) (vrefine_am v p) h; sel_of v h let vrefine_sel
false
false
Steel.Effect.Common.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val vrefine_sel (v: vprop) (p: (normal (t_of v) -> Tot prop)) : Tot (selector (vrefine_t v p) (vrefine_hp v p))
[]
Steel.Effect.Common.vrefine_sel
{ "file_name": "lib/steel/Steel.Effect.Common.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
v: Steel.Effect.Common.vprop -> p: (_: Steel.Effect.Common.normal (Steel.Effect.Common.t_of v) -> Prims.prop) -> Steel.Effect.Common.selector (Steel.Effect.Common.vrefine_t v p) (Steel.Effect.Common.vrefine_hp v p)
{ "end_col": 18, "end_line": 135, "start_col": 2, "start_line": 133 }