file_name
stringlengths
5
52
name
stringlengths
4
95
original_source_type
stringlengths
0
23k
source_type
stringlengths
9
23k
source_definition
stringlengths
9
57.9k
source
dict
source_range
dict
file_context
stringlengths
0
721k
dependencies
dict
opens_and_abbrevs
listlengths
2
94
vconfig
dict
interleaved
bool
1 class
verbose_type
stringlengths
1
7.42k
effect
stringclasses
118 values
effect_flags
sequencelengths
0
2
mutual_with
sequencelengths
0
11
ideal_premises
sequencelengths
0
236
proof_features
sequencelengths
0
1
is_simple_lemma
bool
2 classes
is_div
bool
2 classes
is_proof
bool
2 classes
is_simply_typed
bool
2 classes
is_type
bool
2 classes
partial_definition
stringlengths
5
3.99k
completed_definiton
stringlengths
1
1.63M
isa_cross_project_example
bool
1 class
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.split
val split: Prims.unit -> Tac unit
val split: Prims.unit -> Tac unit
let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal"
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 43, "end_line": 68, "start_col": 0, "start_line": 66 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.unit", "FStar.Tactics.V1.Derived.try_with", "FStar.Tactics.V1.Derived.apply_lemma", "Prims.exn", "FStar.Tactics.V1.Derived.fail" ]
[]
false
true
false
false
false
let split () : Tac unit =
try apply_lemma (`split_lem) with | _ -> fail "Could not split goal"
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.l_intro
val l_intro : _: Prims.unit -> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.Types.binder
let l_intro () = forall_intro `or_else` implies_intro
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 53, "end_line": 89, "start_col": 0, "start_line": 89 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.Types.binder
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.unit", "FStar.Tactics.V1.Derived.or_else", "FStar.Stubs.Reflection.Types.binder", "FStar.Tactics.V1.Logic.forall_intro", "FStar.Tactics.V1.Logic.implies_intro" ]
[]
false
true
false
false
false
let l_intro () =
forall_intro `or_else` implies_intro
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.implies_intros
val implies_intros: Prims.unit -> Tac binders
val implies_intros: Prims.unit -> Tac binders
let implies_intros () : Tac binders = repeat1 implies_intro
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 59, "end_line": 86, "start_col": 0, "start_line": 86 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.Types.binders
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.unit", "FStar.Tactics.V1.Derived.repeat1", "FStar.Stubs.Reflection.Types.binder", "FStar.Tactics.V1.Logic.implies_intro", "Prims.list", "FStar.Stubs.Reflection.Types.binders" ]
[]
false
true
false
false
false
let implies_intros () : Tac binders =
repeat1 implies_intro
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.l_intros
val l_intros : _: Prims.unit -> FStar.Tactics.Effect.Tac (Prims.list FStar.Stubs.Reflection.Types.binder)
let l_intros () = repeat l_intro
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 32, "end_line": 92, "start_col": 0, "start_line": 92 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Tactics.Effect.Tac (Prims.list FStar.Stubs.Reflection.Types.binder)
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.unit", "FStar.Tactics.V1.Derived.repeat", "FStar.Stubs.Reflection.Types.binder", "FStar.Tactics.V1.Logic.l_intro", "Prims.list" ]
[]
false
true
false
false
false
let l_intros () =
repeat l_intro
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.squash_intro
val squash_intro: Prims.unit -> Tac unit
val squash_intro: Prims.unit -> Tac unit
let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash)
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 39, "end_line": 95, "start_col": 0, "start_line": 94 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.unit", "FStar.Tactics.V1.Derived.apply" ]
[]
false
true
false
false
false
let squash_intro () : Tac unit =
apply (`FStar.Squash.return_squash)
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.hyp
val hyp (b: binder) : Tac unit
val hyp (b: binder) : Tac unit
let hyp (b:binder) : Tac unit = l_exact (binder_to_term b)
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 58, "end_line": 101, "start_col": 0, "start_line": 101 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Stubs.Reflection.Types.binder -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.binder", "FStar.Tactics.V1.Logic.l_exact", "Prims.unit", "FStar.Stubs.Reflection.Types.term", "FStar.Tactics.V1.Derived.binder_to_term" ]
[]
false
true
false
false
false
let hyp (b: binder) : Tac unit =
l_exact (binder_to_term b)
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.l_exact
val l_exact : t: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.unit
let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t)
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 37, "end_line": 99, "start_col": 0, "start_line": 97 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Tactics.V1.Derived.try_with", "Prims.unit", "FStar.Tactics.V1.Derived.exact", "Prims.exn", "FStar.Tactics.V1.Logic.squash_intro" ]
[]
false
true
false
false
false
let l_exact (t: term) =
try exact t with | _ -> (squash_intro (); exact t)
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.rewrite_all_equalities
val rewrite_all_equalities: Prims.unit -> Tac unit
val rewrite_all_equalities: Prims.unit -> Tac unit
let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 33, "end_line": 166, "start_col": 0, "start_line": 165 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.unit", "FStar.Tactics.V1.Logic.visit", "FStar.Tactics.V1.Logic.simplify_eq_implication" ]
[]
false
true
false
false
false
let rewrite_all_equalities () : Tac unit =
visit simplify_eq_implication
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.unsquash
val unsquash (t: term) : Tac term
val unsquash (t: term) : Tac term
let unsquash (t:term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack_ln (Tv_Var (bv_of_binder b))
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 37, "end_line": 195, "start_col": 0, "start_line": 191 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.Types.term
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V1.Builtins.pack_ln", "FStar.Stubs.Reflection.V1.Data.Tv_Var", "FStar.Reflection.V1.Derived.bv_of_binder", "FStar.Stubs.Reflection.Types.binder", "FStar.Stubs.Tactics.V1.Builtins.intro", "Prims.unit", "FStar.Tactics.V1.Derived.apply_lemma", "FStar.Reflection.V1.Derived.mk_e_app", "Prims.Cons", "Prims.Nil" ]
[]
false
true
false
false
false
let unsquash (t: term) : Tac term =
let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack_ln (Tv_Var (bv_of_binder b))
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.explode
val explode: Prims.unit -> Tac unit
val explode: Prims.unit -> Tac unit
let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))]))
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 64, "end_line": 131, "start_col": 0, "start_line": 128 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.unit", "FStar.Pervasives.ignore", "FStar.Tactics.V1.Derived.repeatseq", "FStar.Tactics.V1.Derived.first", "Prims.Cons", "FStar.Stubs.Reflection.Types.binder", "FStar.Tactics.V1.Logic.l_intro", "FStar.Tactics.V1.Logic.split", "Prims.Nil" ]
[]
false
true
false
false
false
let explode () : Tac unit =
ignore (repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))]) )
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.visit
val visit (callback: (unit -> Tac unit)) : Tac unit
val visit (callback: (unit -> Tac unit)) : Tac unit
let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) )
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 11, "end_line": 150, "start_col": 0, "start_line": 133 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))]))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
callback: (_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit) -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.unit", "FStar.Tactics.V1.Derived.focus", "FStar.Tactics.V1.Derived.or_else", "FStar.Stubs.Reflection.Types.bv", "FStar.Stubs.Reflection.Types.typ", "FStar.Stubs.Reflection.Types.term", "FStar.Tactics.V1.Derived.seq", "FStar.Tactics.V1.Logic.visit", "FStar.Tactics.V1.Logic.l_revert_all", "FStar.Stubs.Reflection.Types.binders", "FStar.Tactics.V1.Logic.forall_intros", "FStar.Tactics.V1.Logic.split", "FStar.Tactics.V1.Logic.l_revert", "FStar.Stubs.Reflection.Types.binder", "FStar.Tactics.V1.Logic.implies_intro", "FStar.Reflection.V1.Formula.formula", "FStar.Reflection.V1.Formula.term_as_formula", "FStar.Tactics.V1.Derived.cur_goal" ]
[ "recursion" ]
false
true
false
false
false
let rec visit (callback: (unit -> Tac unit)) : Tac unit =
focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> ()))
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.l_revert_all
val l_revert_all (bs: binders) : Tac unit
val l_revert_all (bs: binders) : Tac unit
let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 53, "end_line": 42, "start_col": 0, "start_line": 39 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
bs: FStar.Stubs.Reflection.Types.binders -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.binders", "Prims.unit", "FStar.Stubs.Reflection.Types.binder", "Prims.list", "FStar.Tactics.V1.Logic.l_revert_all", "FStar.Tactics.V1.Logic.l_revert" ]
[ "recursion" ]
false
true
false
false
false
let rec l_revert_all (bs: binders) : Tac unit =
match bs with | [] -> () | _ :: tl -> l_revert (); l_revert_all tl
false
Spec.RSAPSS.fst
Spec.RSAPSS.os2ip_lemma
val os2ip_lemma: emBits:size_pos -> em:lbytes (blocks emBits 8) -> Lemma (requires (if emBits % 8 > 0 then v em.[0] < pow2 (emBits % 8) else v em.[0] < pow2 8)) (ensures os2ip #(blocks emBits 8) em < pow2 emBits)
val os2ip_lemma: emBits:size_pos -> em:lbytes (blocks emBits 8) -> Lemma (requires (if emBits % 8 > 0 then v em.[0] < pow2 (emBits % 8) else v em.[0] < pow2 8)) (ensures os2ip #(blocks emBits 8) em < pow2 emBits)
let os2ip_lemma emBits em = let emLen = blocks emBits 8 in let aux (emBits:size_pos{emBits % 8 > 0}) : Lemma (8 * ((emBits - 1) / 8) + emBits % 8 <= emBits) = assert ((emBits - 1) / 8 <= emBits / 8) in if emBits % 8 > 0 then begin nat_from_intseq_be_slice_lemma em 1; nat_from_intseq_be_lemma0 (slice em 0 1); assert (nat_from_bytes_be em == nat_from_bytes_be (slice em 1 emLen) + pow2 ((emLen - 1) * 8) * v em.[0]); assert (nat_from_bytes_be em < pow2 ((emLen - 1) * 8) + pow2 ((emLen - 1) * 8) * v em.[0]); calc (<=) { pow2 ((emLen - 1) * 8) + pow2 ((emLen - 1) * 8) * v em.[0]; (==) { Math.Lemmas.distributivity_add_right (pow2 (8 * (emLen - 1))) 1 (v em.[0]) } pow2 (8 * (emLen - 1)) * (1 + v em.[0]); (<=) { Math.Lemmas.lemma_mult_le_left (pow2 (8 * emLen - 1)) (v em.[0] + 1) (pow2 (emBits % 8)) } pow2 (8 * (emLen - 1)) * pow2 (emBits % 8); (==) { Math.Lemmas.pow2_plus (8 * (emLen - 1)) (emBits % 8) } pow2 (8 * ((emBits - 1) / 8) + emBits % 8); (<=) { aux emBits; Math.Lemmas.pow2_le_compat emBits ((emBits - 1) - (emBits - 1) % 8 + emBits % 8) } pow2 emBits; }; assert (nat_from_bytes_be em < pow2 emBits) end else begin assert (nat_from_bytes_be em < pow2 (emLen * 8)); assert (emBits == 8 * emLen) end
{ "file_name": "specs/Spec.RSAPSS.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 36, "end_line": 245, "start_col": 0, "start_line": 219 }
module Spec.RSAPSS open FStar.Mul open Lib.IntTypes open Lib.NatMod open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators module Hash = Spec.Agile.Hash #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" (** RFC spec of RSA-PSS: https://tools.ietf.org/html/rfc8017#section-8.1 List of supported hash functions: https://tools.ietf.org/html/rfc8446#appendix-B.3.1.3 Mask generation function: https://tools.ietf.org/html/rfc8017#page-67 *) /// /// Auxillary functions /// val blocks: x:size_pos -> m:size_pos -> Tot (r:size_pos{x <= m * r}) let blocks x m = (x - 1) / m + 1 val xor_bytes: #len:size_pos -> b1:lbytes len -> b2:lbytes len -> Tot (lbytes len) let xor_bytes #len b1 b2 = map2 (fun x y -> x ^. y) b1 b2 let hash_is_supported (a:Hash.hash_alg) : Tot bool = match a with | Hash.SHA2_256 -> true | Hash.SHA2_384 -> true | Hash.SHA2_512 -> true | _ -> false (* Mask Generation Function *) val mgf_hash_f: a:Hash.hash_alg{hash_is_supported a} -> len:size_nat{len + 4 <= max_size_t /\ (len + 4) `Hash.less_than_max_input_length` a} -> i:size_nat -> mgfseed_counter:lbytes (len + 4) -> lbytes (len + 4) & lbytes (Hash.hash_length a) let mgf_hash_f a len i mgfseed_counter = let counter = nat_to_intseq_be 4 i in let mgfseed_counter = update_sub mgfseed_counter len 4 counter in let block = Hash.hash a mgfseed_counter in mgfseed_counter, block let mgf_hash_a (len:size_nat{len + 4 <= max_size_t}) (n:pos) (i:nat{i <= n}) = lbytes (len + 4) val mgf_hash: a:Hash.hash_alg{hash_is_supported a} -> len:size_nat{len + 4 <= max_size_t /\ (len + 4) `Hash.less_than_max_input_length` a} -> mgfseed:lbytes len -> maskLen:size_pos{(blocks maskLen (Hash.hash_length a)) * Hash.hash_length a < pow2 32} -> Tot (lbytes maskLen) let mgf_hash a len mgfseed maskLen = let mgfseed_counter = create (len + 4) (u8 0) in let mgfseed_counter = update_sub mgfseed_counter 0 len mgfseed in let hLen = Hash.hash_length a in let n = blocks maskLen hLen in let _, acc = generate_blocks #uint8 hLen n n (mgf_hash_a len n) (mgf_hash_f a len) mgfseed_counter in sub #uint8 #(n * hLen) acc 0 maskLen (* Bignum convert functions *) val os2ip: #len:size_nat -> b:lbytes len -> Tot (res:nat{res < pow2 (8 * len)}) let os2ip #len b = nat_from_bytes_be b val i2osp: len:size_nat -> n:nat{n < pow2 (8 * len)} -> Tot (lbytes len) let i2osp len n = nat_to_intseq_be len n /// /// RSA /// type modBits_t = modBits:size_nat{1 < modBits} noeq type rsapss_pkey (modBits:modBits_t) = | Mk_rsapss_pkey: n:pos{pow2 (modBits - 1) < n /\ n < pow2 modBits} -> e:pos -> rsapss_pkey modBits noeq type rsapss_skey (modBits:modBits_t) = | Mk_rsapss_skey: pkey:rsapss_pkey modBits -> d:pos -> rsapss_skey modBits val db_zero: #len:size_pos -> db:lbytes len -> emBits:size_nat -> Pure (lbytes len) (requires True) (ensures fun res -> (v res.[0] == (if emBits % 8 > 0 then v db.[0] % pow2 (emBits % 8) else v db.[0]))) let db_zero #len db emBits = let msBits = emBits % 8 in if msBits > 0 then begin let r = db.[0] <- db.[0] &. (u8 0xff >>. size (8 - msBits)) in Math.Lemmas.pow2_plus msBits (8 - msBits); logand_mask db.[0] (u8 0xff >>. size (8 - msBits)) msBits; r end else db val pss_encode: a:Hash.hash_alg{hash_is_supported a} -> sLen:size_nat{sLen + Hash.hash_length a + 8 <= max_size_t /\ (sLen + Hash.hash_length a + 8) `Hash.less_than_max_input_length` a} -> salt:lbytes sLen -> msgLen:nat{msgLen `Hash.less_than_max_input_length` a} -> msg:bytes{length msg == msgLen} -> emBits:size_pos{Hash.hash_length a + sLen + 2 <= blocks emBits 8} -> Pure (lbytes (blocks emBits 8)) (requires True) (ensures fun em -> if emBits % 8 > 0 then v em.[0] < pow2 (emBits % 8) else v em.[0] < pow2 8) let pss_encode a sLen salt msgLen msg emBits = let mHash = Hash.hash a msg in let hLen = Hash.hash_length a in //m1 = [8 * 0x00; mHash; salt] let m1Len = 8 + hLen + sLen in let m1 = create m1Len (u8 0) in let m1 = update_sub m1 8 hLen mHash in let m1 = update_sub m1 (8 + hLen) sLen salt in let m1Hash = Hash.hash a m1 in //db = [0x00;..; 0x00; 0x01; salt] let emLen = blocks emBits 8 in let dbLen = emLen - hLen - 1 in let db = create dbLen (u8 0) in let last_before_salt = dbLen - sLen - 1 in let db = db.[last_before_salt] <- u8 1 in let db = update_sub db (last_before_salt + 1) sLen salt in let dbMask = mgf_hash a hLen m1Hash dbLen in let maskedDB = xor_bytes db dbMask in let maskedDB = db_zero maskedDB emBits in //em = [maskedDB; m1Hash; 0xbc] let em = create emLen (u8 0) in let em = update_sub em 0 dbLen maskedDB in let em = update_sub em dbLen hLen m1Hash in assert (v em.[0] == v maskedDB.[0]); em.[emLen - 1] <- u8 0xbc val pss_verify_: a:Hash.hash_alg{hash_is_supported a} -> sLen:size_nat{sLen + Hash.hash_length a + 8 <= max_size_t /\ (sLen + Hash.hash_length a + 8) `Hash.less_than_max_input_length` a} -> msgLen:nat{msgLen `Hash.less_than_max_input_length` a} -> msg:bytes{length msg == msgLen} -> emBits:size_pos{sLen + Hash.hash_length a + 2 <= blocks emBits 8} -> em:lbytes (blocks emBits 8) -> Tot bool let pss_verify_ a sLen msgLen msg emBits em = let hLen = Hash.hash_length a in let emLen = blocks emBits 8 in let dbLen = emLen - hLen - 1 in let maskedDB = sub em 0 dbLen in let m1Hash = sub em dbLen hLen in let dbMask = mgf_hash a hLen m1Hash dbLen in let db = xor_bytes dbMask maskedDB in let db = db_zero db emBits in let padLen = emLen - sLen - hLen - 1 in let pad2 = create padLen (u8 0) in let pad2 = pad2.[padLen - 1] <- u8 0x01 in let pad = sub db 0 padLen in let salt = sub db padLen sLen in if not (lbytes_eq pad pad2) then false else begin let mHash = Hash.hash a msg in let m1Len = 8 + hLen + sLen in let m1 = create m1Len (u8 0) in let m1 = update_sub m1 8 hLen mHash in let m1 = update_sub m1 (8 + hLen) sLen salt in let m1Hash0 = Hash.hash a m1 in lbytes_eq m1Hash0 m1Hash end val pss_verify: a:Hash.hash_alg{hash_is_supported a} -> sLen:size_nat{sLen + Hash.hash_length a + 8 <= max_size_t /\ (sLen + Hash.hash_length a + 8) `Hash.less_than_max_input_length` a} -> msgLen:nat{msgLen `Hash.less_than_max_input_length` a} -> msg:bytes{length msg == msgLen} -> emBits:size_pos -> em:lbytes (blocks emBits 8) -> Tot bool let pss_verify a sLen msgLen msg emBits em = let emLen = blocks emBits 8 in let msBits = emBits % 8 in let em_0 = if msBits > 0 then em.[0] &. (u8 0xff <<. size msBits) else u8 0 in let em_last = em.[emLen - 1] in if (emLen < sLen + Hash.hash_length a + 2) then false else begin if not (FStar.UInt8.(Lib.RawIntTypes.u8_to_UInt8 em_last =^ 0xbcuy) && FStar.UInt8.(Lib.RawIntTypes.u8_to_UInt8 em_0 =^ 0uy)) then false else pss_verify_ a sLen msgLen msg emBits em end val os2ip_lemma: emBits:size_pos -> em:lbytes (blocks emBits 8) -> Lemma (requires (if emBits % 8 > 0 then v em.[0] < pow2 (emBits % 8) else v em.[0] < pow2 8)) (ensures os2ip #(blocks emBits 8) em < pow2 emBits)
{ "checked_file": "/", "dependencies": [ "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Spec.RSAPSS.fst" }
[ { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
emBits: Lib.IntTypes.size_pos -> em: Lib.ByteSequence.lbytes (Spec.RSAPSS.blocks emBits 8) -> FStar.Pervasives.Lemma (requires ((match emBits % 8 > 0 with | true -> Lib.IntTypes.v em.[ 0 ] < Prims.pow2 (emBits % 8) | _ -> Lib.IntTypes.v em.[ 0 ] < Prims.pow2 8) <: Type0)) (ensures Spec.RSAPSS.os2ip em < Prims.pow2 emBits)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Lib.IntTypes.size_pos", "Lib.ByteSequence.lbytes", "Spec.RSAPSS.blocks", "Prims.op_GreaterThan", "Prims.op_Modulus", "Prims._assert", "Prims.b2t", "Prims.op_LessThan", "Lib.ByteSequence.nat_from_bytes_be", "Lib.IntTypes.SEC", "Prims.pow2", "Prims.unit", "FStar.Calc.calc_finish", "Prims.int", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.op_Subtraction", "Lib.IntTypes.v", "Lib.IntTypes.U8", "Lib.Sequence.op_String_Access", "Lib.IntTypes.uint_t", "Prims.Cons", "FStar.Preorder.relation", "Prims.eq2", "Prims.Nil", "FStar.Calc.calc_step", "Prims.op_Division", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "FStar.Math.Lemmas.distributivity_add_right", "Prims.squash", "FStar.Math.Lemmas.lemma_mult_le_left", "FStar.Math.Lemmas.pow2_plus", "FStar.Math.Lemmas.pow2_le_compat", "Lib.Sequence.slice", "Lib.ByteSequence.nat_from_intseq_be_lemma0", "Lib.ByteSequence.nat_from_intseq_be_slice_lemma", "Prims.bool", "Prims.pos", "Prims.l_True", "Prims.op_Multiply", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let os2ip_lemma emBits em =
let emLen = blocks emBits 8 in let aux (emBits: size_pos{emBits % 8 > 0}) : Lemma (8 * ((emBits - 1) / 8) + emBits % 8 <= emBits) = assert ((emBits - 1) / 8 <= emBits / 8) in if emBits % 8 > 0 then (nat_from_intseq_be_slice_lemma em 1; nat_from_intseq_be_lemma0 (slice em 0 1); assert (nat_from_bytes_be em == nat_from_bytes_be (slice em 1 emLen) + pow2 ((emLen - 1) * 8) * v em.[ 0 ]); assert (nat_from_bytes_be em < pow2 ((emLen - 1) * 8) + pow2 ((emLen - 1) * 8) * v em.[ 0 ]); calc ( <= ) { pow2 ((emLen - 1) * 8) + pow2 ((emLen - 1) * 8) * v em.[ 0 ]; ( == ) { Math.Lemmas.distributivity_add_right (pow2 (8 * (emLen - 1))) 1 (v em.[ 0 ]) } pow2 (8 * (emLen - 1)) * (1 + v em.[ 0 ]); ( <= ) { Math.Lemmas.lemma_mult_le_left (pow2 (8 * emLen - 1)) (v em.[ 0 ] + 1) (pow2 (emBits % 8)) } pow2 (8 * (emLen - 1)) * pow2 (emBits % 8); ( == ) { Math.Lemmas.pow2_plus (8 * (emLen - 1)) (emBits % 8) } pow2 (8 * ((emBits - 1) / 8) + emBits % 8); ( <= ) { (aux emBits; Math.Lemmas.pow2_le_compat emBits ((emBits - 1) - (emBits - 1) % 8 + emBits % 8)) } pow2 emBits; }; assert (nat_from_bytes_be em < pow2 emBits)) else (assert (nat_from_bytes_be em < pow2 (emLen * 8)); assert (emBits == 8 * emLen))
false
MiniParseExample2.fst
MiniParseExample2.c3
val c3:sum_case #somme #(bounded_u16 4) imp0 3us
val c3:sum_case #somme #(bounded_u16 4) imp0 3us
let c3 : sum_case #somme #(bounded_u16 4) imp0 3us = Case #(bounded_u16 4) #somme unit parse_empty serialize_empty (fun (_: unit) -> X <: refine_with_tag #(bounded_u16 4) #somme imp0 (3us <: bounded_u16 4)) (fun (_: refine_with_tag #(bounded_u16 4) #somme imp0 (3us <: bounded_u16 4)) -> ()) ()
{ "file_name": "examples/miniparse/MiniParseExample2.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 10, "end_line": 42, "start_col": 0, "start_line": 35 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module MiniParseExample2 open MiniParse.Spec.TSum module T = FStar.Tactics.V2 module U8 = FStar.UInt8 noeq type somme = | U of FStar.UInt8.t | V | W | X #set-options "--z3rlimit 16" let imp0 (x: somme) : Tot (bounded_u16 4) = match x with | U _ -> 0us <: bounded_u16 4 | V -> 1us <: bounded_u16 4 | W -> 2us <: bounded_u16 4 | _ -> 3us <: bounded_u16 4 #set-options "--print_universes --print_implicits"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MiniParse.Spec.TSum.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.V2.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "MiniParseExample2.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "MiniParse.Spec.TSum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
MiniParse.Spec.TSum.sum_case MiniParseExample2.imp0 (3us <: FStar.UInt16.t)
Prims.Tot
[ "total" ]
[]
[ "MiniParse.Spec.TSum.Case", "MiniParse.Spec.Int.bounded_u16", "MiniParseExample2.somme", "MiniParseExample2.imp0", "FStar.UInt16.__uint_to_t", "Prims.unit", "MiniParse.Spec.Combinators.parse_empty", "MiniParse.Spec.Combinators.serialize_empty", "MiniParseExample2.X", "MiniParse.Spec.TSum.refine_with_tag" ]
[]
false
false
false
false
false
let c3:sum_case #somme #(bounded_u16 4) imp0 3us =
Case #(bounded_u16 4) #somme unit parse_empty serialize_empty (fun (_: unit) -> X <: refine_with_tag #(bounded_u16 4) #somme imp0 (3us <: bounded_u16 4)) (fun (_: refine_with_tag #(bounded_u16 4) #somme imp0 (3us <: bounded_u16 4)) -> ()) ()
false
FStar.Buffer.Quantifiers.fst
FStar.Buffer.Quantifiers.lemma_blit_quantifiers
val lemma_blit_quantifiers: #a:Type -> h0:mem -> h1:mem -> b:buffer a -> bi:UInt32.t{v bi <= length b} -> b':buffer a{disjoint b b'} -> bi':UInt32.t{v bi' <= length b'} -> len:UInt32.t{v bi+v len <= length b /\ v bi'+v len <= length b'} -> Lemma (requires (live h0 b /\ live h0 b' /\ live h1 b' /\ Seq.slice (as_seq h1 b') (v bi') (v bi'+v len) == Seq.slice (as_seq h0 b) (v bi) (v bi+v len) /\ Seq.slice (as_seq h1 b') 0 (v bi') == Seq.slice (as_seq h0 b') 0 (v bi') /\ Seq.slice (as_seq h1 b') (v bi'+v len) (length b') == Seq.slice (as_seq h0 b') (v bi'+v len) (length b') )) (ensures (live h0 b /\ live h0 b' /\ live h1 b' /\ (forall (i:nat). {:pattern (get h1 b' (v bi'+i))} i < v len ==> get h1 b' (v bi'+i) == get h0 b (v bi+i)) /\ (forall (i:nat). {:pattern (get h1 b' i)} ((i >= v bi' + v len /\ i < length b') \/ i < v bi') ==> get h1 b' i == get h0 b' i) ))
val lemma_blit_quantifiers: #a:Type -> h0:mem -> h1:mem -> b:buffer a -> bi:UInt32.t{v bi <= length b} -> b':buffer a{disjoint b b'} -> bi':UInt32.t{v bi' <= length b'} -> len:UInt32.t{v bi+v len <= length b /\ v bi'+v len <= length b'} -> Lemma (requires (live h0 b /\ live h0 b' /\ live h1 b' /\ Seq.slice (as_seq h1 b') (v bi') (v bi'+v len) == Seq.slice (as_seq h0 b) (v bi) (v bi+v len) /\ Seq.slice (as_seq h1 b') 0 (v bi') == Seq.slice (as_seq h0 b') 0 (v bi') /\ Seq.slice (as_seq h1 b') (v bi'+v len) (length b') == Seq.slice (as_seq h0 b') (v bi'+v len) (length b') )) (ensures (live h0 b /\ live h0 b' /\ live h1 b' /\ (forall (i:nat). {:pattern (get h1 b' (v bi'+i))} i < v len ==> get h1 b' (v bi'+i) == get h0 b (v bi+i)) /\ (forall (i:nat). {:pattern (get h1 b' i)} ((i >= v bi' + v len /\ i < length b') \/ i < v bi') ==> get h1 b' i == get h0 b' i) ))
let lemma_blit_quantifiers #a h0 h1 b bi b' bi' len = let lemma_post_1 (j:nat) = j < v len ==> get h1 b' (v bi'+j) == get h0 b (v bi+j) in let qj_1 : j:nat -> Lemma (lemma_post_1 j) = fun j -> assert (j < v len ==> Seq.index (Seq.slice (as_seq h1 b') (v bi') (v bi'+v len)) j == Seq.index (Seq.slice (as_seq h0 b) (v bi) (v bi+v len)) j) in let lemma_post_2 (j:nat) = ((j >= v bi' + v len /\ j < length b') \/ j < v bi') ==> get h1 b' j == get h0 b' j in let qj_2 : j:nat -> Lemma (lemma_post_2 j) = fun j -> assert (j < v bi' ==> Seq.index (Seq.slice (as_seq h1 b') 0 (v bi')) j == Seq.index (Seq.slice (as_seq h0 b') 0 (v bi')) j); assert ((j >= v bi' + v len /\ j < length b') ==> Seq.index (Seq.slice (as_seq h1 b') (v bi'+v len) (length b')) (j - (v bi'+v len)) == Seq.index (Seq.slice (as_seq h0 b') (v bi'+v len) (length b')) (j - (v bi'+v len))) in Classical.forall_intro #_ #lemma_post_1 qj_1; Classical.forall_intro #_ #lemma_post_2 qj_2
{ "file_name": "ulib/legacy/FStar.Buffer.Quantifiers.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 46, "end_line": 105, "start_col": 0, "start_line": 90 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer.Quantifiers open FStar.Seq open FStar.UInt32 open FStar.HyperStack open FStar.Ghost open FStar.Buffer open FStar.Classical #set-options "--initial_fuel 0 --max_fuel 0" val lemma_sub_quantifiers: #a:Type -> h:mem -> b:buffer a -> b':buffer a -> i:FStar.UInt32.t -> len:FStar.UInt32.t{v len <= length b /\ v i + v len <= length b} -> Lemma (requires (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (v i + v len) == as_seq h b')) (ensures (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (v i + v len) == as_seq h b' /\ length b' = v len /\ (forall (j:nat). {:pattern (get h b' j)} j < length b' ==> get h b' j == get h b (j + v i)) )) [SMTPat (Seq.slice (as_seq h b) (v i) (v i + v len)); SMTPat (as_seq h b')] let lemma_sub_quantifiers #a h b b' i len = assert (Seq.length (Seq.slice (as_seq h b) (v i) (v i + v len)) = v len); let lemma_post (j:nat) = j < length b' ==> get h b' j == get h b (j + v i) in let qj : j:nat -> Lemma (lemma_post j) = fun j -> assert (j < v len ==> Seq.index (as_seq h b') j == Seq.index (as_seq h b) (j + v i)) in Classical.forall_intro #_ #lemma_post qj val lemma_offset_quantifiers: #a:Type -> h:mem -> b:buffer a -> b':buffer a -> i:FStar.UInt32.t{v i <= length b} -> Lemma (requires (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (length b) == as_seq h b')) (ensures (live h b /\ live h b' /\ Seq.slice (as_seq h b) (v i) (length b) == as_seq h b' /\ length b' = length b - v i /\ (forall (j:nat). {:pattern (get h b' j)} j < length b' ==> get h b' j == get h b (j + v i)) )) [SMTPat (Seq.slice (as_seq h b) (v i) (length b)); SMTPat (as_seq h b')] let lemma_offset_quantifiers #a h b b' i = lemma_sub_quantifiers #a h b b' i (uint_to_t (length b - v i)) val lemma_create_quantifiers: #a:Type -> h:mem -> b:buffer a -> init:a -> len:FStar.UInt32.t -> Lemma (requires (live h b /\ as_seq h b == Seq.create (v len) init)) (ensures (live h b /\ length b = v len /\ (forall (i:nat). {:pattern (get h b i)} i < length b ==> get h b i == init))) [SMTPat (as_seq h b); SMTPat (Seq.create (v len) init)] let lemma_create_quantifiers #a h b init len = assert (Seq.length (as_seq h b) = v len); let lemma_post (i:nat) = i < length b ==> get h b i == init in let qi : i:nat -> Lemma (lemma_post i) = fun i -> assert (i < length b ==> get h b i == Seq.index (as_seq h b) i) in Classical.forall_intro #_ #lemma_post qi val lemma_index_quantifiers: #a:Type -> h:mem -> b:buffer a -> n:FStar.UInt32.t -> Lemma (requires (live h b /\ v n < length b)) (ensures (live h b /\ v n < length b /\ get h b (v n) == Seq.index (as_seq h b) (v n))) [SMTPat (Seq.index (as_seq h b) (v n))] let lemma_index_quantifiers #a h b n = () val lemma_upd_quantifiers: #a:Type -> h0:mem -> h1:mem -> b:buffer a -> n:FStar.UInt32.t -> z:a -> Lemma (requires (live h0 b /\ live h1 b /\ v n < length b /\ as_seq h1 b == Seq.upd (as_seq h0 b) (v n) z)) (ensures (live h0 b /\ live h1 b /\ v n < length b /\ (forall (i:nat). {:pattern (get h1 b i)} (i < length b /\ i <> v n) ==> get h1 b i == get h0 b i) /\ get h1 b (v n) == z)) [SMTPat (as_seq h1 b); SMTPat (Seq.upd (as_seq h0 b) (v n) z)] let lemma_upd_quantifiers #a h0 h1 b n z = assert(forall (i:nat). i < length b ==> get h1 b i == Seq.index (as_seq h1 b) i) #reset-options "--initial_fuel 0 --max_fuel 0 --z3rlimit 8" val lemma_blit_quantifiers: #a:Type -> h0:mem -> h1:mem -> b:buffer a -> bi:UInt32.t{v bi <= length b} -> b':buffer a{disjoint b b'} -> bi':UInt32.t{v bi' <= length b'} -> len:UInt32.t{v bi+v len <= length b /\ v bi'+v len <= length b'} -> Lemma (requires (live h0 b /\ live h0 b' /\ live h1 b' /\ Seq.slice (as_seq h1 b') (v bi') (v bi'+v len) == Seq.slice (as_seq h0 b) (v bi) (v bi+v len) /\ Seq.slice (as_seq h1 b') 0 (v bi') == Seq.slice (as_seq h0 b') 0 (v bi') /\ Seq.slice (as_seq h1 b') (v bi'+v len) (length b') == Seq.slice (as_seq h0 b') (v bi'+v len) (length b') )) (ensures (live h0 b /\ live h0 b' /\ live h1 b' /\ (forall (i:nat). {:pattern (get h1 b' (v bi'+i))} i < v len ==> get h1 b' (v bi'+i) == get h0 b (v bi+i)) /\ (forall (i:nat). {:pattern (get h1 b' i)} ((i >= v bi' + v len /\ i < length b') \/ i < v bi') ==> get h1 b' i == get h0 b' i)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Buffer.fst.checked" ], "interface_file": false, "source_file": "FStar.Buffer.Quantifiers.fst" }
[ { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "FStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 8, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h0: FStar.Monotonic.HyperStack.mem -> h1: FStar.Monotonic.HyperStack.mem -> b: FStar.Buffer.buffer a -> bi: FStar.UInt32.t{FStar.UInt32.v bi <= FStar.Buffer.length b} -> b': FStar.Buffer.buffer a {FStar.Buffer.disjoint b b'} -> bi': FStar.UInt32.t{FStar.UInt32.v bi' <= FStar.Buffer.length b'} -> len: FStar.UInt32.t { FStar.UInt32.v bi + FStar.UInt32.v len <= FStar.Buffer.length b /\ FStar.UInt32.v bi' + FStar.UInt32.v len <= FStar.Buffer.length b' } -> FStar.Pervasives.Lemma (requires FStar.Buffer.live h0 b /\ FStar.Buffer.live h0 b' /\ FStar.Buffer.live h1 b' /\ FStar.Seq.Base.slice (FStar.Buffer.as_seq h1 b') (FStar.UInt32.v bi') (FStar.UInt32.v bi' + FStar.UInt32.v len) == FStar.Seq.Base.slice (FStar.Buffer.as_seq h0 b) (FStar.UInt32.v bi) (FStar.UInt32.v bi + FStar.UInt32.v len) /\ FStar.Seq.Base.slice (FStar.Buffer.as_seq h1 b') 0 (FStar.UInt32.v bi') == FStar.Seq.Base.slice (FStar.Buffer.as_seq h0 b') 0 (FStar.UInt32.v bi') /\ FStar.Seq.Base.slice (FStar.Buffer.as_seq h1 b') (FStar.UInt32.v bi' + FStar.UInt32.v len) (FStar.Buffer.length b') == FStar.Seq.Base.slice (FStar.Buffer.as_seq h0 b') (FStar.UInt32.v bi' + FStar.UInt32.v len) (FStar.Buffer.length b')) (ensures FStar.Buffer.live h0 b /\ FStar.Buffer.live h0 b' /\ FStar.Buffer.live h1 b' /\ (forall (i: Prims.nat). {:pattern FStar.Buffer.get h1 b' (FStar.UInt32.v bi' + i)} i < FStar.UInt32.v len ==> FStar.Buffer.get h1 b' (FStar.UInt32.v bi' + i) == FStar.Buffer.get h0 b (FStar.UInt32.v bi + i)) /\ (forall (i: Prims.nat). {:pattern FStar.Buffer.get h1 b' i} i >= FStar.UInt32.v bi' + FStar.UInt32.v len /\ i < FStar.Buffer.length b' \/ i < FStar.UInt32.v bi' ==> FStar.Buffer.get h1 b' i == FStar.Buffer.get h0 b' i))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "FStar.Buffer.buffer", "FStar.UInt32.t", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "FStar.Buffer.length", "FStar.Buffer.disjoint", "Prims.l_and", "Prims.op_Addition", "FStar.Classical.forall_intro", "Prims.nat", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "Prims._assert", "Prims.l_imp", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.eq2", "FStar.Seq.Base.index", "FStar.Seq.Base.slice", "FStar.Buffer.as_seq", "Prims.op_Subtraction", "Prims.logical", "Prims.l_or", "FStar.Buffer.get" ]
[]
false
false
true
false
false
let lemma_blit_quantifiers #a h0 h1 b bi b' bi' len =
let lemma_post_1 (j: nat) = j < v len ==> get h1 b' (v bi' + j) == get h0 b (v bi + j) in let qj_1: j: nat -> Lemma (lemma_post_1 j) = fun j -> assert (j < v len ==> Seq.index (Seq.slice (as_seq h1 b') (v bi') (v bi' + v len)) j == Seq.index (Seq.slice (as_seq h0 b) (v bi) (v bi + v len)) j) in let lemma_post_2 (j: nat) = ((j >= v bi' + v len /\ j < length b') \/ j < v bi') ==> get h1 b' j == get h0 b' j in let qj_2: j: nat -> Lemma (lemma_post_2 j) = fun j -> assert (j < v bi' ==> Seq.index (Seq.slice (as_seq h1 b') 0 (v bi')) j == Seq.index (Seq.slice (as_seq h0 b') 0 (v bi')) j); assert ((j >= v bi' + v len /\ j < length b') ==> Seq.index (Seq.slice (as_seq h1 b') (v bi' + v len) (length b')) (j - (v bi' + v len)) == Seq.index (Seq.slice (as_seq h0 b') (v bi' + v len) (length b')) (j - (v bi' + v len))) in Classical.forall_intro #_ #lemma_post_1 qj_1; Classical.forall_intro #_ #lemma_post_2 qj_2
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.pose_lemma
val pose_lemma (t: term) : Tac binder
val pose_lemma (t: term) : Tac binder
let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 5, "end_line": 126, "start_col": 0, "start_line": 107 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.Types.binder
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Tactics.V1.Derived.pose", "FStar.Stubs.Reflection.Types.binder", "FStar.Reflection.V1.Formula.formula", "Prims.unit", "FStar.Pervasives.ignore", "FStar.Pervasives.Native.option", "FStar.Tactics.V1.Derived.trytac", "FStar.Tactics.V1.Derived.trivial", "FStar.Tactics.V1.Derived.flip", "FStar.Tactics.V1.Derived.binder_to_term", "FStar.Tactics.V1.Derived.tcut", "FStar.Reflection.V1.Formula.term_as_formula'", "FStar.Tactics.V1.Derived.norm_term", "Prims.Nil", "FStar.Pervasives.norm_step", "FStar.Pervasives.Native.tuple2", "FStar.Stubs.Reflection.V1.Builtins.inspect_comp", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V1.Data.comp_view", "FStar.Tactics.V1.Derived.fail", "FStar.Stubs.Reflection.Types.comp", "FStar.Stubs.Tactics.V1.Builtins.tcc", "FStar.Stubs.Reflection.Types.env", "FStar.Tactics.V1.Derived.cur_env" ]
[]
false
true
false
false
false
let pose_lemma (t: term) : Tac binder =
let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in let post = norm_term [] post in match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.revert_squash
val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x)
val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x)
let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in ()
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 71, "end_line": 31, "start_col": 0, "start_line": 31 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) ->
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: Prims.squash (forall (x: a). b x) -> x: a -> Prims.squash (b x)
Prims.Tot
[ "total" ]
[]
[ "Prims.squash", "Prims.l_Forall", "Prims.unit" ]
[]
false
false
true
false
false
let revert_squash #a #b s x =
let x:(_: unit{forall x. b x}) = s in ()
false
MiniParseExample2.fst
MiniParseExample2.c2
val c2:sum_case #somme #(bounded_u16 4) imp0 2us
val c2:sum_case #somme #(bounded_u16 4) imp0 2us
let c2 : sum_case #somme #(bounded_u16 4) imp0 2us = Case #(bounded_u16 4) #somme unit parse_empty serialize_empty (fun (_: unit) -> W <: refine_with_tag #(bounded_u16 4) #somme imp0 (2us <: bounded_u16 4)) (fun (x: refine_with_tag #(bounded_u16 4) #somme imp0 (2us <: bounded_u16 4)) -> ()) ()
{ "file_name": "examples/miniparse/MiniParseExample2.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 10, "end_line": 53, "start_col": 0, "start_line": 46 }
(* 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 MiniParseExample2 open MiniParse.Spec.TSum module T = FStar.Tactics.V2 module U8 = FStar.UInt8 noeq type somme = | U of FStar.UInt8.t | V | W | X #set-options "--z3rlimit 16" let imp0 (x: somme) : Tot (bounded_u16 4) = match x with | U _ -> 0us <: bounded_u16 4 | V -> 1us <: bounded_u16 4 | W -> 2us <: bounded_u16 4 | _ -> 3us <: bounded_u16 4 #set-options "--print_universes --print_implicits" let c3 : sum_case #somme #(bounded_u16 4) imp0 3us = Case #(bounded_u16 4) #somme unit parse_empty serialize_empty (fun (_: unit) -> X <: refine_with_tag #(bounded_u16 4) #somme imp0 (3us <: bounded_u16 4)) (fun (_: refine_with_tag #(bounded_u16 4) #somme imp0 (3us <: bounded_u16 4)) -> ()) () #set-options "--z3rlimit 64"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MiniParse.Spec.TSum.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.V2.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "MiniParseExample2.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "MiniParse.Spec.TSum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
MiniParse.Spec.TSum.sum_case MiniParseExample2.imp0 (2us <: FStar.UInt16.t)
Prims.Tot
[ "total" ]
[]
[ "MiniParse.Spec.TSum.Case", "MiniParse.Spec.Int.bounded_u16", "MiniParseExample2.somme", "MiniParseExample2.imp0", "FStar.UInt16.__uint_to_t", "Prims.unit", "MiniParse.Spec.Combinators.parse_empty", "MiniParse.Spec.Combinators.serialize_empty", "MiniParseExample2.W", "MiniParse.Spec.TSum.refine_with_tag" ]
[]
false
false
false
false
false
let c2:sum_case #somme #(bounded_u16 4) imp0 2us =
Case #(bounded_u16 4) #somme unit parse_empty serialize_empty (fun (_: unit) -> W <: refine_with_tag #(bounded_u16 4) #somme imp0 (2us <: bounded_u16 4)) (fun (x: refine_with_tag #(bounded_u16 4) #somme imp0 (2us <: bounded_u16 4)) -> ()) ()
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.cases_or
val cases_or (o: term) : Tac unit
val cases_or (o: term) : Tac unit
let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o])
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 40, "end_line": 205, "start_col": 0, "start_line": 204 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. *) let unsquash (t:term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack_ln (Tv_Var (bv_of_binder b)) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
o: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Tactics.V1.Derived.apply_lemma", "FStar.Reflection.V1.Derived.mk_e_app", "Prims.Cons", "Prims.Nil", "Prims.unit" ]
[]
false
true
false
false
false
let cases_or (o: term) : Tac unit =
apply_lemma (mk_e_app (`or_ind) [o])
false
MiniParseExample2.fst
MiniParseExample2.c1
val c1:sum_case #somme #(bounded_u16 4) imp0 1us
val c1:sum_case #somme #(bounded_u16 4) imp0 1us
let c1 : sum_case #somme #(bounded_u16 4) imp0 1us = Case #(bounded_u16 4) #somme unit parse_empty serialize_empty (fun (_: unit) -> V <: refine_with_tag #(bounded_u16 4) #somme imp0 (1us <: bounded_u16 4)) (fun (_: refine_with_tag #(bounded_u16 4) #somme imp0 (1us <: bounded_u16 4)) -> ()) ()
{ "file_name": "examples/miniparse/MiniParseExample2.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 10, "end_line": 62, "start_col": 0, "start_line": 55 }
(* 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 MiniParseExample2 open MiniParse.Spec.TSum module T = FStar.Tactics.V2 module U8 = FStar.UInt8 noeq type somme = | U of FStar.UInt8.t | V | W | X #set-options "--z3rlimit 16" let imp0 (x: somme) : Tot (bounded_u16 4) = match x with | U _ -> 0us <: bounded_u16 4 | V -> 1us <: bounded_u16 4 | W -> 2us <: bounded_u16 4 | _ -> 3us <: bounded_u16 4 #set-options "--print_universes --print_implicits" let c3 : sum_case #somme #(bounded_u16 4) imp0 3us = Case #(bounded_u16 4) #somme unit parse_empty serialize_empty (fun (_: unit) -> X <: refine_with_tag #(bounded_u16 4) #somme imp0 (3us <: bounded_u16 4)) (fun (_: refine_with_tag #(bounded_u16 4) #somme imp0 (3us <: bounded_u16 4)) -> ()) () #set-options "--z3rlimit 64" let c2 : sum_case #somme #(bounded_u16 4) imp0 2us = Case #(bounded_u16 4) #somme unit parse_empty serialize_empty (fun (_: unit) -> W <: refine_with_tag #(bounded_u16 4) #somme imp0 (2us <: bounded_u16 4)) (fun (x: refine_with_tag #(bounded_u16 4) #somme imp0 (2us <: bounded_u16 4)) -> ()) ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MiniParse.Spec.TSum.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.V2.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "MiniParseExample2.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "MiniParse.Spec.TSum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
MiniParse.Spec.TSum.sum_case MiniParseExample2.imp0 (1us <: FStar.UInt16.t)
Prims.Tot
[ "total" ]
[]
[ "MiniParse.Spec.TSum.Case", "MiniParse.Spec.Int.bounded_u16", "MiniParseExample2.somme", "MiniParseExample2.imp0", "FStar.UInt16.__uint_to_t", "Prims.unit", "MiniParse.Spec.Combinators.parse_empty", "MiniParse.Spec.Combinators.serialize_empty", "MiniParseExample2.V", "MiniParse.Spec.TSum.refine_with_tag" ]
[]
false
false
false
false
false
let c1:sum_case #somme #(bounded_u16 4) imp0 1us =
Case #(bounded_u16 4) #somme unit parse_empty serialize_empty (fun (_: unit) -> V <: refine_with_tag #(bounded_u16 4) #somme imp0 (1us <: bounded_u16 4)) (fun (_: refine_with_tag #(bounded_u16 4) #somme imp0 (1us <: bounded_u16 4)) -> ()) ()
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.right
val right: Prims.unit -> Tac unit
val right: Prims.unit -> Tac unit
let right () : Tac unit = apply_lemma (`or_intro_2)
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 29, "end_line": 227, "start_col": 0, "start_line": 226 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. *) let unsquash (t:term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack_ln (Tv_Var (bv_of_binder b)) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.unit", "FStar.Tactics.V1.Derived.apply_lemma" ]
[]
false
true
false
false
false
let right () : Tac unit =
apply_lemma (`or_intro_2)
false
MiniParseExample2.fst
MiniParseExample2.c0
val c0:sum_case #somme #(bounded_u16 4) imp0 0us
val c0:sum_case #somme #(bounded_u16 4) imp0 0us
let c0 : sum_case #somme #(bounded_u16 4) imp0 0us = Case #(bounded_u16 4) #somme U8.t parse_u8 serialize_u8 (fun (x: U8.t) -> U x <: refine_with_tag #(bounded_u16 4) #somme imp0 (0us <: bounded_u16 4)) (fun (x: refine_with_tag #(bounded_u16 4) #somme imp0 0us) -> ( match x with | U x -> x )) ()
{ "file_name": "examples/miniparse/MiniParseExample2.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 10, "end_line": 74, "start_col": 0, "start_line": 64 }
(* 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 MiniParseExample2 open MiniParse.Spec.TSum module T = FStar.Tactics.V2 module U8 = FStar.UInt8 noeq type somme = | U of FStar.UInt8.t | V | W | X #set-options "--z3rlimit 16" let imp0 (x: somme) : Tot (bounded_u16 4) = match x with | U _ -> 0us <: bounded_u16 4 | V -> 1us <: bounded_u16 4 | W -> 2us <: bounded_u16 4 | _ -> 3us <: bounded_u16 4 #set-options "--print_universes --print_implicits" let c3 : sum_case #somme #(bounded_u16 4) imp0 3us = Case #(bounded_u16 4) #somme unit parse_empty serialize_empty (fun (_: unit) -> X <: refine_with_tag #(bounded_u16 4) #somme imp0 (3us <: bounded_u16 4)) (fun (_: refine_with_tag #(bounded_u16 4) #somme imp0 (3us <: bounded_u16 4)) -> ()) () #set-options "--z3rlimit 64" let c2 : sum_case #somme #(bounded_u16 4) imp0 2us = Case #(bounded_u16 4) #somme unit parse_empty serialize_empty (fun (_: unit) -> W <: refine_with_tag #(bounded_u16 4) #somme imp0 (2us <: bounded_u16 4)) (fun (x: refine_with_tag #(bounded_u16 4) #somme imp0 (2us <: bounded_u16 4)) -> ()) () let c1 : sum_case #somme #(bounded_u16 4) imp0 1us = Case #(bounded_u16 4) #somme unit parse_empty serialize_empty (fun (_: unit) -> V <: refine_with_tag #(bounded_u16 4) #somme imp0 (1us <: bounded_u16 4)) (fun (_: refine_with_tag #(bounded_u16 4) #somme imp0 (1us <: bounded_u16 4)) -> ()) ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MiniParse.Spec.TSum.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Tactics.V2.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "MiniParseExample2.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "MiniParse.Spec.TSum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
MiniParse.Spec.TSum.sum_case MiniParseExample2.imp0 (0us <: FStar.UInt16.t)
Prims.Tot
[ "total" ]
[]
[ "MiniParse.Spec.TSum.Case", "MiniParse.Spec.Int.bounded_u16", "MiniParseExample2.somme", "MiniParseExample2.imp0", "FStar.UInt16.__uint_to_t", "FStar.UInt8.t", "MiniParse.Spec.Int.parse_u8", "MiniParse.Spec.Int.serialize_u8", "MiniParseExample2.U", "MiniParse.Spec.TSum.refine_with_tag" ]
[]
false
false
false
false
false
let c0:sum_case #somme #(bounded_u16 4) imp0 0us =
Case #(bounded_u16 4) #somme U8.t parse_u8 serialize_u8 (fun (x: U8.t) -> U x <: refine_with_tag #(bounded_u16 4) #somme imp0 (0us <: bounded_u16 4)) (fun (x: refine_with_tag #(bounded_u16 4) #somme imp0 0us) -> (match x with | U x -> x)) ()
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.imp_intro_lem
val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b)
val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b)
let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f))
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 113, "end_line": 74, "start_col": 0, "start_line": 73 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) ->
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: a -> Prims.squash b) -> FStar.Pervasives.Lemma (ensures a ==> b)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.squash", "FStar.Classical.give_witness", "Prims.l_imp", "FStar.Classical.arrow_to_impl", "FStar.Squash.bind_squash", "Prims.unit" ]
[]
false
false
true
false
false
let imp_intro_lem #a #b f =
FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x: squash a) -> FStar.Squash.bind_squash x f))
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.cases_bool
val cases_bool (b: term) : Tac unit
val cases_bool (b: term) : Tac unit
let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ())
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 104, "end_line": 215, "start_col": 0, "start_line": 212 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. *) let unsquash (t:term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack_ln (Tv_Var (bv_of_binder b)) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Tactics.V1.Derived.seq", "Prims.unit", "FStar.Tactics.V1.Derived.apply_lemma", "FStar.Reflection.V1.Derived.mk_e_app", "Prims.Cons", "Prims.Nil", "FStar.Pervasives.Native.option", "FStar.Tactics.V1.Derived.trytac", "FStar.Stubs.Tactics.V1.Builtins.clear_top", "FStar.Stubs.Tactics.V1.Builtins.rewrite", "FStar.Stubs.Reflection.Types.binder", "FStar.Tactics.V1.Logic.implies_intro" ]
[]
false
true
false
false
false
let cases_bool (b: term) : Tac unit =
let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ())
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.and_elim
val and_elim (t: term) : Tac unit
val and_elim (t: term) : Tac unit
let and_elim (t : term) : Tac unit = begin try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t))) end
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 7, "end_line": 245, "start_col": 0, "start_line": 241 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. *) let unsquash (t:term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack_ln (Tv_Var (bv_of_binder b)) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1) let right () : Tac unit = apply_lemma (`or_intro_2) private val __and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim #p #q #phi p_and_q f = () private val __and_elim' : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim' #p #q #phi p_and_q f = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Tactics.V1.Derived.try_with", "Prims.unit", "FStar.Tactics.V1.Derived.apply_lemma", "Prims.exn" ]
[]
false
true
false
false
false
let and_elim (t: term) : Tac unit =
try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t)))
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.witness
val witness (t: term) : Tac unit
val witness (t: term) : Tac unit
let witness (t : term) : Tac unit = apply_raw (`__witness); exact t
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 11, "end_line": 256, "start_col": 0, "start_line": 254 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. *) let unsquash (t:term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack_ln (Tv_Var (bv_of_binder b)) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1) let right () : Tac unit = apply_lemma (`or_intro_2) private val __and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim #p #q #phi p_and_q f = () private val __and_elim' : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim' #p #q #phi p_and_q f = () let and_elim (t : term) : Tac unit = begin try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t))) end let destruct_and (t : term) : Tac (binder * binder) = and_elim t; (implies_intro (), implies_intro ()) private val __witness : (#a:Type) -> (x:a) -> (#p:(a -> Type)) -> squash (p x) -> squash (exists (x:a). p x) private let __witness #a x #p _ = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Tactics.V1.Derived.exact", "Prims.unit", "FStar.Tactics.V1.Derived.apply_raw" ]
[]
false
true
false
false
false
let witness (t: term) : Tac unit =
apply_raw (`__witness); exact t
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.__elim_exists'
val __elim_exists' (#t: _) (#pred: (t -> Type0)) (#goal: _) (h: (exists x. pred x)) (k: (x: t -> pred x -> squash goal)) : squash goal
val __elim_exists' (#t: _) (#pred: (t -> Type0)) (#goal: _) (h: (exists x. pred x)) (k: (x: t -> pred x -> squash goal)) : squash goal
let __elim_exists' #t (#pred : t -> Type0) #goal (h : (exists x. pred x)) (k : (x:t -> pred x -> squash goal)) : squash goal = FStar.Squash.bind_squash #(x:t & pred x) h (fun (|x, pf|) -> k x pf)
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 70, "end_line": 261, "start_col": 0, "start_line": 259 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. *) let unsquash (t:term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack_ln (Tv_Var (bv_of_binder b)) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1) let right () : Tac unit = apply_lemma (`or_intro_2) private val __and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim #p #q #phi p_and_q f = () private val __and_elim' : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim' #p #q #phi p_and_q f = () let and_elim (t : term) : Tac unit = begin try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t))) end let destruct_and (t : term) : Tac (binder * binder) = and_elim t; (implies_intro (), implies_intro ()) private val __witness : (#a:Type) -> (x:a) -> (#p:(a -> Type)) -> squash (p x) -> squash (exists (x:a). p x) private let __witness #a x #p _ = () let witness (t : term) : Tac unit = apply_raw (`__witness); exact t
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: (exists (x: t). pred x) -> k: (x: t -> _: pred x -> Prims.squash goal) -> Prims.squash goal
Prims.Tot
[ "total" ]
[]
[ "Prims.l_Exists", "Prims.squash", "FStar.Squash.bind_squash", "Prims.dtuple2" ]
[]
false
false
true
false
false
let __elim_exists' #t (#pred: (t -> Type0)) #goal (h: (exists x. pred x)) (k: (x: t -> pred x -> squash goal)) : squash goal =
FStar.Squash.bind_squash #(x: t & pred x) h (fun (| x , pf |) -> k x pf)
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.destruct_and
val destruct_and (t: term) : Tac (binder * binder)
val destruct_and (t: term) : Tac (binder * binder)
let destruct_and (t : term) : Tac (binder * binder) = and_elim t; (implies_intro (), implies_intro ())
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 40, "end_line": 249, "start_col": 0, "start_line": 247 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. *) let unsquash (t:term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack_ln (Tv_Var (bv_of_binder b)) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1) let right () : Tac unit = apply_lemma (`or_intro_2) private val __and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim #p #q #phi p_and_q f = () private val __and_elim' : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim' #p #q #phi p_and_q f = () let and_elim (t : term) : Tac unit = begin try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t))) end
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac (FStar.Stubs.Reflection.Types.binder * FStar.Stubs.Reflection.Types.binder)
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.Types.binder", "FStar.Pervasives.Native.tuple2", "FStar.Tactics.V1.Logic.implies_intro", "Prims.unit", "FStar.Tactics.V1.Logic.and_elim" ]
[]
false
true
false
false
false
let destruct_and (t: term) : Tac (binder * binder) =
and_elim t; (implies_intro (), implies_intro ())
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.left
val left: Prims.unit -> Tac unit
val left: Prims.unit -> Tac unit
let left () : Tac unit = apply_lemma (`or_intro_1)
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 29, "end_line": 224, "start_col": 0, "start_line": 223 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. *) let unsquash (t:term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack_ln (Tv_Var (bv_of_binder b)) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.unit", "FStar.Tactics.V1.Derived.apply_lemma" ]
[]
false
true
false
false
false
let left () : Tac unit =
apply_lemma (`or_intro_1)
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.elim_exists
val elim_exists (t: term) : Tac (binder & binder)
val elim_exists (t: term) : Tac (binder & binder)
let elim_exists (t : term) : Tac (binder & binder) = apply_lemma (`(__elim_exists' (`#(t)))); let x = intro () in let pf = intro () in (x, pf)
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 9, "end_line": 268, "start_col": 0, "start_line": 264 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. *) let unsquash (t:term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack_ln (Tv_Var (bv_of_binder b)) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1) let right () : Tac unit = apply_lemma (`or_intro_2) private val __and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim #p #q #phi p_and_q f = () private val __and_elim' : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim' #p #q #phi p_and_q f = () let and_elim (t : term) : Tac unit = begin try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t))) end let destruct_and (t : term) : Tac (binder * binder) = and_elim t; (implies_intro (), implies_intro ()) private val __witness : (#a:Type) -> (x:a) -> (#p:(a -> Type)) -> squash (p x) -> squash (exists (x:a). p x) private let __witness #a x #p _ = () let witness (t : term) : Tac unit = apply_raw (`__witness); exact t private let __elim_exists' #t (#pred : t -> Type0) #goal (h : (exists x. pred x)) (k : (x:t -> pred x -> squash goal)) : squash goal = FStar.Squash.bind_squash #(x:t & pred x) h (fun (|x, pf|) -> k x pf)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac (FStar.Stubs.Reflection.Types.binder * FStar.Stubs.Reflection.Types.binder)
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.Types.binder", "FStar.Pervasives.Native.tuple2", "FStar.Stubs.Tactics.V1.Builtins.intro", "Prims.unit", "FStar.Tactics.V1.Derived.apply_lemma" ]
[]
false
true
false
false
false
let elim_exists (t: term) : Tac (binder & binder) =
apply_lemma (`(__elim_exists' (`#(t)))); let x = intro () in let pf = intro () in (x, pf)
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.__forall_inst_sq
val __forall_inst_sq (#t: _) (#pred: (t -> Type0)) (h: squash (forall x. pred x)) (x: t) : squash (pred x)
val __forall_inst_sq (#t: _) (#pred: (t -> Type0)) (h: squash (forall x. pred x)) (x: t) : squash (pred x)
let __forall_inst_sq #t (#pred : t -> Type0) (h : squash (forall x. pred x)) (x : t) : squash (pred x) = FStar.Squash.bind_squash h (fun (f : (forall x. pred x)) -> __forall_inst f x)
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 82, "end_line": 277, "start_col": 0, "start_line": 276 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. *) let unsquash (t:term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack_ln (Tv_Var (bv_of_binder b)) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1) let right () : Tac unit = apply_lemma (`or_intro_2) private val __and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim #p #q #phi p_and_q f = () private val __and_elim' : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim' #p #q #phi p_and_q f = () let and_elim (t : term) : Tac unit = begin try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t))) end let destruct_and (t : term) : Tac (binder * binder) = and_elim t; (implies_intro (), implies_intro ()) private val __witness : (#a:Type) -> (x:a) -> (#p:(a -> Type)) -> squash (p x) -> squash (exists (x:a). p x) private let __witness #a x #p _ = () let witness (t : term) : Tac unit = apply_raw (`__witness); exact t private let __elim_exists' #t (#pred : t -> Type0) #goal (h : (exists x. pred x)) (k : (x:t -> pred x -> squash goal)) : squash goal = FStar.Squash.bind_squash #(x:t & pred x) h (fun (|x, pf|) -> k x pf) (* returns witness and proof as binders *) let elim_exists (t : term) : Tac (binder & binder) = apply_lemma (`(__elim_exists' (`#(t)))); let x = intro () in let pf = intro () in (x, pf) private let __forall_inst #t (#pred : t -> Type0) (h : (forall x. pred x)) (x : t) : squash (pred x) = () (* GM: annoying that this doesn't just work by SMT *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: Prims.squash (forall (x: t). pred x) -> x: t -> Prims.squash (pred x)
Prims.Tot
[ "total" ]
[]
[ "Prims.squash", "Prims.l_Forall", "FStar.Squash.bind_squash", "FStar.Tactics.V1.Logic.__forall_inst" ]
[]
false
false
true
false
false
let __forall_inst_sq #t (#pred: (t -> Type0)) (h: squash (forall x. pred x)) (x: t) : squash (pred x) =
FStar.Squash.bind_squash h (fun (f: (forall x. pred x)) -> __forall_inst f x)
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.instantiate_as
val instantiate_as (fa x: term) (s: string) : Tac binder
val instantiate_as (fa x: term) (s: string) : Tac binder
let instantiate_as (fa : term) (x : term) (s : string) : Tac binder = let b = instantiate fa x in rename_to b s
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 17, "end_line": 286, "start_col": 0, "start_line": 284 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. *) let unsquash (t:term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack_ln (Tv_Var (bv_of_binder b)) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1) let right () : Tac unit = apply_lemma (`or_intro_2) private val __and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim #p #q #phi p_and_q f = () private val __and_elim' : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim' #p #q #phi p_and_q f = () let and_elim (t : term) : Tac unit = begin try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t))) end let destruct_and (t : term) : Tac (binder * binder) = and_elim t; (implies_intro (), implies_intro ()) private val __witness : (#a:Type) -> (x:a) -> (#p:(a -> Type)) -> squash (p x) -> squash (exists (x:a). p x) private let __witness #a x #p _ = () let witness (t : term) : Tac unit = apply_raw (`__witness); exact t private let __elim_exists' #t (#pred : t -> Type0) #goal (h : (exists x. pred x)) (k : (x:t -> pred x -> squash goal)) : squash goal = FStar.Squash.bind_squash #(x:t & pred x) h (fun (|x, pf|) -> k x pf) (* returns witness and proof as binders *) let elim_exists (t : term) : Tac (binder & binder) = apply_lemma (`(__elim_exists' (`#(t)))); let x = intro () in let pf = intro () in (x, pf) private let __forall_inst #t (#pred : t -> Type0) (h : (forall x. pred x)) (x : t) : squash (pred x) = () (* GM: annoying that this doesn't just work by SMT *) private let __forall_inst_sq #t (#pred : t -> Type0) (h : squash (forall x. pred x)) (x : t) : squash (pred x) = FStar.Squash.bind_squash h (fun (f : (forall x. pred x)) -> __forall_inst f x) let instantiate (fa : term) (x : term) : Tac binder = try pose (`__forall_inst_sq (`#fa) (`#x)) with | _ -> try pose (`__forall_inst (`#fa) (`#x)) with | _ -> fail "could not instantiate"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
fa: FStar.Stubs.Reflection.Types.term -> x: FStar.Stubs.Reflection.Types.term -> s: Prims.string -> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.Types.binder
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.term", "Prims.string", "FStar.Stubs.Tactics.V1.Builtins.rename_to", "FStar.Stubs.Reflection.Types.binder", "FStar.Tactics.V1.Logic.instantiate" ]
[]
false
true
false
false
false
let instantiate_as (fa x: term) (s: string) : Tac binder =
let b = instantiate fa x in rename_to b s
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.easy
val easy : #a:Type -> (#[easy_fill ()] _ : a) -> a
val easy : #a:Type -> (#[easy_fill ()] _ : a) -> a
let easy #a #x = x
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 18, "end_line": 327, "start_col": 0, "start_line": 327 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. *) let unsquash (t:term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack_ln (Tv_Var (bv_of_binder b)) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1) let right () : Tac unit = apply_lemma (`or_intro_2) private val __and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim #p #q #phi p_and_q f = () private val __and_elim' : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim' #p #q #phi p_and_q f = () let and_elim (t : term) : Tac unit = begin try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t))) end let destruct_and (t : term) : Tac (binder * binder) = and_elim t; (implies_intro (), implies_intro ()) private val __witness : (#a:Type) -> (x:a) -> (#p:(a -> Type)) -> squash (p x) -> squash (exists (x:a). p x) private let __witness #a x #p _ = () let witness (t : term) : Tac unit = apply_raw (`__witness); exact t private let __elim_exists' #t (#pred : t -> Type0) #goal (h : (exists x. pred x)) (k : (x:t -> pred x -> squash goal)) : squash goal = FStar.Squash.bind_squash #(x:t & pred x) h (fun (|x, pf|) -> k x pf) (* returns witness and proof as binders *) let elim_exists (t : term) : Tac (binder & binder) = apply_lemma (`(__elim_exists' (`#(t)))); let x = intro () in let pf = intro () in (x, pf) private let __forall_inst #t (#pred : t -> Type0) (h : (forall x. pred x)) (x : t) : squash (pred x) = () (* GM: annoying that this doesn't just work by SMT *) private let __forall_inst_sq #t (#pred : t -> Type0) (h : squash (forall x. pred x)) (x : t) : squash (pred x) = FStar.Squash.bind_squash h (fun (f : (forall x. pred x)) -> __forall_inst f x) let instantiate (fa : term) (x : term) : Tac binder = try pose (`__forall_inst_sq (`#fa) (`#x)) with | _ -> try pose (`__forall_inst (`#fa) (`#x)) with | _ -> fail "could not instantiate" let instantiate_as (fa : term) (x : term) (s : string) : Tac binder = let b = instantiate fa x in rename_to b s private let sklem0 (#a:Type) (#p : a -> Type0) ($v : (exists (x:a). p x)) (phi:Type0) : Lemma (requires (forall x. p x ==> phi)) (ensures phi) = () private let rec sk_binder' (acc:binders) (b:binder) : Tac (binders * binder) = focus (fun () -> try apply_lemma (`(sklem0 (`#(binder_to_term b)))); if ngoals () <> 1 then fail "no"; clear b; let bx = forall_intro () in let b' = implies_intro () in sk_binder' (bx::acc) b' (* We might have introduced a new existential, so possibly recurse *) with | _ -> (acc, b) (* If the above failed, just return *) ) (* Skolemizes a given binder for an existential, returning the introduced new binders * and the skolemized formula. *) let sk_binder b = sk_binder' [] b let skolem () = let bs = binders_of_env (cur_env ()) in map sk_binder bs private val lemma_from_squash : #a:Type -> #b:(a -> Type) -> (x:a -> squash (b x)) -> x:a -> Lemma (b x) private let lemma_from_squash #a #b f x = let _ = f x in assert (b x) private let easy_fill () = let _ = repeat intro in (* If the goal is `a -> Lemma b`, intro will fail, try to use this switch *) let _ = trytac (fun () -> apply (`lemma_from_squash); intro ()) in smt ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a
Prims.Tot
[ "total" ]
[]
[]
[]
false
false
false
true
false
let easy #a #x =
x
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.instantiate
val instantiate (fa x: term) : Tac binder
val instantiate (fa x: term) : Tac binder
let instantiate (fa : term) (x : term) : Tac binder = try pose (`__forall_inst_sq (`#fa) (`#x)) with | _ -> try pose (`__forall_inst (`#fa) (`#x)) with | _ -> fail "could not instantiate"
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 32, "end_line": 282, "start_col": 0, "start_line": 279 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. *) let unsquash (t:term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack_ln (Tv_Var (bv_of_binder b)) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1) let right () : Tac unit = apply_lemma (`or_intro_2) private val __and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim #p #q #phi p_and_q f = () private val __and_elim' : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim' #p #q #phi p_and_q f = () let and_elim (t : term) : Tac unit = begin try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t))) end let destruct_and (t : term) : Tac (binder * binder) = and_elim t; (implies_intro (), implies_intro ()) private val __witness : (#a:Type) -> (x:a) -> (#p:(a -> Type)) -> squash (p x) -> squash (exists (x:a). p x) private let __witness #a x #p _ = () let witness (t : term) : Tac unit = apply_raw (`__witness); exact t private let __elim_exists' #t (#pred : t -> Type0) #goal (h : (exists x. pred x)) (k : (x:t -> pred x -> squash goal)) : squash goal = FStar.Squash.bind_squash #(x:t & pred x) h (fun (|x, pf|) -> k x pf) (* returns witness and proof as binders *) let elim_exists (t : term) : Tac (binder & binder) = apply_lemma (`(__elim_exists' (`#(t)))); let x = intro () in let pf = intro () in (x, pf) private let __forall_inst #t (#pred : t -> Type0) (h : (forall x. pred x)) (x : t) : squash (pred x) = () (* GM: annoying that this doesn't just work by SMT *) private let __forall_inst_sq #t (#pred : t -> Type0) (h : squash (forall x. pred x)) (x : t) : squash (pred x) = FStar.Squash.bind_squash h (fun (f : (forall x. pred x)) -> __forall_inst f x)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
fa: FStar.Stubs.Reflection.Types.term -> x: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.Types.binder
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Tactics.V1.Derived.try_with", "FStar.Stubs.Reflection.Types.binder", "Prims.unit", "FStar.Tactics.V1.Derived.pose", "Prims.exn", "FStar.Tactics.V1.Derived.fail" ]
[]
false
true
false
false
false
let instantiate (fa x: term) : Tac binder =
try pose (`__forall_inst_sq (`#fa) (`#x)) with | _ -> try pose (`__forall_inst (`#fa) (`#x)) with | _ -> fail "could not instantiate"
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.__lemma_to_squash
val __lemma_to_squash: #req: _ -> #ens: _ -> squash req -> h: (unit -> Lemma (requires req) (ensures ens)) -> squash ens
val __lemma_to_squash: #req: _ -> #ens: _ -> squash req -> h: (unit -> Lemma (requires req) (ensures ens)) -> squash ens
let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h ()
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 6, "end_line": 105, "start_col": 0, "start_line": 104 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.squash req -> h: (_: Prims.unit -> FStar.Pervasives.Lemma (requires req) (ensures ens)) -> Prims.squash ens
Prims.Tot
[ "total" ]
[]
[ "Prims.squash", "Prims.unit", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let __lemma_to_squash #req #ens (_: squash req) (h: (unit -> Lemma (requires req) (ensures ens))) : squash ens =
h ()
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.easy_fill
val easy_fill : _: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
let easy_fill () = let _ = repeat intro in (* If the goal is `a -> Lemma b`, intro will fail, try to use this switch *) let _ = trytac (fun () -> apply (`lemma_from_squash); intro ()) in smt ()
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 10, "end_line": 324, "start_col": 0, "start_line": 320 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. *) let unsquash (t:term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack_ln (Tv_Var (bv_of_binder b)) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1) let right () : Tac unit = apply_lemma (`or_intro_2) private val __and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim #p #q #phi p_and_q f = () private val __and_elim' : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim' #p #q #phi p_and_q f = () let and_elim (t : term) : Tac unit = begin try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t))) end let destruct_and (t : term) : Tac (binder * binder) = and_elim t; (implies_intro (), implies_intro ()) private val __witness : (#a:Type) -> (x:a) -> (#p:(a -> Type)) -> squash (p x) -> squash (exists (x:a). p x) private let __witness #a x #p _ = () let witness (t : term) : Tac unit = apply_raw (`__witness); exact t private let __elim_exists' #t (#pred : t -> Type0) #goal (h : (exists x. pred x)) (k : (x:t -> pred x -> squash goal)) : squash goal = FStar.Squash.bind_squash #(x:t & pred x) h (fun (|x, pf|) -> k x pf) (* returns witness and proof as binders *) let elim_exists (t : term) : Tac (binder & binder) = apply_lemma (`(__elim_exists' (`#(t)))); let x = intro () in let pf = intro () in (x, pf) private let __forall_inst #t (#pred : t -> Type0) (h : (forall x. pred x)) (x : t) : squash (pred x) = () (* GM: annoying that this doesn't just work by SMT *) private let __forall_inst_sq #t (#pred : t -> Type0) (h : squash (forall x. pred x)) (x : t) : squash (pred x) = FStar.Squash.bind_squash h (fun (f : (forall x. pred x)) -> __forall_inst f x) let instantiate (fa : term) (x : term) : Tac binder = try pose (`__forall_inst_sq (`#fa) (`#x)) with | _ -> try pose (`__forall_inst (`#fa) (`#x)) with | _ -> fail "could not instantiate" let instantiate_as (fa : term) (x : term) (s : string) : Tac binder = let b = instantiate fa x in rename_to b s private let sklem0 (#a:Type) (#p : a -> Type0) ($v : (exists (x:a). p x)) (phi:Type0) : Lemma (requires (forall x. p x ==> phi)) (ensures phi) = () private let rec sk_binder' (acc:binders) (b:binder) : Tac (binders * binder) = focus (fun () -> try apply_lemma (`(sklem0 (`#(binder_to_term b)))); if ngoals () <> 1 then fail "no"; clear b; let bx = forall_intro () in let b' = implies_intro () in sk_binder' (bx::acc) b' (* We might have introduced a new existential, so possibly recurse *) with | _ -> (acc, b) (* If the above failed, just return *) ) (* Skolemizes a given binder for an existential, returning the introduced new binders * and the skolemized formula. *) let sk_binder b = sk_binder' [] b let skolem () = let bs = binders_of_env (cur_env ()) in map sk_binder bs private val lemma_from_squash : #a:Type -> #b:(a -> Type) -> (x:a -> squash (b x)) -> x:a -> Lemma (b x) private let lemma_from_squash #a #b f x = let _ = f x in assert (b x)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.unit", "FStar.Tactics.V1.Derived.smt", "FStar.Pervasives.Native.option", "FStar.Stubs.Reflection.Types.binder", "FStar.Tactics.V1.Derived.trytac", "FStar.Stubs.Tactics.V1.Builtins.intro", "FStar.Tactics.V1.Derived.apply", "Prims.list", "FStar.Tactics.V1.Derived.repeat" ]
[]
false
true
false
false
false
let easy_fill () =
let _ = repeat intro in let _ = trytac (fun () -> apply (`lemma_from_squash); intro ()) in smt ()
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.skolem
val skolem : _: Prims.unit -> FStar.Tactics.Effect.Tac (Prims.list (FStar.Stubs.Reflection.Types.binders * FStar.Stubs.Reflection.Types.binder))
let skolem () = let bs = binders_of_env (cur_env ()) in map sk_binder bs
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 18, "end_line": 312, "start_col": 0, "start_line": 310 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. *) let unsquash (t:term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack_ln (Tv_Var (bv_of_binder b)) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1) let right () : Tac unit = apply_lemma (`or_intro_2) private val __and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim #p #q #phi p_and_q f = () private val __and_elim' : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim' #p #q #phi p_and_q f = () let and_elim (t : term) : Tac unit = begin try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t))) end let destruct_and (t : term) : Tac (binder * binder) = and_elim t; (implies_intro (), implies_intro ()) private val __witness : (#a:Type) -> (x:a) -> (#p:(a -> Type)) -> squash (p x) -> squash (exists (x:a). p x) private let __witness #a x #p _ = () let witness (t : term) : Tac unit = apply_raw (`__witness); exact t private let __elim_exists' #t (#pred : t -> Type0) #goal (h : (exists x. pred x)) (k : (x:t -> pred x -> squash goal)) : squash goal = FStar.Squash.bind_squash #(x:t & pred x) h (fun (|x, pf|) -> k x pf) (* returns witness and proof as binders *) let elim_exists (t : term) : Tac (binder & binder) = apply_lemma (`(__elim_exists' (`#(t)))); let x = intro () in let pf = intro () in (x, pf) private let __forall_inst #t (#pred : t -> Type0) (h : (forall x. pred x)) (x : t) : squash (pred x) = () (* GM: annoying that this doesn't just work by SMT *) private let __forall_inst_sq #t (#pred : t -> Type0) (h : squash (forall x. pred x)) (x : t) : squash (pred x) = FStar.Squash.bind_squash h (fun (f : (forall x. pred x)) -> __forall_inst f x) let instantiate (fa : term) (x : term) : Tac binder = try pose (`__forall_inst_sq (`#fa) (`#x)) with | _ -> try pose (`__forall_inst (`#fa) (`#x)) with | _ -> fail "could not instantiate" let instantiate_as (fa : term) (x : term) (s : string) : Tac binder = let b = instantiate fa x in rename_to b s private let sklem0 (#a:Type) (#p : a -> Type0) ($v : (exists (x:a). p x)) (phi:Type0) : Lemma (requires (forall x. p x ==> phi)) (ensures phi) = () private let rec sk_binder' (acc:binders) (b:binder) : Tac (binders * binder) = focus (fun () -> try apply_lemma (`(sklem0 (`#(binder_to_term b)))); if ngoals () <> 1 then fail "no"; clear b; let bx = forall_intro () in let b' = implies_intro () in sk_binder' (bx::acc) b' (* We might have introduced a new existential, so possibly recurse *) with | _ -> (acc, b) (* If the above failed, just return *) ) (* Skolemizes a given binder for an existential, returning the introduced new binders * and the skolemized formula. *) let sk_binder b = sk_binder' [] b
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Tactics.Effect.Tac (Prims.list (FStar.Stubs.Reflection.Types.binders * FStar.Stubs.Reflection.Types.binder))
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.unit", "FStar.Tactics.Util.map", "FStar.Stubs.Reflection.Types.binder", "FStar.Pervasives.Native.tuple2", "FStar.Stubs.Reflection.Types.binders", "FStar.Tactics.V1.Logic.sk_binder", "Prims.list", "FStar.Stubs.Reflection.V1.Builtins.binders_of_env", "FStar.Stubs.Reflection.Types.env", "FStar.Tactics.V1.Derived.cur_env" ]
[]
false
true
false
false
false
let skolem () =
let bs = binders_of_env (cur_env ()) in map sk_binder bs
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.sk_binder'
val sk_binder' (acc: binders) (b: binder) : Tac (binders * binder)
val sk_binder' (acc: binders) (b: binder) : Tac (binders * binder)
let rec sk_binder' (acc:binders) (b:binder) : Tac (binders * binder) = focus (fun () -> try apply_lemma (`(sklem0 (`#(binder_to_term b)))); if ngoals () <> 1 then fail "no"; clear b; let bx = forall_intro () in let b' = implies_intro () in sk_binder' (bx::acc) b' (* We might have introduced a new existential, so possibly recurse *) with | _ -> (acc, b) (* If the above failed, just return *) )
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 3, "end_line": 304, "start_col": 0, "start_line": 294 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. *) let unsquash (t:term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack_ln (Tv_Var (bv_of_binder b)) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1) let right () : Tac unit = apply_lemma (`or_intro_2) private val __and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim #p #q #phi p_and_q f = () private val __and_elim' : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim' #p #q #phi p_and_q f = () let and_elim (t : term) : Tac unit = begin try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t))) end let destruct_and (t : term) : Tac (binder * binder) = and_elim t; (implies_intro (), implies_intro ()) private val __witness : (#a:Type) -> (x:a) -> (#p:(a -> Type)) -> squash (p x) -> squash (exists (x:a). p x) private let __witness #a x #p _ = () let witness (t : term) : Tac unit = apply_raw (`__witness); exact t private let __elim_exists' #t (#pred : t -> Type0) #goal (h : (exists x. pred x)) (k : (x:t -> pred x -> squash goal)) : squash goal = FStar.Squash.bind_squash #(x:t & pred x) h (fun (|x, pf|) -> k x pf) (* returns witness and proof as binders *) let elim_exists (t : term) : Tac (binder & binder) = apply_lemma (`(__elim_exists' (`#(t)))); let x = intro () in let pf = intro () in (x, pf) private let __forall_inst #t (#pred : t -> Type0) (h : (forall x. pred x)) (x : t) : squash (pred x) = () (* GM: annoying that this doesn't just work by SMT *) private let __forall_inst_sq #t (#pred : t -> Type0) (h : squash (forall x. pred x)) (x : t) : squash (pred x) = FStar.Squash.bind_squash h (fun (f : (forall x. pred x)) -> __forall_inst f x) let instantiate (fa : term) (x : term) : Tac binder = try pose (`__forall_inst_sq (`#fa) (`#x)) with | _ -> try pose (`__forall_inst (`#fa) (`#x)) with | _ -> fail "could not instantiate" let instantiate_as (fa : term) (x : term) (s : string) : Tac binder = let b = instantiate fa x in rename_to b s private let sklem0 (#a:Type) (#p : a -> Type0) ($v : (exists (x:a). p x)) (phi:Type0) : Lemma (requires (forall x. p x ==> phi)) (ensures phi) = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
acc: FStar.Stubs.Reflection.Types.binders -> b: FStar.Stubs.Reflection.Types.binder -> FStar.Tactics.Effect.Tac (FStar.Stubs.Reflection.Types.binders * FStar.Stubs.Reflection.Types.binder)
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.binders", "FStar.Stubs.Reflection.Types.binder", "FStar.Tactics.V1.Derived.focus", "FStar.Pervasives.Native.tuple2", "Prims.unit", "FStar.Tactics.V1.Derived.try_with", "FStar.Tactics.V1.Logic.sk_binder'", "Prims.Cons", "FStar.Tactics.V1.Logic.implies_intro", "FStar.Tactics.V1.Logic.forall_intro", "FStar.Stubs.Tactics.V1.Builtins.clear", "FStar.Tactics.V1.Derived.fail", "Prims.bool", "Prims.op_disEquality", "Prims.int", "FStar.Tactics.V1.Derived.ngoals", "FStar.Tactics.V1.Derived.apply_lemma", "FStar.Stubs.Reflection.Types.term", "FStar.Tactics.V1.Derived.binder_to_term", "Prims.exn", "FStar.Pervasives.Native.Mktuple2" ]
[ "recursion" ]
false
true
false
false
false
let rec sk_binder' (acc: binders) (b: binder) : Tac (binders * binder) =
focus (fun () -> try (apply_lemma (`(sklem0 (`#(binder_to_term b)))); if ngoals () <> 1 then fail "no"; clear b; let bx = forall_intro () in let b' = implies_intro () in sk_binder' (bx :: acc) b') with | _ -> (acc, b))
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.sk_binder
val sk_binder : b: FStar.Stubs.Reflection.Types.binder -> FStar.Tactics.Effect.Tac (FStar.Stubs.Reflection.Types.binders * FStar.Stubs.Reflection.Types.binder)
let sk_binder b = sk_binder' [] b
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 33, "end_line": 308, "start_col": 0, "start_line": 308 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. *) let unsquash (t:term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack_ln (Tv_Var (bv_of_binder b)) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1) let right () : Tac unit = apply_lemma (`or_intro_2) private val __and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim #p #q #phi p_and_q f = () private val __and_elim' : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim' #p #q #phi p_and_q f = () let and_elim (t : term) : Tac unit = begin try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t))) end let destruct_and (t : term) : Tac (binder * binder) = and_elim t; (implies_intro (), implies_intro ()) private val __witness : (#a:Type) -> (x:a) -> (#p:(a -> Type)) -> squash (p x) -> squash (exists (x:a). p x) private let __witness #a x #p _ = () let witness (t : term) : Tac unit = apply_raw (`__witness); exact t private let __elim_exists' #t (#pred : t -> Type0) #goal (h : (exists x. pred x)) (k : (x:t -> pred x -> squash goal)) : squash goal = FStar.Squash.bind_squash #(x:t & pred x) h (fun (|x, pf|) -> k x pf) (* returns witness and proof as binders *) let elim_exists (t : term) : Tac (binder & binder) = apply_lemma (`(__elim_exists' (`#(t)))); let x = intro () in let pf = intro () in (x, pf) private let __forall_inst #t (#pred : t -> Type0) (h : (forall x. pred x)) (x : t) : squash (pred x) = () (* GM: annoying that this doesn't just work by SMT *) private let __forall_inst_sq #t (#pred : t -> Type0) (h : squash (forall x. pred x)) (x : t) : squash (pred x) = FStar.Squash.bind_squash h (fun (f : (forall x. pred x)) -> __forall_inst f x) let instantiate (fa : term) (x : term) : Tac binder = try pose (`__forall_inst_sq (`#fa) (`#x)) with | _ -> try pose (`__forall_inst (`#fa) (`#x)) with | _ -> fail "could not instantiate" let instantiate_as (fa : term) (x : term) (s : string) : Tac binder = let b = instantiate fa x in rename_to b s private let sklem0 (#a:Type) (#p : a -> Type0) ($v : (exists (x:a). p x)) (phi:Type0) : Lemma (requires (forall x. p x ==> phi)) (ensures phi) = () private let rec sk_binder' (acc:binders) (b:binder) : Tac (binders * binder) = focus (fun () -> try apply_lemma (`(sklem0 (`#(binder_to_term b)))); if ngoals () <> 1 then fail "no"; clear b; let bx = forall_intro () in let b' = implies_intro () in sk_binder' (bx::acc) b' (* We might have introduced a new existential, so possibly recurse *) with | _ -> (acc, b) (* If the above failed, just return *) ) (* Skolemizes a given binder for an existential, returning the introduced new binders
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Stubs.Reflection.Types.binder -> FStar.Tactics.Effect.Tac (FStar.Stubs.Reflection.Types.binders * FStar.Stubs.Reflection.Types.binder)
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.binder", "FStar.Tactics.V1.Logic.sk_binder'", "Prims.Nil", "FStar.Pervasives.Native.tuple2", "FStar.Stubs.Reflection.Types.binders" ]
[]
false
true
false
false
false
let sk_binder b =
sk_binder' [] b
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.using_lemma
val using_lemma (t: term) : Tac binder
val using_lemma (t: term) : Tac binder
let using_lemma (t : term) : Tac binder = try pose_lemma (`(lem1_fa (`#t))) with | _ -> try pose_lemma (`(lem2_fa (`#t))) with | _ -> try pose_lemma (`(lem3_fa (`#t))) with | _ -> fail #binder "using_lemma: failed to instantiate"
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 51, "end_line": 364, "start_col": 0, "start_line": 360 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. *) let unsquash (t:term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack_ln (Tv_Var (bv_of_binder b)) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1) let right () : Tac unit = apply_lemma (`or_intro_2) private val __and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim #p #q #phi p_and_q f = () private val __and_elim' : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim' #p #q #phi p_and_q f = () let and_elim (t : term) : Tac unit = begin try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t))) end let destruct_and (t : term) : Tac (binder * binder) = and_elim t; (implies_intro (), implies_intro ()) private val __witness : (#a:Type) -> (x:a) -> (#p:(a -> Type)) -> squash (p x) -> squash (exists (x:a). p x) private let __witness #a x #p _ = () let witness (t : term) : Tac unit = apply_raw (`__witness); exact t private let __elim_exists' #t (#pred : t -> Type0) #goal (h : (exists x. pred x)) (k : (x:t -> pred x -> squash goal)) : squash goal = FStar.Squash.bind_squash #(x:t & pred x) h (fun (|x, pf|) -> k x pf) (* returns witness and proof as binders *) let elim_exists (t : term) : Tac (binder & binder) = apply_lemma (`(__elim_exists' (`#(t)))); let x = intro () in let pf = intro () in (x, pf) private let __forall_inst #t (#pred : t -> Type0) (h : (forall x. pred x)) (x : t) : squash (pred x) = () (* GM: annoying that this doesn't just work by SMT *) private let __forall_inst_sq #t (#pred : t -> Type0) (h : squash (forall x. pred x)) (x : t) : squash (pred x) = FStar.Squash.bind_squash h (fun (f : (forall x. pred x)) -> __forall_inst f x) let instantiate (fa : term) (x : term) : Tac binder = try pose (`__forall_inst_sq (`#fa) (`#x)) with | _ -> try pose (`__forall_inst (`#fa) (`#x)) with | _ -> fail "could not instantiate" let instantiate_as (fa : term) (x : term) (s : string) : Tac binder = let b = instantiate fa x in rename_to b s private let sklem0 (#a:Type) (#p : a -> Type0) ($v : (exists (x:a). p x)) (phi:Type0) : Lemma (requires (forall x. p x ==> phi)) (ensures phi) = () private let rec sk_binder' (acc:binders) (b:binder) : Tac (binders * binder) = focus (fun () -> try apply_lemma (`(sklem0 (`#(binder_to_term b)))); if ngoals () <> 1 then fail "no"; clear b; let bx = forall_intro () in let b' = implies_intro () in sk_binder' (bx::acc) b' (* We might have introduced a new existential, so possibly recurse *) with | _ -> (acc, b) (* If the above failed, just return *) ) (* Skolemizes a given binder for an existential, returning the introduced new binders * and the skolemized formula. *) let sk_binder b = sk_binder' [] b let skolem () = let bs = binders_of_env (cur_env ()) in map sk_binder bs private val lemma_from_squash : #a:Type -> #b:(a -> Type) -> (x:a -> squash (b x)) -> x:a -> Lemma (b x) private let lemma_from_squash #a #b f x = let _ = f x in assert (b x) private let easy_fill () = let _ = repeat intro in (* If the goal is `a -> Lemma b`, intro will fail, try to use this switch *) let _ = trytac (fun () -> apply (`lemma_from_squash); intro ()) in smt () val easy : #a:Type -> (#[easy_fill ()] _ : a) -> a let easy #a #x = x private let lem1_fa #a #pre #post ($lem : (x:a -> Lemma (requires pre x) (ensures post x))) : Lemma (forall (x:a). pre x ==> post x) = let l' x : Lemma (pre x ==> post x) = Classical.move_requires lem x in Classical.forall_intro l' private let lem2_fa #a #b #pre #post ($lem : (x:a -> y:b -> Lemma (requires pre x y) (ensures post x y))) : Lemma (forall (x:a) (y:b). pre x y ==> post x y) = let l' x y : Lemma (pre x y ==> post x y) = Classical.move_requires (lem x) y in Classical.forall_intro_2 l' private let lem3_fa #a #b #c #pre #post ($lem : (x:a -> y:b -> z:c -> Lemma (requires pre x y z) (ensures post x y z))) : Lemma (forall (x:a) (y:b) (z:c). pre x y z ==> post x y z) = let l' x y z : Lemma (pre x y z ==> post x y z) = Classical.move_requires (lem x y) z in Classical.forall_intro_3 l' (** Add a lemma into the local context, quantified for all arguments. Only works for lemmas with up to 3 arguments for now. It is expected that `t` is a top-level name, this has not been battle-tested for other
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac FStar.Stubs.Reflection.Types.binder
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Tactics.V1.Derived.try_with", "FStar.Stubs.Reflection.Types.binder", "Prims.unit", "FStar.Tactics.V1.Logic.pose_lemma", "Prims.exn", "FStar.Tactics.V1.Derived.fail" ]
[]
false
true
false
false
false
let using_lemma (t: term) : Tac binder =
try pose_lemma (`(lem1_fa (`#t))) with | _ -> try pose_lemma (`(lem2_fa (`#t))) with | _ -> try pose_lemma (`(lem3_fa (`#t))) with | _ -> fail #binder "using_lemma: failed to instantiate"
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.lem3_fa
val lem3_fa (#a #b #c #pre #post: _) ($lem: (x: a -> y: b -> z: c -> Lemma (requires pre x y z) (ensures post x y z))) : Lemma (forall (x: a) (y: b) (z: c). pre x y z ==> post x y z)
val lem3_fa (#a #b #c #pre #post: _) ($lem: (x: a -> y: b -> z: c -> Lemma (requires pre x y z) (ensures post x y z))) : Lemma (forall (x: a) (y: b) (z: c). pre x y z ==> post x y z)
let lem3_fa #a #b #c #pre #post ($lem : (x:a -> y:b -> z:c -> Lemma (requires pre x y z) (ensures post x y z))) : Lemma (forall (x:a) (y:b) (z:c). pre x y z ==> post x y z) = let l' x y z : Lemma (pre x y z ==> post x y z) = Classical.move_requires (lem x y) z in Classical.forall_intro_3 l'
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 29, "end_line": 354, "start_col": 0, "start_line": 348 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. *) let unsquash (t:term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack_ln (Tv_Var (bv_of_binder b)) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1) let right () : Tac unit = apply_lemma (`or_intro_2) private val __and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim #p #q #phi p_and_q f = () private val __and_elim' : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim' #p #q #phi p_and_q f = () let and_elim (t : term) : Tac unit = begin try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t))) end let destruct_and (t : term) : Tac (binder * binder) = and_elim t; (implies_intro (), implies_intro ()) private val __witness : (#a:Type) -> (x:a) -> (#p:(a -> Type)) -> squash (p x) -> squash (exists (x:a). p x) private let __witness #a x #p _ = () let witness (t : term) : Tac unit = apply_raw (`__witness); exact t private let __elim_exists' #t (#pred : t -> Type0) #goal (h : (exists x. pred x)) (k : (x:t -> pred x -> squash goal)) : squash goal = FStar.Squash.bind_squash #(x:t & pred x) h (fun (|x, pf|) -> k x pf) (* returns witness and proof as binders *) let elim_exists (t : term) : Tac (binder & binder) = apply_lemma (`(__elim_exists' (`#(t)))); let x = intro () in let pf = intro () in (x, pf) private let __forall_inst #t (#pred : t -> Type0) (h : (forall x. pred x)) (x : t) : squash (pred x) = () (* GM: annoying that this doesn't just work by SMT *) private let __forall_inst_sq #t (#pred : t -> Type0) (h : squash (forall x. pred x)) (x : t) : squash (pred x) = FStar.Squash.bind_squash h (fun (f : (forall x. pred x)) -> __forall_inst f x) let instantiate (fa : term) (x : term) : Tac binder = try pose (`__forall_inst_sq (`#fa) (`#x)) with | _ -> try pose (`__forall_inst (`#fa) (`#x)) with | _ -> fail "could not instantiate" let instantiate_as (fa : term) (x : term) (s : string) : Tac binder = let b = instantiate fa x in rename_to b s private let sklem0 (#a:Type) (#p : a -> Type0) ($v : (exists (x:a). p x)) (phi:Type0) : Lemma (requires (forall x. p x ==> phi)) (ensures phi) = () private let rec sk_binder' (acc:binders) (b:binder) : Tac (binders * binder) = focus (fun () -> try apply_lemma (`(sklem0 (`#(binder_to_term b)))); if ngoals () <> 1 then fail "no"; clear b; let bx = forall_intro () in let b' = implies_intro () in sk_binder' (bx::acc) b' (* We might have introduced a new existential, so possibly recurse *) with | _ -> (acc, b) (* If the above failed, just return *) ) (* Skolemizes a given binder for an existential, returning the introduced new binders * and the skolemized formula. *) let sk_binder b = sk_binder' [] b let skolem () = let bs = binders_of_env (cur_env ()) in map sk_binder bs private val lemma_from_squash : #a:Type -> #b:(a -> Type) -> (x:a -> squash (b x)) -> x:a -> Lemma (b x) private let lemma_from_squash #a #b f x = let _ = f x in assert (b x) private let easy_fill () = let _ = repeat intro in (* If the goal is `a -> Lemma b`, intro will fail, try to use this switch *) let _ = trytac (fun () -> apply (`lemma_from_squash); intro ()) in smt () val easy : #a:Type -> (#[easy_fill ()] _ : a) -> a let easy #a #x = x private let lem1_fa #a #pre #post ($lem : (x:a -> Lemma (requires pre x) (ensures post x))) : Lemma (forall (x:a). pre x ==> post x) = let l' x : Lemma (pre x ==> post x) = Classical.move_requires lem x in Classical.forall_intro l' private let lem2_fa #a #b #pre #post ($lem : (x:a -> y:b -> Lemma (requires pre x y) (ensures post x y))) : Lemma (forall (x:a) (y:b). pre x y ==> post x y) = let l' x y : Lemma (pre x y ==> post x y) = Classical.move_requires (lem x) y in Classical.forall_intro_2 l'
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$lem: (x: a -> y: b -> z: c -> FStar.Pervasives.Lemma (requires pre x y z) (ensures post x y z)) -> FStar.Pervasives.Lemma (ensures forall (x: a) (y: b) (z: c). pre x y z ==> post x y z)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Classical.forall_intro_3", "Prims.l_imp", "Prims.l_True", "FStar.Classical.move_requires", "Prims.l_Forall" ]
[]
false
false
true
false
false
let lem3_fa #a #b #c #pre #post ($lem: (x: a -> y: b -> z: c -> Lemma (requires pre x y z) (ensures post x y z))) : Lemma (forall (x: a) (y: b) (z: c). pre x y z ==> post x y z) =
let l' x y z : Lemma (pre x y z ==> post x y z) = Classical.move_requires (lem x y) z in Classical.forall_intro_3 l'
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.lem1_fa
val lem1_fa (#a #pre #post: _) ($lem: (x: a -> Lemma (requires pre x) (ensures post x))) : Lemma (forall (x: a). pre x ==> post x)
val lem1_fa (#a #pre #post: _) ($lem: (x: a -> Lemma (requires pre x) (ensures post x))) : Lemma (forall (x: a). pre x ==> post x)
let lem1_fa #a #pre #post ($lem : (x:a -> Lemma (requires pre x) (ensures post x))) : Lemma (forall (x:a). pre x ==> post x) = let l' x : Lemma (pre x ==> post x) = Classical.move_requires lem x in Classical.forall_intro l'
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 27, "end_line": 336, "start_col": 0, "start_line": 330 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. *) let unsquash (t:term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack_ln (Tv_Var (bv_of_binder b)) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1) let right () : Tac unit = apply_lemma (`or_intro_2) private val __and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim #p #q #phi p_and_q f = () private val __and_elim' : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim' #p #q #phi p_and_q f = () let and_elim (t : term) : Tac unit = begin try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t))) end let destruct_and (t : term) : Tac (binder * binder) = and_elim t; (implies_intro (), implies_intro ()) private val __witness : (#a:Type) -> (x:a) -> (#p:(a -> Type)) -> squash (p x) -> squash (exists (x:a). p x) private let __witness #a x #p _ = () let witness (t : term) : Tac unit = apply_raw (`__witness); exact t private let __elim_exists' #t (#pred : t -> Type0) #goal (h : (exists x. pred x)) (k : (x:t -> pred x -> squash goal)) : squash goal = FStar.Squash.bind_squash #(x:t & pred x) h (fun (|x, pf|) -> k x pf) (* returns witness and proof as binders *) let elim_exists (t : term) : Tac (binder & binder) = apply_lemma (`(__elim_exists' (`#(t)))); let x = intro () in let pf = intro () in (x, pf) private let __forall_inst #t (#pred : t -> Type0) (h : (forall x. pred x)) (x : t) : squash (pred x) = () (* GM: annoying that this doesn't just work by SMT *) private let __forall_inst_sq #t (#pred : t -> Type0) (h : squash (forall x. pred x)) (x : t) : squash (pred x) = FStar.Squash.bind_squash h (fun (f : (forall x. pred x)) -> __forall_inst f x) let instantiate (fa : term) (x : term) : Tac binder = try pose (`__forall_inst_sq (`#fa) (`#x)) with | _ -> try pose (`__forall_inst (`#fa) (`#x)) with | _ -> fail "could not instantiate" let instantiate_as (fa : term) (x : term) (s : string) : Tac binder = let b = instantiate fa x in rename_to b s private let sklem0 (#a:Type) (#p : a -> Type0) ($v : (exists (x:a). p x)) (phi:Type0) : Lemma (requires (forall x. p x ==> phi)) (ensures phi) = () private let rec sk_binder' (acc:binders) (b:binder) : Tac (binders * binder) = focus (fun () -> try apply_lemma (`(sklem0 (`#(binder_to_term b)))); if ngoals () <> 1 then fail "no"; clear b; let bx = forall_intro () in let b' = implies_intro () in sk_binder' (bx::acc) b' (* We might have introduced a new existential, so possibly recurse *) with | _ -> (acc, b) (* If the above failed, just return *) ) (* Skolemizes a given binder for an existential, returning the introduced new binders * and the skolemized formula. *) let sk_binder b = sk_binder' [] b let skolem () = let bs = binders_of_env (cur_env ()) in map sk_binder bs private val lemma_from_squash : #a:Type -> #b:(a -> Type) -> (x:a -> squash (b x)) -> x:a -> Lemma (b x) private let lemma_from_squash #a #b f x = let _ = f x in assert (b x) private let easy_fill () = let _ = repeat intro in (* If the goal is `a -> Lemma b`, intro will fail, try to use this switch *) let _ = trytac (fun () -> apply (`lemma_from_squash); intro ()) in smt () val easy : #a:Type -> (#[easy_fill ()] _ : a) -> a let easy #a #x = x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$lem: (x: a -> FStar.Pervasives.Lemma (requires pre x) (ensures post x)) -> FStar.Pervasives.Lemma (ensures forall (x: a). pre x ==> post x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Classical.forall_intro", "Prims.l_imp", "Prims.l_True", "FStar.Classical.move_requires", "Prims.l_Forall" ]
[]
false
false
true
false
false
let lem1_fa #a #pre #post ($lem: (x: a -> Lemma (requires pre x) (ensures post x))) : Lemma (forall (x: a). pre x ==> post x) =
let l' x : Lemma (pre x ==> post x) = Classical.move_requires lem x in Classical.forall_intro l'
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.vbind
val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q
val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q
let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f)
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 95, "end_line": 187, "start_col": 0, "start_line": 187 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
sq: Prims.squash p -> f: (_: p -> Prims.squash q) -> FStar.Pervasives.Lemma (ensures q)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.squash", "FStar.Classical.give_witness_from_squash", "FStar.Squash.bind_squash", "Prims.unit" ]
[]
true
false
true
false
false
let vbind #p #q sq f =
FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f)
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.simplify_eq_implication
val simplify_eq_implication: Prims.unit -> Tac unit
val simplify_eq_implication: Prims.unit -> Tac unit
let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 37, "end_line": 163, "start_col": 0, "start_line": 152 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) )
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.unit", "FStar.Tactics.V1.Derived.fail", "FStar.Reflection.V1.Formula.formula", "FStar.Stubs.Reflection.Types.term", "FStar.Tactics.V1.Logic.visit", "FStar.Tactics.V1.Logic.simplify_eq_implication", "FStar.Stubs.Tactics.V1.Builtins.clear_top", "FStar.Stubs.Tactics.V1.Builtins.rewrite", "FStar.Stubs.Reflection.Types.binder", "FStar.Tactics.V1.Logic.implies_intro", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "FStar.Tactics.V1.Derived.destruct_equality_implication", "FStar.Stubs.Reflection.Types.typ", "FStar.Tactics.V1.Derived.cur_goal", "FStar.Stubs.Reflection.Types.env", "FStar.Tactics.V1.Derived.cur_env" ]
[ "recursion" ]
false
true
false
false
false
let rec simplify_eq_implication () : Tac unit =
let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit simplify_eq_implication
false
LowStar.Lens.fst
LowStar.Lens.mods
val mods (l:hs_lens 'a 'b) (h:HS.mem) : Type0
val mods (l:hs_lens 'a 'b) (h:HS.mem) : Type0
let mods (l:hs_lens 'a 'b) (h:HS.mem) = B.modifies (as_loc l.footprint) l.snapshot h /\ FStar.HyperStack.ST.equal_domains l.snapshot h
{ "file_name": "examples/data_structures/LowStar.Lens.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 48, "end_line": 24, "start_col": 0, "start_line": 22 }
(* 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 LowStar.Lens open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack module HST = FStar.HyperStack.ST
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "LowStar.Lens.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
l: LowStar.Lens.hs_lens 'a 'b -> h: FStar.Monotonic.HyperStack.mem -> Type0
Prims.Tot
[ "total" ]
[]
[ "LowStar.Lens.hs_lens", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "LowStar.Monotonic.Buffer.modifies", "LowStar.Lens.as_loc", "LowStar.Lens.__proj__Mkhs_lens__item__footprint", "LowStar.Lens.__proj__Mkhs_lens__item__snapshot", "FStar.HyperStack.ST.equal_domains" ]
[]
false
false
false
true
true
let mods (l: hs_lens 'a 'b) (h: HS.mem) =
B.modifies (as_loc l.footprint) l.snapshot h /\ FStar.HyperStack.ST.equal_domains l.snapshot h
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.lem2_fa
val lem2_fa (#a #b #pre #post: _) ($lem: (x: a -> y: b -> Lemma (requires pre x y) (ensures post x y))) : Lemma (forall (x: a) (y: b). pre x y ==> post x y)
val lem2_fa (#a #b #pre #post: _) ($lem: (x: a -> y: b -> Lemma (requires pre x y) (ensures post x y))) : Lemma (forall (x: a) (y: b). pre x y ==> post x y)
let lem2_fa #a #b #pre #post ($lem : (x:a -> y:b -> Lemma (requires pre x y) (ensures post x y))) : Lemma (forall (x:a) (y:b). pre x y ==> post x y) = let l' x y : Lemma (pre x y ==> post x y) = Classical.move_requires (lem x) y in Classical.forall_intro_2 l'
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 29, "end_line": 345, "start_col": 0, "start_line": 339 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. *) let unsquash (t:term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack_ln (Tv_Var (bv_of_binder b)) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1) let right () : Tac unit = apply_lemma (`or_intro_2) private val __and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim #p #q #phi p_and_q f = () private val __and_elim' : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim' #p #q #phi p_and_q f = () let and_elim (t : term) : Tac unit = begin try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t))) end let destruct_and (t : term) : Tac (binder * binder) = and_elim t; (implies_intro (), implies_intro ()) private val __witness : (#a:Type) -> (x:a) -> (#p:(a -> Type)) -> squash (p x) -> squash (exists (x:a). p x) private let __witness #a x #p _ = () let witness (t : term) : Tac unit = apply_raw (`__witness); exact t private let __elim_exists' #t (#pred : t -> Type0) #goal (h : (exists x. pred x)) (k : (x:t -> pred x -> squash goal)) : squash goal = FStar.Squash.bind_squash #(x:t & pred x) h (fun (|x, pf|) -> k x pf) (* returns witness and proof as binders *) let elim_exists (t : term) : Tac (binder & binder) = apply_lemma (`(__elim_exists' (`#(t)))); let x = intro () in let pf = intro () in (x, pf) private let __forall_inst #t (#pred : t -> Type0) (h : (forall x. pred x)) (x : t) : squash (pred x) = () (* GM: annoying that this doesn't just work by SMT *) private let __forall_inst_sq #t (#pred : t -> Type0) (h : squash (forall x. pred x)) (x : t) : squash (pred x) = FStar.Squash.bind_squash h (fun (f : (forall x. pred x)) -> __forall_inst f x) let instantiate (fa : term) (x : term) : Tac binder = try pose (`__forall_inst_sq (`#fa) (`#x)) with | _ -> try pose (`__forall_inst (`#fa) (`#x)) with | _ -> fail "could not instantiate" let instantiate_as (fa : term) (x : term) (s : string) : Tac binder = let b = instantiate fa x in rename_to b s private let sklem0 (#a:Type) (#p : a -> Type0) ($v : (exists (x:a). p x)) (phi:Type0) : Lemma (requires (forall x. p x ==> phi)) (ensures phi) = () private let rec sk_binder' (acc:binders) (b:binder) : Tac (binders * binder) = focus (fun () -> try apply_lemma (`(sklem0 (`#(binder_to_term b)))); if ngoals () <> 1 then fail "no"; clear b; let bx = forall_intro () in let b' = implies_intro () in sk_binder' (bx::acc) b' (* We might have introduced a new existential, so possibly recurse *) with | _ -> (acc, b) (* If the above failed, just return *) ) (* Skolemizes a given binder for an existential, returning the introduced new binders * and the skolemized formula. *) let sk_binder b = sk_binder' [] b let skolem () = let bs = binders_of_env (cur_env ()) in map sk_binder bs private val lemma_from_squash : #a:Type -> #b:(a -> Type) -> (x:a -> squash (b x)) -> x:a -> Lemma (b x) private let lemma_from_squash #a #b f x = let _ = f x in assert (b x) private let easy_fill () = let _ = repeat intro in (* If the goal is `a -> Lemma b`, intro will fail, try to use this switch *) let _ = trytac (fun () -> apply (`lemma_from_squash); intro ()) in smt () val easy : #a:Type -> (#[easy_fill ()] _ : a) -> a let easy #a #x = x private let lem1_fa #a #pre #post ($lem : (x:a -> Lemma (requires pre x) (ensures post x))) : Lemma (forall (x:a). pre x ==> post x) = let l' x : Lemma (pre x ==> post x) = Classical.move_requires lem x in Classical.forall_intro l'
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$lem: (x: a -> y: b -> FStar.Pervasives.Lemma (requires pre x y) (ensures post x y)) -> FStar.Pervasives.Lemma (ensures forall (x: a) (y: b). pre x y ==> post x y)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Classical.forall_intro_2", "Prims.l_imp", "Prims.l_True", "FStar.Classical.move_requires", "Prims.l_Forall" ]
[]
false
false
true
false
false
let lem2_fa #a #b #pre #post ($lem: (x: a -> y: b -> Lemma (requires pre x y) (ensures post x y))) : Lemma (forall (x: a) (y: b). pre x y ==> post x y) =
let l' x y : Lemma (pre x y ==> post x y) = Classical.move_requires (lem x) y in Classical.forall_intro_2 l'
false
LowStar.Lens.fst
LowStar.Lens.inv
val inv (#roots:_) (#view:_) (l:hs_lens roots view) (h:HS.mem) : Type0
val inv (#roots:_) (#view:_) (l:hs_lens roots view) (h:HS.mem) : Type0
let inv #roots #view (l:hs_lens roots view) (h:HS.mem) = l.invariant l.x h /\ mods l h
{ "file_name": "examples/data_structures/LowStar.Lens.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 10, "end_line": 28, "start_col": 0, "start_line": 26 }
(* 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 LowStar.Lens open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack module HST = FStar.HyperStack.ST let mods (l:hs_lens 'a 'b) (h:HS.mem) = B.modifies (as_loc l.footprint) l.snapshot h /\ FStar.HyperStack.ST.equal_domains l.snapshot h
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "LowStar.Lens.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
l: LowStar.Lens.hs_lens roots view -> h: FStar.Monotonic.HyperStack.mem -> Type0
Prims.Tot
[ "total" ]
[]
[ "LowStar.Lens.hs_lens", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "LowStar.Lens.__proj__Mkhs_lens__item__invariant", "LowStar.Lens.__proj__Mkhs_lens__item__x", "LowStar.Lens.mods" ]
[]
false
false
false
true
true
let inv #roots #view (l: hs_lens roots view) (h: HS.mem) =
l.invariant l.x h /\ mods l h
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.unfold_definition_and_simplify_eq
val unfold_definition_and_simplify_eq (tm: term) : Tac unit
val unfold_definition_and_simplify_eq (tm: term) : Tac unit
let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 11, "end_line": 184, "start_col": 0, "start_line": 168 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
tm: FStar.Stubs.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V1.Builtins.term_eq", "FStar.Tactics.V1.Derived.trivial", "Prims.unit", "Prims.bool", "FStar.Reflection.V1.Formula.formula", "FStar.Tactics.V1.Derived.fail", "FStar.Tactics.V1.Logic.visit", "FStar.Tactics.V1.Logic.unfold_definition_and_simplify_eq", "FStar.Stubs.Tactics.V1.Builtins.clear_top", "FStar.Stubs.Tactics.V1.Builtins.rewrite", "FStar.Stubs.Reflection.Types.binder", "FStar.Tactics.V1.Logic.implies_intro", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "FStar.Tactics.V1.Derived.destruct_equality_implication", "FStar.Reflection.V1.Formula.term_as_formula", "FStar.Stubs.Reflection.Types.typ", "FStar.Tactics.V1.Derived.cur_goal" ]
[ "recursion" ]
false
true
false
false
false
let rec unfold_definition_and_simplify_eq (tm: term) : Tac unit =
let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () | _ -> let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm)
false
ProgramOptimizations.fst
ProgramOptimizations.com12
val com12 : ProgramOptimizations.com
let com12 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (Var x))
{ "file_name": "examples/rel/ProgramOptimizations.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 34, "end_line": 160, "start_col": 0, "start_line": 159 }
(* 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 ProgramOptimizations open FStar.DM4F.Heap.IntStoreFixed open FStar.DM4F.IntStoreFixed (* * language and examples from: * "Simple Relational Correctness Proofs for Static Analyses and Program Transformations" * https://research.microsoft.com/en-us/um/people/nick/correctnesspopl2004.pdf *) type var = id type i_op = | Add | Sub type i_exp = | Const : int -> i_exp | Var : id -> i_exp | IOp : i_op -> i_exp -> i_exp -> i_exp | UMinus: i_exp -> i_exp type r_op = | Lt | Gt | Eq type b_op = | And | Or type b_exp = | CTrue : b_exp | CFalse: b_exp | ROp : r_op -> i_exp -> i_exp -> b_exp | BOp : b_op -> b_exp -> b_exp -> b_exp | Not : b_exp -> b_exp type com = | Skip : com | Assign: var -> i_exp -> com | Seq : com -> com -> com | If : b_exp -> com -> com -> com let rec i_exp_denotation (e:i_exp) :ISNull int = match e with | Const n -> n | Var r -> !r | IOp op e1 e2 -> (let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in match op with | Add -> n1 + n2 | Sub -> n1 - n2) | UMinus e -> - (i_exp_denotation e) let rec b_exp_denotation (b:b_exp) :ISNull bool = match b with | CTrue -> true | CFalse -> false | ROp op e1 e2 -> let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | BOp op b1 b2 -> let bc1 = b_exp_denotation b1 in let bc2 = b_exp_denotation b2 in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | Not b -> not (b_exp_denotation b) let rec com_denotation (c:com) :ISNull unit = match c with | Skip -> () | Assign r e -> let n = i_exp_denotation e in write r n (* r := n does not work, as it goes to FStar.ST *) | Seq c1 c2 -> com_denotation c1; com_denotation c2 | If b c1 c2 -> if b_exp_denotation b then com_denotation c1 else com_denotation c2 type g_exp = | GConst: int -> g_exp | Left : id -> g_exp | Right : id -> g_exp | GIOp : i_op -> g_exp -> g_exp -> g_exp type rel_exp = | RTrue : rel_exp | RFalse: rel_exp | RROp : r_op -> g_exp -> g_exp -> rel_exp | RBOp : b_op -> rel_exp -> rel_exp -> rel_exp | RNot : rel_exp -> rel_exp let rec g_exp_denotation (g:g_exp) (h_left:heap) (h_right:heap) :int = match g with | GConst n -> n | Left r -> sel h_left r | Right r -> sel h_right r | GIOp op g1 g2 -> match op with | Add -> g_exp_denotation g1 h_left h_right + g_exp_denotation g2 h_left h_right | Sub -> g_exp_denotation g1 h_left h_right - g_exp_denotation g2 h_left h_right let rec rel_exp_denotation (re:rel_exp) (h_left:heap) (h_right:heap) :bool = match re with | RTrue -> true | RFalse -> false | RROp op g1 g2 -> let n1 = g_exp_denotation g1 h_left h_right in let n2 = g_exp_denotation g2 h_left h_right in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | RBOp op re1 re2 -> let bc1 = rel_exp_denotation re1 h_left h_right in let bc2 = rel_exp_denotation re2 h_left h_right in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | RNot re1 -> not (rel_exp_denotation re1 h_left h_right) assume val x:id assume val y:id assume val z:id assume Distinct_vars: x <> y /\ y <> z /\ x <> z (* * removing redundant computation * proving com1 = x := y + 1; z := y + 1 * and com2 = x := y + 1; z := x * * relate two states with equal values of y to two states with equal values of x and z *) let com11 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1;
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.IntStoreFixed.fst.checked", "FStar.DM4F.Heap.IntStoreFixed.fsti.checked" ], "interface_file": false, "source_file": "ProgramOptimizations.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ProgramOptimizations.com
Prims.Tot
[ "total" ]
[]
[ "ProgramOptimizations.Seq", "ProgramOptimizations.Assign", "ProgramOptimizations.x", "ProgramOptimizations.IOp", "ProgramOptimizations.Add", "ProgramOptimizations.Var", "ProgramOptimizations.y", "ProgramOptimizations.Const", "ProgramOptimizations.z" ]
[]
false
false
false
true
false
let com12 =
Seq (Assign x (IOp Add (Var y) (Const 1))) (Assign z (Var x))
false
Spec.Frodo.Test.fst
Spec.Frodo.Test.test1_keypaircoins
val test1_keypaircoins : Prims.list Lib.IntTypes.uint8
let test1_keypaircoins = List.Tot.map u8_from_UInt8 [ 0xa6uy; 0x65uy; 0x65uy; 0x9fuy; 0xfbuy; 0xe4uy; 0x06uy; 0x5cuy; 0xcauy; 0x81uy; 0x5auy; 0x45uy; 0xe4uy; 0x94uy; 0xd8uy; 0x01uy; 0x90uy; 0x30uy; 0x33uy; 0x55uy; 0x33uy; 0x84uy; 0x2euy; 0xe4uy; 0x4cuy; 0x55uy; 0x8fuy; 0xd8uy; 0xaeuy; 0x4buy; 0x4euy; 0x91uy; 0x62uy; 0xfeuy; 0xc7uy; 0x9auy; 0xc5uy; 0xcduy; 0x1fuy; 0xe2uy; 0xd2uy; 0x00uy; 0x63uy; 0x39uy; 0xaauy; 0xb1uy; 0xf3uy; 0x17uy ]
{ "file_name": "specs/tests/Spec.Frodo.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 62, "start_col": 0, "start_line": 55 }
module Spec.Frodo.Test open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Frodo.KEM open Spec.Frodo.KEM.KeyGen open Spec.Frodo.KEM.Encaps open Spec.Frodo.KEM.Decaps open Spec.Frodo.Params open FStar.All module PS = Lib.PrintSequence #set-options "--z3rlimit 50 --fuel 0 --ifuel 1" let compare (#len: size_nat) (test_expected: lbytes len) (test_result: lbytes len) = for_all2 (fun a b -> uint_to_nat #U8 a = uint_to_nat #U8 b) test_expected test_result let test_frodo (a:frodo_alg) (gen_a:frodo_gen_a) (keypaircoins: list uint8 {List.Tot.length keypaircoins == 2 * crypto_bytes a + bytes_seed_a}) (enccoins: list uint8 {List.Tot.length enccoins == bytes_mu a}) (ss_expected: list uint8 {List.Tot.length ss_expected == crypto_bytes a}) (pk_expected: list uint8 {List.Tot.length pk_expected == crypto_publickeybytes a}) (ct_expected: list uint8 {List.Tot.length ct_expected == crypto_ciphertextbytes a}) (sk_expected: list uint8 {List.Tot.length sk_expected == crypto_secretkeybytes a}) : ML bool = let keypaircoins = createL keypaircoins in let enccoins = createL enccoins in let ss_expected = createL ss_expected in let pk_expected = createL pk_expected in let ct_expected = createL ct_expected in let sk_expected = createL sk_expected in let pk, sk = crypto_kem_keypair_ a gen_a keypaircoins in let ct, ss1 = crypto_kem_enc_ a gen_a enccoins pk in let ss2 = crypto_kem_dec a gen_a ct sk in let r_pk = compare pk_expected pk in let r_sk = compare sk_expected sk in let r_ct = compare ct_expected ct in let r_ss = PS.print_compare true (crypto_bytes a) ss1 ss2 in let r_ss1 = PS.print_compare true (crypto_bytes a) ss_expected ss2 in r_pk && r_sk && r_ct && r_ss && r_ss1 // // Test1. FrodoKEM-64. SHAKE128
{ "checked_file": "/", "dependencies": [ "Spec.Frodo.Params.fst.checked", "Spec.Frodo.KEM.KeyGen.fst.checked", "Spec.Frodo.KEM.Encaps.fst.checked", "Spec.Frodo.KEM.Decaps.fst.checked", "Spec.Frodo.KEM.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.IO.fst.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Test.fst" }
[ { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.Params", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.KEM.Decaps", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.KEM.Encaps", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.KEM.KeyGen", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.list Lib.IntTypes.uint8
Prims.Tot
[ "total" ]
[]
[ "FStar.List.Tot.Base.map", "FStar.UInt8.t", "Lib.IntTypes.uint8", "Lib.RawIntTypes.u8_from_UInt8", "Prims.Cons", "FStar.UInt8.__uint_to_t", "Prims.Nil" ]
[]
false
false
false
true
false
let test1_keypaircoins =
List.Tot.map u8_from_UInt8 [ 0xa6uy; 0x65uy; 0x65uy; 0x9fuy; 0xfbuy; 0xe4uy; 0x06uy; 0x5cuy; 0xcauy; 0x81uy; 0x5auy; 0x45uy; 0xe4uy; 0x94uy; 0xd8uy; 0x01uy; 0x90uy; 0x30uy; 0x33uy; 0x55uy; 0x33uy; 0x84uy; 0x2euy; 0xe4uy; 0x4cuy; 0x55uy; 0x8fuy; 0xd8uy; 0xaeuy; 0x4buy; 0x4euy; 0x91uy; 0x62uy; 0xfeuy; 0xc7uy; 0x9auy; 0xc5uy; 0xcduy; 0x1fuy; 0xe2uy; 0xd2uy; 0x00uy; 0x63uy; 0x39uy; 0xaauy; 0xb1uy; 0xf3uy; 0x17uy ]
false
Spec.Frodo.Test.fst
Spec.Frodo.Test.test1_ss_expected
val test1_ss_expected : Prims.list Lib.IntTypes.uint8
let test1_ss_expected = List.Tot.map u8_from_UInt8 [ 0xf8uy; 0x96uy; 0x15uy; 0x94uy; 0x80uy; 0x9fuy; 0xebuy; 0x77uy; 0x56uy; 0xbeuy; 0x37uy; 0x69uy; 0xa0uy; 0xeauy; 0x60uy; 0x16uy ]
{ "file_name": "specs/tests/Spec.Frodo.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 76, "start_col": 0, "start_line": 71 }
module Spec.Frodo.Test open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Frodo.KEM open Spec.Frodo.KEM.KeyGen open Spec.Frodo.KEM.Encaps open Spec.Frodo.KEM.Decaps open Spec.Frodo.Params open FStar.All module PS = Lib.PrintSequence #set-options "--z3rlimit 50 --fuel 0 --ifuel 1" let compare (#len: size_nat) (test_expected: lbytes len) (test_result: lbytes len) = for_all2 (fun a b -> uint_to_nat #U8 a = uint_to_nat #U8 b) test_expected test_result let test_frodo (a:frodo_alg) (gen_a:frodo_gen_a) (keypaircoins: list uint8 {List.Tot.length keypaircoins == 2 * crypto_bytes a + bytes_seed_a}) (enccoins: list uint8 {List.Tot.length enccoins == bytes_mu a}) (ss_expected: list uint8 {List.Tot.length ss_expected == crypto_bytes a}) (pk_expected: list uint8 {List.Tot.length pk_expected == crypto_publickeybytes a}) (ct_expected: list uint8 {List.Tot.length ct_expected == crypto_ciphertextbytes a}) (sk_expected: list uint8 {List.Tot.length sk_expected == crypto_secretkeybytes a}) : ML bool = let keypaircoins = createL keypaircoins in let enccoins = createL enccoins in let ss_expected = createL ss_expected in let pk_expected = createL pk_expected in let ct_expected = createL ct_expected in let sk_expected = createL sk_expected in let pk, sk = crypto_kem_keypair_ a gen_a keypaircoins in let ct, ss1 = crypto_kem_enc_ a gen_a enccoins pk in let ss2 = crypto_kem_dec a gen_a ct sk in let r_pk = compare pk_expected pk in let r_sk = compare sk_expected sk in let r_ct = compare ct_expected ct in let r_ss = PS.print_compare true (crypto_bytes a) ss1 ss2 in let r_ss1 = PS.print_compare true (crypto_bytes a) ss_expected ss2 in r_pk && r_sk && r_ct && r_ss && r_ss1 // // Test1. FrodoKEM-64. SHAKE128 // let test1_keypaircoins = List.Tot.map u8_from_UInt8 [ 0xa6uy; 0x65uy; 0x65uy; 0x9fuy; 0xfbuy; 0xe4uy; 0x06uy; 0x5cuy; 0xcauy; 0x81uy; 0x5auy; 0x45uy; 0xe4uy; 0x94uy; 0xd8uy; 0x01uy; 0x90uy; 0x30uy; 0x33uy; 0x55uy; 0x33uy; 0x84uy; 0x2euy; 0xe4uy; 0x4cuy; 0x55uy; 0x8fuy; 0xd8uy; 0xaeuy; 0x4buy; 0x4euy; 0x91uy; 0x62uy; 0xfeuy; 0xc7uy; 0x9auy; 0xc5uy; 0xcduy; 0x1fuy; 0xe2uy; 0xd2uy; 0x00uy; 0x63uy; 0x39uy; 0xaauy; 0xb1uy; 0xf3uy; 0x17uy ] let test1_enccoins = List.Tot.map u8_from_UInt8 [ 0x8duy; 0xf3uy; 0xfauy; 0xe3uy; 0x83uy; 0x27uy; 0xc5uy; 0x3cuy; 0xc1uy; 0xc4uy; 0x8cuy; 0x60uy; 0xb2uy; 0x52uy; 0x2buy; 0xb5uy ]
{ "checked_file": "/", "dependencies": [ "Spec.Frodo.Params.fst.checked", "Spec.Frodo.KEM.KeyGen.fst.checked", "Spec.Frodo.KEM.Encaps.fst.checked", "Spec.Frodo.KEM.Decaps.fst.checked", "Spec.Frodo.KEM.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.IO.fst.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Test.fst" }
[ { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.Params", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.KEM.Decaps", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.KEM.Encaps", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.KEM.KeyGen", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.list Lib.IntTypes.uint8
Prims.Tot
[ "total" ]
[]
[ "FStar.List.Tot.Base.map", "FStar.UInt8.t", "Lib.IntTypes.uint8", "Lib.RawIntTypes.u8_from_UInt8", "Prims.Cons", "FStar.UInt8.__uint_to_t", "Prims.Nil" ]
[]
false
false
false
true
false
let test1_ss_expected =
List.Tot.map u8_from_UInt8 [ 0xf8uy; 0x96uy; 0x15uy; 0x94uy; 0x80uy; 0x9fuy; 0xebuy; 0x77uy; 0x56uy; 0xbeuy; 0x37uy; 0x69uy; 0xa0uy; 0xeauy; 0x60uy; 0x16uy ]
false
ProgramOptimizations.fst
ProgramOptimizations.rel11
val rel11 : ProgramOptimizations.rel_exp
let rel11 = RROp Eq (Left y) (Right y)
{ "file_name": "examples/rel/ProgramOptimizations.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 38, "end_line": 162, "start_col": 0, "start_line": 162 }
(* 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 ProgramOptimizations open FStar.DM4F.Heap.IntStoreFixed open FStar.DM4F.IntStoreFixed (* * language and examples from: * "Simple Relational Correctness Proofs for Static Analyses and Program Transformations" * https://research.microsoft.com/en-us/um/people/nick/correctnesspopl2004.pdf *) type var = id type i_op = | Add | Sub type i_exp = | Const : int -> i_exp | Var : id -> i_exp | IOp : i_op -> i_exp -> i_exp -> i_exp | UMinus: i_exp -> i_exp type r_op = | Lt | Gt | Eq type b_op = | And | Or type b_exp = | CTrue : b_exp | CFalse: b_exp | ROp : r_op -> i_exp -> i_exp -> b_exp | BOp : b_op -> b_exp -> b_exp -> b_exp | Not : b_exp -> b_exp type com = | Skip : com | Assign: var -> i_exp -> com | Seq : com -> com -> com | If : b_exp -> com -> com -> com let rec i_exp_denotation (e:i_exp) :ISNull int = match e with | Const n -> n | Var r -> !r | IOp op e1 e2 -> (let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in match op with | Add -> n1 + n2 | Sub -> n1 - n2) | UMinus e -> - (i_exp_denotation e) let rec b_exp_denotation (b:b_exp) :ISNull bool = match b with | CTrue -> true | CFalse -> false | ROp op e1 e2 -> let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | BOp op b1 b2 -> let bc1 = b_exp_denotation b1 in let bc2 = b_exp_denotation b2 in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | Not b -> not (b_exp_denotation b) let rec com_denotation (c:com) :ISNull unit = match c with | Skip -> () | Assign r e -> let n = i_exp_denotation e in write r n (* r := n does not work, as it goes to FStar.ST *) | Seq c1 c2 -> com_denotation c1; com_denotation c2 | If b c1 c2 -> if b_exp_denotation b then com_denotation c1 else com_denotation c2 type g_exp = | GConst: int -> g_exp | Left : id -> g_exp | Right : id -> g_exp | GIOp : i_op -> g_exp -> g_exp -> g_exp type rel_exp = | RTrue : rel_exp | RFalse: rel_exp | RROp : r_op -> g_exp -> g_exp -> rel_exp | RBOp : b_op -> rel_exp -> rel_exp -> rel_exp | RNot : rel_exp -> rel_exp let rec g_exp_denotation (g:g_exp) (h_left:heap) (h_right:heap) :int = match g with | GConst n -> n | Left r -> sel h_left r | Right r -> sel h_right r | GIOp op g1 g2 -> match op with | Add -> g_exp_denotation g1 h_left h_right + g_exp_denotation g2 h_left h_right | Sub -> g_exp_denotation g1 h_left h_right - g_exp_denotation g2 h_left h_right let rec rel_exp_denotation (re:rel_exp) (h_left:heap) (h_right:heap) :bool = match re with | RTrue -> true | RFalse -> false | RROp op g1 g2 -> let n1 = g_exp_denotation g1 h_left h_right in let n2 = g_exp_denotation g2 h_left h_right in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | RBOp op re1 re2 -> let bc1 = rel_exp_denotation re1 h_left h_right in let bc2 = rel_exp_denotation re2 h_left h_right in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | RNot re1 -> not (rel_exp_denotation re1 h_left h_right) assume val x:id assume val y:id assume val z:id assume Distinct_vars: x <> y /\ y <> z /\ x <> z (* * removing redundant computation * proving com1 = x := y + 1; z := y + 1 * and com2 = x := y + 1; z := x * * relate two states with equal values of y to two states with equal values of x and z *) let com11 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (IOp Add (Var y) (Const 1))) //z := y + 1 let com12 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (Var x)) //z := x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.IntStoreFixed.fst.checked", "FStar.DM4F.Heap.IntStoreFixed.fsti.checked" ], "interface_file": false, "source_file": "ProgramOptimizations.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ProgramOptimizations.rel_exp
Prims.Tot
[ "total" ]
[]
[ "ProgramOptimizations.RROp", "ProgramOptimizations.Eq", "ProgramOptimizations.Left", "ProgramOptimizations.y", "ProgramOptimizations.Right" ]
[]
false
false
false
true
false
let rel11 =
RROp Eq (Left y) (Right y)
false
ProgramOptimizations.fst
ProgramOptimizations.com21
val com21 : ProgramOptimizations.com
let com21 = If (ROp Gt (Var x) (Const 3)) (Assign y (Var x)) (Assign y (Const 7))
{ "file_name": "examples/rel/ProgramOptimizations.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 35, "end_line": 181, "start_col": 0, "start_line": 179 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module ProgramOptimizations open FStar.DM4F.Heap.IntStoreFixed open FStar.DM4F.IntStoreFixed (* * language and examples from: * "Simple Relational Correctness Proofs for Static Analyses and Program Transformations" * https://research.microsoft.com/en-us/um/people/nick/correctnesspopl2004.pdf *) type var = id type i_op = | Add | Sub type i_exp = | Const : int -> i_exp | Var : id -> i_exp | IOp : i_op -> i_exp -> i_exp -> i_exp | UMinus: i_exp -> i_exp type r_op = | Lt | Gt | Eq type b_op = | And | Or type b_exp = | CTrue : b_exp | CFalse: b_exp | ROp : r_op -> i_exp -> i_exp -> b_exp | BOp : b_op -> b_exp -> b_exp -> b_exp | Not : b_exp -> b_exp type com = | Skip : com | Assign: var -> i_exp -> com | Seq : com -> com -> com | If : b_exp -> com -> com -> com let rec i_exp_denotation (e:i_exp) :ISNull int = match e with | Const n -> n | Var r -> !r | IOp op e1 e2 -> (let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in match op with | Add -> n1 + n2 | Sub -> n1 - n2) | UMinus e -> - (i_exp_denotation e) let rec b_exp_denotation (b:b_exp) :ISNull bool = match b with | CTrue -> true | CFalse -> false | ROp op e1 e2 -> let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | BOp op b1 b2 -> let bc1 = b_exp_denotation b1 in let bc2 = b_exp_denotation b2 in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | Not b -> not (b_exp_denotation b) let rec com_denotation (c:com) :ISNull unit = match c with | Skip -> () | Assign r e -> let n = i_exp_denotation e in write r n (* r := n does not work, as it goes to FStar.ST *) | Seq c1 c2 -> com_denotation c1; com_denotation c2 | If b c1 c2 -> if b_exp_denotation b then com_denotation c1 else com_denotation c2 type g_exp = | GConst: int -> g_exp | Left : id -> g_exp | Right : id -> g_exp | GIOp : i_op -> g_exp -> g_exp -> g_exp type rel_exp = | RTrue : rel_exp | RFalse: rel_exp | RROp : r_op -> g_exp -> g_exp -> rel_exp | RBOp : b_op -> rel_exp -> rel_exp -> rel_exp | RNot : rel_exp -> rel_exp let rec g_exp_denotation (g:g_exp) (h_left:heap) (h_right:heap) :int = match g with | GConst n -> n | Left r -> sel h_left r | Right r -> sel h_right r | GIOp op g1 g2 -> match op with | Add -> g_exp_denotation g1 h_left h_right + g_exp_denotation g2 h_left h_right | Sub -> g_exp_denotation g1 h_left h_right - g_exp_denotation g2 h_left h_right let rec rel_exp_denotation (re:rel_exp) (h_left:heap) (h_right:heap) :bool = match re with | RTrue -> true | RFalse -> false | RROp op g1 g2 -> let n1 = g_exp_denotation g1 h_left h_right in let n2 = g_exp_denotation g2 h_left h_right in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | RBOp op re1 re2 -> let bc1 = rel_exp_denotation re1 h_left h_right in let bc2 = rel_exp_denotation re2 h_left h_right in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | RNot re1 -> not (rel_exp_denotation re1 h_left h_right) assume val x:id assume val y:id assume val z:id assume Distinct_vars: x <> y /\ y <> z /\ x <> z (* * removing redundant computation * proving com1 = x := y + 1; z := y + 1 * and com2 = x := y + 1; z := x * * relate two states with equal values of y to two states with equal values of x and z *) let com11 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (IOp Add (Var y) (Const 1))) //z := y + 1 let com12 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (Var x)) //z := x let rel11 = RROp Eq (Left y) (Right y) //Left y = Right y let rel12 = RBOp And (RROp Eq (Left x) (Right x)) //Left x = Right x /\ (RROp Eq (Left z) (Right z)) //Left z = Right z let lemma_sound_optimization1 (h_left:heap) (h_right:heap) :Lemma (requires (rel_exp_denotation rel11 h_left h_right)) //h_left, h_right are related by rel1 (ensures (let _, h_left' = reify (com_denotation com11) h_left in let _, h_right' = reify (com_denotation com12) h_right in rel_exp_denotation rel12 h_left' h_right')) //[|com1|](h_left), [|com2|](h_right) are related by rel2 = () (* * dead code elimination * proving com1 = if x > 3 then y := x else y := 7 * and com2 = skip * are equivalent if all that the rest of the computation cares for is y > 2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.IntStoreFixed.fst.checked", "FStar.DM4F.Heap.IntStoreFixed.fsti.checked" ], "interface_file": false, "source_file": "ProgramOptimizations.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ProgramOptimizations.com
Prims.Tot
[ "total" ]
[]
[ "ProgramOptimizations.If", "ProgramOptimizations.ROp", "ProgramOptimizations.Gt", "ProgramOptimizations.Var", "ProgramOptimizations.x", "ProgramOptimizations.Const", "ProgramOptimizations.Assign", "ProgramOptimizations.y" ]
[]
false
false
false
true
false
let com21 =
If (ROp Gt (Var x) (Const 3)) (Assign y (Var x)) (Assign y (Const 7))
false
ProgramOptimizations.fst
ProgramOptimizations.com22
val com22 : ProgramOptimizations.com
let com22 = Skip
{ "file_name": "examples/rel/ProgramOptimizations.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 16, "end_line": 182, "start_col": 0, "start_line": 182 }
(* 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 ProgramOptimizations open FStar.DM4F.Heap.IntStoreFixed open FStar.DM4F.IntStoreFixed (* * language and examples from: * "Simple Relational Correctness Proofs for Static Analyses and Program Transformations" * https://research.microsoft.com/en-us/um/people/nick/correctnesspopl2004.pdf *) type var = id type i_op = | Add | Sub type i_exp = | Const : int -> i_exp | Var : id -> i_exp | IOp : i_op -> i_exp -> i_exp -> i_exp | UMinus: i_exp -> i_exp type r_op = | Lt | Gt | Eq type b_op = | And | Or type b_exp = | CTrue : b_exp | CFalse: b_exp | ROp : r_op -> i_exp -> i_exp -> b_exp | BOp : b_op -> b_exp -> b_exp -> b_exp | Not : b_exp -> b_exp type com = | Skip : com | Assign: var -> i_exp -> com | Seq : com -> com -> com | If : b_exp -> com -> com -> com let rec i_exp_denotation (e:i_exp) :ISNull int = match e with | Const n -> n | Var r -> !r | IOp op e1 e2 -> (let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in match op with | Add -> n1 + n2 | Sub -> n1 - n2) | UMinus e -> - (i_exp_denotation e) let rec b_exp_denotation (b:b_exp) :ISNull bool = match b with | CTrue -> true | CFalse -> false | ROp op e1 e2 -> let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | BOp op b1 b2 -> let bc1 = b_exp_denotation b1 in let bc2 = b_exp_denotation b2 in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | Not b -> not (b_exp_denotation b) let rec com_denotation (c:com) :ISNull unit = match c with | Skip -> () | Assign r e -> let n = i_exp_denotation e in write r n (* r := n does not work, as it goes to FStar.ST *) | Seq c1 c2 -> com_denotation c1; com_denotation c2 | If b c1 c2 -> if b_exp_denotation b then com_denotation c1 else com_denotation c2 type g_exp = | GConst: int -> g_exp | Left : id -> g_exp | Right : id -> g_exp | GIOp : i_op -> g_exp -> g_exp -> g_exp type rel_exp = | RTrue : rel_exp | RFalse: rel_exp | RROp : r_op -> g_exp -> g_exp -> rel_exp | RBOp : b_op -> rel_exp -> rel_exp -> rel_exp | RNot : rel_exp -> rel_exp let rec g_exp_denotation (g:g_exp) (h_left:heap) (h_right:heap) :int = match g with | GConst n -> n | Left r -> sel h_left r | Right r -> sel h_right r | GIOp op g1 g2 -> match op with | Add -> g_exp_denotation g1 h_left h_right + g_exp_denotation g2 h_left h_right | Sub -> g_exp_denotation g1 h_left h_right - g_exp_denotation g2 h_left h_right let rec rel_exp_denotation (re:rel_exp) (h_left:heap) (h_right:heap) :bool = match re with | RTrue -> true | RFalse -> false | RROp op g1 g2 -> let n1 = g_exp_denotation g1 h_left h_right in let n2 = g_exp_denotation g2 h_left h_right in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | RBOp op re1 re2 -> let bc1 = rel_exp_denotation re1 h_left h_right in let bc2 = rel_exp_denotation re2 h_left h_right in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | RNot re1 -> not (rel_exp_denotation re1 h_left h_right) assume val x:id assume val y:id assume val z:id assume Distinct_vars: x <> y /\ y <> z /\ x <> z (* * removing redundant computation * proving com1 = x := y + 1; z := y + 1 * and com2 = x := y + 1; z := x * * relate two states with equal values of y to two states with equal values of x and z *) let com11 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (IOp Add (Var y) (Const 1))) //z := y + 1 let com12 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (Var x)) //z := x let rel11 = RROp Eq (Left y) (Right y) //Left y = Right y let rel12 = RBOp And (RROp Eq (Left x) (Right x)) //Left x = Right x /\ (RROp Eq (Left z) (Right z)) //Left z = Right z let lemma_sound_optimization1 (h_left:heap) (h_right:heap) :Lemma (requires (rel_exp_denotation rel11 h_left h_right)) //h_left, h_right are related by rel1 (ensures (let _, h_left' = reify (com_denotation com11) h_left in let _, h_right' = reify (com_denotation com12) h_right in rel_exp_denotation rel12 h_left' h_right')) //[|com1|](h_left), [|com2|](h_right) are related by rel2 = () (* * dead code elimination * proving com1 = if x > 3 then y := x else y := 7 * and com2 = skip * are equivalent if all that the rest of the computation cares for is y > 2 *) let com21 = If (ROp Gt (Var x) (Const 3)) (Assign y (Var x))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.IntStoreFixed.fst.checked", "FStar.DM4F.Heap.IntStoreFixed.fsti.checked" ], "interface_file": false, "source_file": "ProgramOptimizations.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ProgramOptimizations.com
Prims.Tot
[ "total" ]
[]
[ "ProgramOptimizations.Skip" ]
[]
false
false
false
true
false
let com22 =
Skip
false
ProgramOptimizations.fst
ProgramOptimizations.rel22
val rel22 : ProgramOptimizations.rel_exp
let rel22 = RBOp And (RROp Gt (Left y) (GConst 2)) //Left y > 2 (RROp Gt (Right y) (GConst 2))
{ "file_name": "examples/rel/ProgramOptimizations.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 51, "end_line": 188, "start_col": 0, "start_line": 187 }
(* 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 ProgramOptimizations open FStar.DM4F.Heap.IntStoreFixed open FStar.DM4F.IntStoreFixed (* * language and examples from: * "Simple Relational Correctness Proofs for Static Analyses and Program Transformations" * https://research.microsoft.com/en-us/um/people/nick/correctnesspopl2004.pdf *) type var = id type i_op = | Add | Sub type i_exp = | Const : int -> i_exp | Var : id -> i_exp | IOp : i_op -> i_exp -> i_exp -> i_exp | UMinus: i_exp -> i_exp type r_op = | Lt | Gt | Eq type b_op = | And | Or type b_exp = | CTrue : b_exp | CFalse: b_exp | ROp : r_op -> i_exp -> i_exp -> b_exp | BOp : b_op -> b_exp -> b_exp -> b_exp | Not : b_exp -> b_exp type com = | Skip : com | Assign: var -> i_exp -> com | Seq : com -> com -> com | If : b_exp -> com -> com -> com let rec i_exp_denotation (e:i_exp) :ISNull int = match e with | Const n -> n | Var r -> !r | IOp op e1 e2 -> (let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in match op with | Add -> n1 + n2 | Sub -> n1 - n2) | UMinus e -> - (i_exp_denotation e) let rec b_exp_denotation (b:b_exp) :ISNull bool = match b with | CTrue -> true | CFalse -> false | ROp op e1 e2 -> let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | BOp op b1 b2 -> let bc1 = b_exp_denotation b1 in let bc2 = b_exp_denotation b2 in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | Not b -> not (b_exp_denotation b) let rec com_denotation (c:com) :ISNull unit = match c with | Skip -> () | Assign r e -> let n = i_exp_denotation e in write r n (* r := n does not work, as it goes to FStar.ST *) | Seq c1 c2 -> com_denotation c1; com_denotation c2 | If b c1 c2 -> if b_exp_denotation b then com_denotation c1 else com_denotation c2 type g_exp = | GConst: int -> g_exp | Left : id -> g_exp | Right : id -> g_exp | GIOp : i_op -> g_exp -> g_exp -> g_exp type rel_exp = | RTrue : rel_exp | RFalse: rel_exp | RROp : r_op -> g_exp -> g_exp -> rel_exp | RBOp : b_op -> rel_exp -> rel_exp -> rel_exp | RNot : rel_exp -> rel_exp let rec g_exp_denotation (g:g_exp) (h_left:heap) (h_right:heap) :int = match g with | GConst n -> n | Left r -> sel h_left r | Right r -> sel h_right r | GIOp op g1 g2 -> match op with | Add -> g_exp_denotation g1 h_left h_right + g_exp_denotation g2 h_left h_right | Sub -> g_exp_denotation g1 h_left h_right - g_exp_denotation g2 h_left h_right let rec rel_exp_denotation (re:rel_exp) (h_left:heap) (h_right:heap) :bool = match re with | RTrue -> true | RFalse -> false | RROp op g1 g2 -> let n1 = g_exp_denotation g1 h_left h_right in let n2 = g_exp_denotation g2 h_left h_right in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | RBOp op re1 re2 -> let bc1 = rel_exp_denotation re1 h_left h_right in let bc2 = rel_exp_denotation re2 h_left h_right in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | RNot re1 -> not (rel_exp_denotation re1 h_left h_right) assume val x:id assume val y:id assume val z:id assume Distinct_vars: x <> y /\ y <> z /\ x <> z (* * removing redundant computation * proving com1 = x := y + 1; z := y + 1 * and com2 = x := y + 1; z := x * * relate two states with equal values of y to two states with equal values of x and z *) let com11 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (IOp Add (Var y) (Const 1))) //z := y + 1 let com12 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (Var x)) //z := x let rel11 = RROp Eq (Left y) (Right y) //Left y = Right y let rel12 = RBOp And (RROp Eq (Left x) (Right x)) //Left x = Right x /\ (RROp Eq (Left z) (Right z)) //Left z = Right z let lemma_sound_optimization1 (h_left:heap) (h_right:heap) :Lemma (requires (rel_exp_denotation rel11 h_left h_right)) //h_left, h_right are related by rel1 (ensures (let _, h_left' = reify (com_denotation com11) h_left in let _, h_right' = reify (com_denotation com12) h_right in rel_exp_denotation rel12 h_left' h_right')) //[|com1|](h_left), [|com2|](h_right) are related by rel2 = () (* * dead code elimination * proving com1 = if x > 3 then y := x else y := 7 * and com2 = skip * are equivalent if all that the rest of the computation cares for is y > 2 *) let com21 = If (ROp Gt (Var x) (Const 3)) (Assign y (Var x)) (Assign y (Const 7)) //if x > 3 then y := x else y := 7 let com22 = Skip let rel21 = RBOp And (RBOp And (RROp Eq (Left x) (Right x)) //Left x = Right x (RROp Gt (Left y) (GConst 2))) //Left y > 2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.IntStoreFixed.fst.checked", "FStar.DM4F.Heap.IntStoreFixed.fsti.checked" ], "interface_file": false, "source_file": "ProgramOptimizations.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ProgramOptimizations.rel_exp
Prims.Tot
[ "total" ]
[]
[ "ProgramOptimizations.RBOp", "ProgramOptimizations.And", "ProgramOptimizations.RROp", "ProgramOptimizations.Gt", "ProgramOptimizations.Left", "ProgramOptimizations.y", "ProgramOptimizations.GConst", "ProgramOptimizations.Right" ]
[]
false
false
false
true
false
let rel22 =
RBOp And (RROp Gt (Left y) (GConst 2)) (RROp Gt (Right y) (GConst 2))
false
ProgramOptimizations.fst
ProgramOptimizations.rel12
val rel12 : ProgramOptimizations.rel_exp
let rel12 = RBOp And (RROp Eq (Left x) (Right x)) //Left x = Right x /\ (RROp Eq (Left z) (Right z))
{ "file_name": "examples/rel/ProgramOptimizations.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 49, "end_line": 164, "start_col": 0, "start_line": 163 }
(* 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 ProgramOptimizations open FStar.DM4F.Heap.IntStoreFixed open FStar.DM4F.IntStoreFixed (* * language and examples from: * "Simple Relational Correctness Proofs for Static Analyses and Program Transformations" * https://research.microsoft.com/en-us/um/people/nick/correctnesspopl2004.pdf *) type var = id type i_op = | Add | Sub type i_exp = | Const : int -> i_exp | Var : id -> i_exp | IOp : i_op -> i_exp -> i_exp -> i_exp | UMinus: i_exp -> i_exp type r_op = | Lt | Gt | Eq type b_op = | And | Or type b_exp = | CTrue : b_exp | CFalse: b_exp | ROp : r_op -> i_exp -> i_exp -> b_exp | BOp : b_op -> b_exp -> b_exp -> b_exp | Not : b_exp -> b_exp type com = | Skip : com | Assign: var -> i_exp -> com | Seq : com -> com -> com | If : b_exp -> com -> com -> com let rec i_exp_denotation (e:i_exp) :ISNull int = match e with | Const n -> n | Var r -> !r | IOp op e1 e2 -> (let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in match op with | Add -> n1 + n2 | Sub -> n1 - n2) | UMinus e -> - (i_exp_denotation e) let rec b_exp_denotation (b:b_exp) :ISNull bool = match b with | CTrue -> true | CFalse -> false | ROp op e1 e2 -> let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | BOp op b1 b2 -> let bc1 = b_exp_denotation b1 in let bc2 = b_exp_denotation b2 in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | Not b -> not (b_exp_denotation b) let rec com_denotation (c:com) :ISNull unit = match c with | Skip -> () | Assign r e -> let n = i_exp_denotation e in write r n (* r := n does not work, as it goes to FStar.ST *) | Seq c1 c2 -> com_denotation c1; com_denotation c2 | If b c1 c2 -> if b_exp_denotation b then com_denotation c1 else com_denotation c2 type g_exp = | GConst: int -> g_exp | Left : id -> g_exp | Right : id -> g_exp | GIOp : i_op -> g_exp -> g_exp -> g_exp type rel_exp = | RTrue : rel_exp | RFalse: rel_exp | RROp : r_op -> g_exp -> g_exp -> rel_exp | RBOp : b_op -> rel_exp -> rel_exp -> rel_exp | RNot : rel_exp -> rel_exp let rec g_exp_denotation (g:g_exp) (h_left:heap) (h_right:heap) :int = match g with | GConst n -> n | Left r -> sel h_left r | Right r -> sel h_right r | GIOp op g1 g2 -> match op with | Add -> g_exp_denotation g1 h_left h_right + g_exp_denotation g2 h_left h_right | Sub -> g_exp_denotation g1 h_left h_right - g_exp_denotation g2 h_left h_right let rec rel_exp_denotation (re:rel_exp) (h_left:heap) (h_right:heap) :bool = match re with | RTrue -> true | RFalse -> false | RROp op g1 g2 -> let n1 = g_exp_denotation g1 h_left h_right in let n2 = g_exp_denotation g2 h_left h_right in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | RBOp op re1 re2 -> let bc1 = rel_exp_denotation re1 h_left h_right in let bc2 = rel_exp_denotation re2 h_left h_right in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | RNot re1 -> not (rel_exp_denotation re1 h_left h_right) assume val x:id assume val y:id assume val z:id assume Distinct_vars: x <> y /\ y <> z /\ x <> z (* * removing redundant computation * proving com1 = x := y + 1; z := y + 1 * and com2 = x := y + 1; z := x * * relate two states with equal values of y to two states with equal values of x and z *) let com11 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (IOp Add (Var y) (Const 1))) //z := y + 1 let com12 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (Var x)) //z := x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.IntStoreFixed.fst.checked", "FStar.DM4F.Heap.IntStoreFixed.fsti.checked" ], "interface_file": false, "source_file": "ProgramOptimizations.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ProgramOptimizations.rel_exp
Prims.Tot
[ "total" ]
[]
[ "ProgramOptimizations.RBOp", "ProgramOptimizations.And", "ProgramOptimizations.RROp", "ProgramOptimizations.Eq", "ProgramOptimizations.Left", "ProgramOptimizations.x", "ProgramOptimizations.Right", "ProgramOptimizations.z" ]
[]
false
false
false
true
false
let rel12 =
RBOp And (RROp Eq (Left x) (Right x)) (RROp Eq (Left z) (Right z))
false
ProgramOptimizations.fst
ProgramOptimizations.com31
val com31 : ProgramOptimizations.com
let com31 = If (ROp Eq (Var x) (Const 3)) (Assign y (Var x)) (Assign y (Const 3))
{ "file_name": "examples/rel/ProgramOptimizations.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 28, "end_line": 205, "start_col": 0, "start_line": 203 }
(* 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 ProgramOptimizations open FStar.DM4F.Heap.IntStoreFixed open FStar.DM4F.IntStoreFixed (* * language and examples from: * "Simple Relational Correctness Proofs for Static Analyses and Program Transformations" * https://research.microsoft.com/en-us/um/people/nick/correctnesspopl2004.pdf *) type var = id type i_op = | Add | Sub type i_exp = | Const : int -> i_exp | Var : id -> i_exp | IOp : i_op -> i_exp -> i_exp -> i_exp | UMinus: i_exp -> i_exp type r_op = | Lt | Gt | Eq type b_op = | And | Or type b_exp = | CTrue : b_exp | CFalse: b_exp | ROp : r_op -> i_exp -> i_exp -> b_exp | BOp : b_op -> b_exp -> b_exp -> b_exp | Not : b_exp -> b_exp type com = | Skip : com | Assign: var -> i_exp -> com | Seq : com -> com -> com | If : b_exp -> com -> com -> com let rec i_exp_denotation (e:i_exp) :ISNull int = match e with | Const n -> n | Var r -> !r | IOp op e1 e2 -> (let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in match op with | Add -> n1 + n2 | Sub -> n1 - n2) | UMinus e -> - (i_exp_denotation e) let rec b_exp_denotation (b:b_exp) :ISNull bool = match b with | CTrue -> true | CFalse -> false | ROp op e1 e2 -> let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | BOp op b1 b2 -> let bc1 = b_exp_denotation b1 in let bc2 = b_exp_denotation b2 in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | Not b -> not (b_exp_denotation b) let rec com_denotation (c:com) :ISNull unit = match c with | Skip -> () | Assign r e -> let n = i_exp_denotation e in write r n (* r := n does not work, as it goes to FStar.ST *) | Seq c1 c2 -> com_denotation c1; com_denotation c2 | If b c1 c2 -> if b_exp_denotation b then com_denotation c1 else com_denotation c2 type g_exp = | GConst: int -> g_exp | Left : id -> g_exp | Right : id -> g_exp | GIOp : i_op -> g_exp -> g_exp -> g_exp type rel_exp = | RTrue : rel_exp | RFalse: rel_exp | RROp : r_op -> g_exp -> g_exp -> rel_exp | RBOp : b_op -> rel_exp -> rel_exp -> rel_exp | RNot : rel_exp -> rel_exp let rec g_exp_denotation (g:g_exp) (h_left:heap) (h_right:heap) :int = match g with | GConst n -> n | Left r -> sel h_left r | Right r -> sel h_right r | GIOp op g1 g2 -> match op with | Add -> g_exp_denotation g1 h_left h_right + g_exp_denotation g2 h_left h_right | Sub -> g_exp_denotation g1 h_left h_right - g_exp_denotation g2 h_left h_right let rec rel_exp_denotation (re:rel_exp) (h_left:heap) (h_right:heap) :bool = match re with | RTrue -> true | RFalse -> false | RROp op g1 g2 -> let n1 = g_exp_denotation g1 h_left h_right in let n2 = g_exp_denotation g2 h_left h_right in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | RBOp op re1 re2 -> let bc1 = rel_exp_denotation re1 h_left h_right in let bc2 = rel_exp_denotation re2 h_left h_right in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | RNot re1 -> not (rel_exp_denotation re1 h_left h_right) assume val x:id assume val y:id assume val z:id assume Distinct_vars: x <> y /\ y <> z /\ x <> z (* * removing redundant computation * proving com1 = x := y + 1; z := y + 1 * and com2 = x := y + 1; z := x * * relate two states with equal values of y to two states with equal values of x and z *) let com11 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (IOp Add (Var y) (Const 1))) //z := y + 1 let com12 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (Var x)) //z := x let rel11 = RROp Eq (Left y) (Right y) //Left y = Right y let rel12 = RBOp And (RROp Eq (Left x) (Right x)) //Left x = Right x /\ (RROp Eq (Left z) (Right z)) //Left z = Right z let lemma_sound_optimization1 (h_left:heap) (h_right:heap) :Lemma (requires (rel_exp_denotation rel11 h_left h_right)) //h_left, h_right are related by rel1 (ensures (let _, h_left' = reify (com_denotation com11) h_left in let _, h_right' = reify (com_denotation com12) h_right in rel_exp_denotation rel12 h_left' h_right')) //[|com1|](h_left), [|com2|](h_right) are related by rel2 = () (* * dead code elimination * proving com1 = if x > 3 then y := x else y := 7 * and com2 = skip * are equivalent if all that the rest of the computation cares for is y > 2 *) let com21 = If (ROp Gt (Var x) (Const 3)) (Assign y (Var x)) (Assign y (Const 7)) //if x > 3 then y := x else y := 7 let com22 = Skip let rel21 = RBOp And (RBOp And (RROp Eq (Left x) (Right x)) //Left x = Right x (RROp Gt (Left y) (GConst 2))) //Left y > 2 (RROp Gt (Right y) (GConst 2)) //Right y > 2 let rel22 = RBOp And (RROp Gt (Left y) (GConst 2)) //Left y > 2 (RROp Gt (Right y) (GConst 2)) //Right y > 2 let lemma_sound_optimization2 (h_left:heap) (h_right:heap) :Lemma (requires (rel_exp_denotation rel21 h_left h_right)) (ensures (let _, h_left' = reify (com_denotation com21) h_left in let _, h_right' = reify (com_denotation com22) h_right in rel_exp_denotation rel22 h_left' h_right')) = () (* * optimization * proving com1 = if x = 3 then y := x else y := 3 * and com2 = y := 3 * are equivalent
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.IntStoreFixed.fst.checked", "FStar.DM4F.Heap.IntStoreFixed.fsti.checked" ], "interface_file": false, "source_file": "ProgramOptimizations.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ProgramOptimizations.com
Prims.Tot
[ "total" ]
[]
[ "ProgramOptimizations.If", "ProgramOptimizations.ROp", "ProgramOptimizations.Eq", "ProgramOptimizations.Var", "ProgramOptimizations.x", "ProgramOptimizations.Const", "ProgramOptimizations.Assign", "ProgramOptimizations.y" ]
[]
false
false
false
true
false
let com31 =
If (ROp Eq (Var x) (Const 3)) (Assign y (Var x)) (Assign y (Const 3))
false
ProgramOptimizations.fst
ProgramOptimizations.com11
val com11 : ProgramOptimizations.com
let com11 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (IOp Add (Var y) (Const 1)))
{ "file_name": "examples/rel/ProgramOptimizations.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 54, "end_line": 158, "start_col": 0, "start_line": 157 }
(* 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 ProgramOptimizations open FStar.DM4F.Heap.IntStoreFixed open FStar.DM4F.IntStoreFixed (* * language and examples from: * "Simple Relational Correctness Proofs for Static Analyses and Program Transformations" * https://research.microsoft.com/en-us/um/people/nick/correctnesspopl2004.pdf *) type var = id type i_op = | Add | Sub type i_exp = | Const : int -> i_exp | Var : id -> i_exp | IOp : i_op -> i_exp -> i_exp -> i_exp | UMinus: i_exp -> i_exp type r_op = | Lt | Gt | Eq type b_op = | And | Or type b_exp = | CTrue : b_exp | CFalse: b_exp | ROp : r_op -> i_exp -> i_exp -> b_exp | BOp : b_op -> b_exp -> b_exp -> b_exp | Not : b_exp -> b_exp type com = | Skip : com | Assign: var -> i_exp -> com | Seq : com -> com -> com | If : b_exp -> com -> com -> com let rec i_exp_denotation (e:i_exp) :ISNull int = match e with | Const n -> n | Var r -> !r | IOp op e1 e2 -> (let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in match op with | Add -> n1 + n2 | Sub -> n1 - n2) | UMinus e -> - (i_exp_denotation e) let rec b_exp_denotation (b:b_exp) :ISNull bool = match b with | CTrue -> true | CFalse -> false | ROp op e1 e2 -> let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | BOp op b1 b2 -> let bc1 = b_exp_denotation b1 in let bc2 = b_exp_denotation b2 in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | Not b -> not (b_exp_denotation b) let rec com_denotation (c:com) :ISNull unit = match c with | Skip -> () | Assign r e -> let n = i_exp_denotation e in write r n (* r := n does not work, as it goes to FStar.ST *) | Seq c1 c2 -> com_denotation c1; com_denotation c2 | If b c1 c2 -> if b_exp_denotation b then com_denotation c1 else com_denotation c2 type g_exp = | GConst: int -> g_exp | Left : id -> g_exp | Right : id -> g_exp | GIOp : i_op -> g_exp -> g_exp -> g_exp type rel_exp = | RTrue : rel_exp | RFalse: rel_exp | RROp : r_op -> g_exp -> g_exp -> rel_exp | RBOp : b_op -> rel_exp -> rel_exp -> rel_exp | RNot : rel_exp -> rel_exp let rec g_exp_denotation (g:g_exp) (h_left:heap) (h_right:heap) :int = match g with | GConst n -> n | Left r -> sel h_left r | Right r -> sel h_right r | GIOp op g1 g2 -> match op with | Add -> g_exp_denotation g1 h_left h_right + g_exp_denotation g2 h_left h_right | Sub -> g_exp_denotation g1 h_left h_right - g_exp_denotation g2 h_left h_right let rec rel_exp_denotation (re:rel_exp) (h_left:heap) (h_right:heap) :bool = match re with | RTrue -> true | RFalse -> false | RROp op g1 g2 -> let n1 = g_exp_denotation g1 h_left h_right in let n2 = g_exp_denotation g2 h_left h_right in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | RBOp op re1 re2 -> let bc1 = rel_exp_denotation re1 h_left h_right in let bc2 = rel_exp_denotation re2 h_left h_right in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | RNot re1 -> not (rel_exp_denotation re1 h_left h_right) assume val x:id assume val y:id assume val z:id assume Distinct_vars: x <> y /\ y <> z /\ x <> z (* * removing redundant computation * proving com1 = x := y + 1; z := y + 1 * and com2 = x := y + 1; z := x * * relate two states with equal values of y to two states with equal values of x and z
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.IntStoreFixed.fst.checked", "FStar.DM4F.Heap.IntStoreFixed.fsti.checked" ], "interface_file": false, "source_file": "ProgramOptimizations.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ProgramOptimizations.com
Prims.Tot
[ "total" ]
[]
[ "ProgramOptimizations.Seq", "ProgramOptimizations.Assign", "ProgramOptimizations.x", "ProgramOptimizations.IOp", "ProgramOptimizations.Add", "ProgramOptimizations.Var", "ProgramOptimizations.y", "ProgramOptimizations.Const", "ProgramOptimizations.z" ]
[]
false
false
false
true
false
let com11 =
Seq (Assign x (IOp Add (Var y) (Const 1))) (Assign z (IOp Add (Var y) (Const 1)))
false
ProgramOptimizations.fst
ProgramOptimizations.rel21
val rel21 : ProgramOptimizations.rel_exp
let rel21 = RBOp And (RBOp And (RROp Eq (Left x) (Right x)) //Left x = Right x (RROp Gt (Left y) (GConst 2))) //Left y > 2 (RROp Gt (Right y) (GConst 2))
{ "file_name": "examples/rel/ProgramOptimizations.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 51, "end_line": 186, "start_col": 0, "start_line": 184 }
(* 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 ProgramOptimizations open FStar.DM4F.Heap.IntStoreFixed open FStar.DM4F.IntStoreFixed (* * language and examples from: * "Simple Relational Correctness Proofs for Static Analyses and Program Transformations" * https://research.microsoft.com/en-us/um/people/nick/correctnesspopl2004.pdf *) type var = id type i_op = | Add | Sub type i_exp = | Const : int -> i_exp | Var : id -> i_exp | IOp : i_op -> i_exp -> i_exp -> i_exp | UMinus: i_exp -> i_exp type r_op = | Lt | Gt | Eq type b_op = | And | Or type b_exp = | CTrue : b_exp | CFalse: b_exp | ROp : r_op -> i_exp -> i_exp -> b_exp | BOp : b_op -> b_exp -> b_exp -> b_exp | Not : b_exp -> b_exp type com = | Skip : com | Assign: var -> i_exp -> com | Seq : com -> com -> com | If : b_exp -> com -> com -> com let rec i_exp_denotation (e:i_exp) :ISNull int = match e with | Const n -> n | Var r -> !r | IOp op e1 e2 -> (let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in match op with | Add -> n1 + n2 | Sub -> n1 - n2) | UMinus e -> - (i_exp_denotation e) let rec b_exp_denotation (b:b_exp) :ISNull bool = match b with | CTrue -> true | CFalse -> false | ROp op e1 e2 -> let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | BOp op b1 b2 -> let bc1 = b_exp_denotation b1 in let bc2 = b_exp_denotation b2 in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | Not b -> not (b_exp_denotation b) let rec com_denotation (c:com) :ISNull unit = match c with | Skip -> () | Assign r e -> let n = i_exp_denotation e in write r n (* r := n does not work, as it goes to FStar.ST *) | Seq c1 c2 -> com_denotation c1; com_denotation c2 | If b c1 c2 -> if b_exp_denotation b then com_denotation c1 else com_denotation c2 type g_exp = | GConst: int -> g_exp | Left : id -> g_exp | Right : id -> g_exp | GIOp : i_op -> g_exp -> g_exp -> g_exp type rel_exp = | RTrue : rel_exp | RFalse: rel_exp | RROp : r_op -> g_exp -> g_exp -> rel_exp | RBOp : b_op -> rel_exp -> rel_exp -> rel_exp | RNot : rel_exp -> rel_exp let rec g_exp_denotation (g:g_exp) (h_left:heap) (h_right:heap) :int = match g with | GConst n -> n | Left r -> sel h_left r | Right r -> sel h_right r | GIOp op g1 g2 -> match op with | Add -> g_exp_denotation g1 h_left h_right + g_exp_denotation g2 h_left h_right | Sub -> g_exp_denotation g1 h_left h_right - g_exp_denotation g2 h_left h_right let rec rel_exp_denotation (re:rel_exp) (h_left:heap) (h_right:heap) :bool = match re with | RTrue -> true | RFalse -> false | RROp op g1 g2 -> let n1 = g_exp_denotation g1 h_left h_right in let n2 = g_exp_denotation g2 h_left h_right in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | RBOp op re1 re2 -> let bc1 = rel_exp_denotation re1 h_left h_right in let bc2 = rel_exp_denotation re2 h_left h_right in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | RNot re1 -> not (rel_exp_denotation re1 h_left h_right) assume val x:id assume val y:id assume val z:id assume Distinct_vars: x <> y /\ y <> z /\ x <> z (* * removing redundant computation * proving com1 = x := y + 1; z := y + 1 * and com2 = x := y + 1; z := x * * relate two states with equal values of y to two states with equal values of x and z *) let com11 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (IOp Add (Var y) (Const 1))) //z := y + 1 let com12 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (Var x)) //z := x let rel11 = RROp Eq (Left y) (Right y) //Left y = Right y let rel12 = RBOp And (RROp Eq (Left x) (Right x)) //Left x = Right x /\ (RROp Eq (Left z) (Right z)) //Left z = Right z let lemma_sound_optimization1 (h_left:heap) (h_right:heap) :Lemma (requires (rel_exp_denotation rel11 h_left h_right)) //h_left, h_right are related by rel1 (ensures (let _, h_left' = reify (com_denotation com11) h_left in let _, h_right' = reify (com_denotation com12) h_right in rel_exp_denotation rel12 h_left' h_right')) //[|com1|](h_left), [|com2|](h_right) are related by rel2 = () (* * dead code elimination * proving com1 = if x > 3 then y := x else y := 7 * and com2 = skip * are equivalent if all that the rest of the computation cares for is y > 2 *) let com21 = If (ROp Gt (Var x) (Const 3)) (Assign y (Var x)) (Assign y (Const 7)) //if x > 3 then y := x else y := 7 let com22 = Skip
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.IntStoreFixed.fst.checked", "FStar.DM4F.Heap.IntStoreFixed.fsti.checked" ], "interface_file": false, "source_file": "ProgramOptimizations.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ProgramOptimizations.rel_exp
Prims.Tot
[ "total" ]
[]
[ "ProgramOptimizations.RBOp", "ProgramOptimizations.And", "ProgramOptimizations.RROp", "ProgramOptimizations.Eq", "ProgramOptimizations.Left", "ProgramOptimizations.x", "ProgramOptimizations.Right", "ProgramOptimizations.Gt", "ProgramOptimizations.y", "ProgramOptimizations.GConst" ]
[]
false
false
false
true
false
let rel21 =
RBOp And (RBOp And (RROp Eq (Left x) (Right x)) (RROp Gt (Left y) (GConst 2))) (RROp Gt (Right y) (GConst 2))
false
ProgramOptimizations.fst
ProgramOptimizations.com32
val com32 : ProgramOptimizations.com
let com32 = Assign y (Const 3)
{ "file_name": "examples/rel/ProgramOptimizations.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 30, "end_line": 206, "start_col": 0, "start_line": 206 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module ProgramOptimizations open FStar.DM4F.Heap.IntStoreFixed open FStar.DM4F.IntStoreFixed (* * language and examples from: * "Simple Relational Correctness Proofs for Static Analyses and Program Transformations" * https://research.microsoft.com/en-us/um/people/nick/correctnesspopl2004.pdf *) type var = id type i_op = | Add | Sub type i_exp = | Const : int -> i_exp | Var : id -> i_exp | IOp : i_op -> i_exp -> i_exp -> i_exp | UMinus: i_exp -> i_exp type r_op = | Lt | Gt | Eq type b_op = | And | Or type b_exp = | CTrue : b_exp | CFalse: b_exp | ROp : r_op -> i_exp -> i_exp -> b_exp | BOp : b_op -> b_exp -> b_exp -> b_exp | Not : b_exp -> b_exp type com = | Skip : com | Assign: var -> i_exp -> com | Seq : com -> com -> com | If : b_exp -> com -> com -> com let rec i_exp_denotation (e:i_exp) :ISNull int = match e with | Const n -> n | Var r -> !r | IOp op e1 e2 -> (let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in match op with | Add -> n1 + n2 | Sub -> n1 - n2) | UMinus e -> - (i_exp_denotation e) let rec b_exp_denotation (b:b_exp) :ISNull bool = match b with | CTrue -> true | CFalse -> false | ROp op e1 e2 -> let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | BOp op b1 b2 -> let bc1 = b_exp_denotation b1 in let bc2 = b_exp_denotation b2 in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | Not b -> not (b_exp_denotation b) let rec com_denotation (c:com) :ISNull unit = match c with | Skip -> () | Assign r e -> let n = i_exp_denotation e in write r n (* r := n does not work, as it goes to FStar.ST *) | Seq c1 c2 -> com_denotation c1; com_denotation c2 | If b c1 c2 -> if b_exp_denotation b then com_denotation c1 else com_denotation c2 type g_exp = | GConst: int -> g_exp | Left : id -> g_exp | Right : id -> g_exp | GIOp : i_op -> g_exp -> g_exp -> g_exp type rel_exp = | RTrue : rel_exp | RFalse: rel_exp | RROp : r_op -> g_exp -> g_exp -> rel_exp | RBOp : b_op -> rel_exp -> rel_exp -> rel_exp | RNot : rel_exp -> rel_exp let rec g_exp_denotation (g:g_exp) (h_left:heap) (h_right:heap) :int = match g with | GConst n -> n | Left r -> sel h_left r | Right r -> sel h_right r | GIOp op g1 g2 -> match op with | Add -> g_exp_denotation g1 h_left h_right + g_exp_denotation g2 h_left h_right | Sub -> g_exp_denotation g1 h_left h_right - g_exp_denotation g2 h_left h_right let rec rel_exp_denotation (re:rel_exp) (h_left:heap) (h_right:heap) :bool = match re with | RTrue -> true | RFalse -> false | RROp op g1 g2 -> let n1 = g_exp_denotation g1 h_left h_right in let n2 = g_exp_denotation g2 h_left h_right in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | RBOp op re1 re2 -> let bc1 = rel_exp_denotation re1 h_left h_right in let bc2 = rel_exp_denotation re2 h_left h_right in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | RNot re1 -> not (rel_exp_denotation re1 h_left h_right) assume val x:id assume val y:id assume val z:id assume Distinct_vars: x <> y /\ y <> z /\ x <> z (* * removing redundant computation * proving com1 = x := y + 1; z := y + 1 * and com2 = x := y + 1; z := x * * relate two states with equal values of y to two states with equal values of x and z *) let com11 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (IOp Add (Var y) (Const 1))) //z := y + 1 let com12 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (Var x)) //z := x let rel11 = RROp Eq (Left y) (Right y) //Left y = Right y let rel12 = RBOp And (RROp Eq (Left x) (Right x)) //Left x = Right x /\ (RROp Eq (Left z) (Right z)) //Left z = Right z let lemma_sound_optimization1 (h_left:heap) (h_right:heap) :Lemma (requires (rel_exp_denotation rel11 h_left h_right)) //h_left, h_right are related by rel1 (ensures (let _, h_left' = reify (com_denotation com11) h_left in let _, h_right' = reify (com_denotation com12) h_right in rel_exp_denotation rel12 h_left' h_right')) //[|com1|](h_left), [|com2|](h_right) are related by rel2 = () (* * dead code elimination * proving com1 = if x > 3 then y := x else y := 7 * and com2 = skip * are equivalent if all that the rest of the computation cares for is y > 2 *) let com21 = If (ROp Gt (Var x) (Const 3)) (Assign y (Var x)) (Assign y (Const 7)) //if x > 3 then y := x else y := 7 let com22 = Skip let rel21 = RBOp And (RBOp And (RROp Eq (Left x) (Right x)) //Left x = Right x (RROp Gt (Left y) (GConst 2))) //Left y > 2 (RROp Gt (Right y) (GConst 2)) //Right y > 2 let rel22 = RBOp And (RROp Gt (Left y) (GConst 2)) //Left y > 2 (RROp Gt (Right y) (GConst 2)) //Right y > 2 let lemma_sound_optimization2 (h_left:heap) (h_right:heap) :Lemma (requires (rel_exp_denotation rel21 h_left h_right)) (ensures (let _, h_left' = reify (com_denotation com21) h_left in let _, h_right' = reify (com_denotation com22) h_right in rel_exp_denotation rel22 h_left' h_right')) = () (* * optimization * proving com1 = if x = 3 then y := x else y := 3 * and com2 = y := 3 * are equivalent *) let com31 = If (ROp Eq (Var x) (Const 3)) (Assign y (Var x))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.IntStoreFixed.fst.checked", "FStar.DM4F.Heap.IntStoreFixed.fsti.checked" ], "interface_file": false, "source_file": "ProgramOptimizations.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ProgramOptimizations.com
Prims.Tot
[ "total" ]
[]
[ "ProgramOptimizations.Assign", "ProgramOptimizations.y", "ProgramOptimizations.Const" ]
[]
false
false
false
true
false
let com32 =
Assign y (Const 3)
false
ProgramOptimizations.fst
ProgramOptimizations.rel31
val rel31 : ProgramOptimizations.rel_exp
let rel31 = RTrue
{ "file_name": "examples/rel/ProgramOptimizations.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 17, "end_line": 208, "start_col": 0, "start_line": 208 }
(* 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 ProgramOptimizations open FStar.DM4F.Heap.IntStoreFixed open FStar.DM4F.IntStoreFixed (* * language and examples from: * "Simple Relational Correctness Proofs for Static Analyses and Program Transformations" * https://research.microsoft.com/en-us/um/people/nick/correctnesspopl2004.pdf *) type var = id type i_op = | Add | Sub type i_exp = | Const : int -> i_exp | Var : id -> i_exp | IOp : i_op -> i_exp -> i_exp -> i_exp | UMinus: i_exp -> i_exp type r_op = | Lt | Gt | Eq type b_op = | And | Or type b_exp = | CTrue : b_exp | CFalse: b_exp | ROp : r_op -> i_exp -> i_exp -> b_exp | BOp : b_op -> b_exp -> b_exp -> b_exp | Not : b_exp -> b_exp type com = | Skip : com | Assign: var -> i_exp -> com | Seq : com -> com -> com | If : b_exp -> com -> com -> com let rec i_exp_denotation (e:i_exp) :ISNull int = match e with | Const n -> n | Var r -> !r | IOp op e1 e2 -> (let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in match op with | Add -> n1 + n2 | Sub -> n1 - n2) | UMinus e -> - (i_exp_denotation e) let rec b_exp_denotation (b:b_exp) :ISNull bool = match b with | CTrue -> true | CFalse -> false | ROp op e1 e2 -> let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | BOp op b1 b2 -> let bc1 = b_exp_denotation b1 in let bc2 = b_exp_denotation b2 in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | Not b -> not (b_exp_denotation b) let rec com_denotation (c:com) :ISNull unit = match c with | Skip -> () | Assign r e -> let n = i_exp_denotation e in write r n (* r := n does not work, as it goes to FStar.ST *) | Seq c1 c2 -> com_denotation c1; com_denotation c2 | If b c1 c2 -> if b_exp_denotation b then com_denotation c1 else com_denotation c2 type g_exp = | GConst: int -> g_exp | Left : id -> g_exp | Right : id -> g_exp | GIOp : i_op -> g_exp -> g_exp -> g_exp type rel_exp = | RTrue : rel_exp | RFalse: rel_exp | RROp : r_op -> g_exp -> g_exp -> rel_exp | RBOp : b_op -> rel_exp -> rel_exp -> rel_exp | RNot : rel_exp -> rel_exp let rec g_exp_denotation (g:g_exp) (h_left:heap) (h_right:heap) :int = match g with | GConst n -> n | Left r -> sel h_left r | Right r -> sel h_right r | GIOp op g1 g2 -> match op with | Add -> g_exp_denotation g1 h_left h_right + g_exp_denotation g2 h_left h_right | Sub -> g_exp_denotation g1 h_left h_right - g_exp_denotation g2 h_left h_right let rec rel_exp_denotation (re:rel_exp) (h_left:heap) (h_right:heap) :bool = match re with | RTrue -> true | RFalse -> false | RROp op g1 g2 -> let n1 = g_exp_denotation g1 h_left h_right in let n2 = g_exp_denotation g2 h_left h_right in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | RBOp op re1 re2 -> let bc1 = rel_exp_denotation re1 h_left h_right in let bc2 = rel_exp_denotation re2 h_left h_right in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | RNot re1 -> not (rel_exp_denotation re1 h_left h_right) assume val x:id assume val y:id assume val z:id assume Distinct_vars: x <> y /\ y <> z /\ x <> z (* * removing redundant computation * proving com1 = x := y + 1; z := y + 1 * and com2 = x := y + 1; z := x * * relate two states with equal values of y to two states with equal values of x and z *) let com11 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (IOp Add (Var y) (Const 1))) //z := y + 1 let com12 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (Var x)) //z := x let rel11 = RROp Eq (Left y) (Right y) //Left y = Right y let rel12 = RBOp And (RROp Eq (Left x) (Right x)) //Left x = Right x /\ (RROp Eq (Left z) (Right z)) //Left z = Right z let lemma_sound_optimization1 (h_left:heap) (h_right:heap) :Lemma (requires (rel_exp_denotation rel11 h_left h_right)) //h_left, h_right are related by rel1 (ensures (let _, h_left' = reify (com_denotation com11) h_left in let _, h_right' = reify (com_denotation com12) h_right in rel_exp_denotation rel12 h_left' h_right')) //[|com1|](h_left), [|com2|](h_right) are related by rel2 = () (* * dead code elimination * proving com1 = if x > 3 then y := x else y := 7 * and com2 = skip * are equivalent if all that the rest of the computation cares for is y > 2 *) let com21 = If (ROp Gt (Var x) (Const 3)) (Assign y (Var x)) (Assign y (Const 7)) //if x > 3 then y := x else y := 7 let com22 = Skip let rel21 = RBOp And (RBOp And (RROp Eq (Left x) (Right x)) //Left x = Right x (RROp Gt (Left y) (GConst 2))) //Left y > 2 (RROp Gt (Right y) (GConst 2)) //Right y > 2 let rel22 = RBOp And (RROp Gt (Left y) (GConst 2)) //Left y > 2 (RROp Gt (Right y) (GConst 2)) //Right y > 2 let lemma_sound_optimization2 (h_left:heap) (h_right:heap) :Lemma (requires (rel_exp_denotation rel21 h_left h_right)) (ensures (let _, h_left' = reify (com_denotation com21) h_left in let _, h_right' = reify (com_denotation com22) h_right in rel_exp_denotation rel22 h_left' h_right')) = () (* * optimization * proving com1 = if x = 3 then y := x else y := 3 * and com2 = y := 3 * are equivalent *) let com31 = If (ROp Eq (Var x) (Const 3)) (Assign y (Var x)) (Assign y (Const 3)) //if x = 3 then y := x else y := 3 let com32 = Assign y (Const 3) //y := 3
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.IntStoreFixed.fst.checked", "FStar.DM4F.Heap.IntStoreFixed.fsti.checked" ], "interface_file": false, "source_file": "ProgramOptimizations.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ProgramOptimizations.rel_exp
Prims.Tot
[ "total" ]
[]
[ "ProgramOptimizations.RTrue" ]
[]
false
false
false
true
false
let rel31 =
RTrue
false
ProgramOptimizations.fst
ProgramOptimizations.rel32
val rel32 : ProgramOptimizations.rel_exp
let rel32 = RBOp And (RROp Eq (Left y) (GConst 3)) //Left y = 3 (RROp Eq (Right y) (GConst 3))
{ "file_name": "examples/rel/ProgramOptimizations.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 51, "end_line": 210, "start_col": 0, "start_line": 209 }
(* 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 ProgramOptimizations open FStar.DM4F.Heap.IntStoreFixed open FStar.DM4F.IntStoreFixed (* * language and examples from: * "Simple Relational Correctness Proofs for Static Analyses and Program Transformations" * https://research.microsoft.com/en-us/um/people/nick/correctnesspopl2004.pdf *) type var = id type i_op = | Add | Sub type i_exp = | Const : int -> i_exp | Var : id -> i_exp | IOp : i_op -> i_exp -> i_exp -> i_exp | UMinus: i_exp -> i_exp type r_op = | Lt | Gt | Eq type b_op = | And | Or type b_exp = | CTrue : b_exp | CFalse: b_exp | ROp : r_op -> i_exp -> i_exp -> b_exp | BOp : b_op -> b_exp -> b_exp -> b_exp | Not : b_exp -> b_exp type com = | Skip : com | Assign: var -> i_exp -> com | Seq : com -> com -> com | If : b_exp -> com -> com -> com let rec i_exp_denotation (e:i_exp) :ISNull int = match e with | Const n -> n | Var r -> !r | IOp op e1 e2 -> (let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in match op with | Add -> n1 + n2 | Sub -> n1 - n2) | UMinus e -> - (i_exp_denotation e) let rec b_exp_denotation (b:b_exp) :ISNull bool = match b with | CTrue -> true | CFalse -> false | ROp op e1 e2 -> let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | BOp op b1 b2 -> let bc1 = b_exp_denotation b1 in let bc2 = b_exp_denotation b2 in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | Not b -> not (b_exp_denotation b) let rec com_denotation (c:com) :ISNull unit = match c with | Skip -> () | Assign r e -> let n = i_exp_denotation e in write r n (* r := n does not work, as it goes to FStar.ST *) | Seq c1 c2 -> com_denotation c1; com_denotation c2 | If b c1 c2 -> if b_exp_denotation b then com_denotation c1 else com_denotation c2 type g_exp = | GConst: int -> g_exp | Left : id -> g_exp | Right : id -> g_exp | GIOp : i_op -> g_exp -> g_exp -> g_exp type rel_exp = | RTrue : rel_exp | RFalse: rel_exp | RROp : r_op -> g_exp -> g_exp -> rel_exp | RBOp : b_op -> rel_exp -> rel_exp -> rel_exp | RNot : rel_exp -> rel_exp let rec g_exp_denotation (g:g_exp) (h_left:heap) (h_right:heap) :int = match g with | GConst n -> n | Left r -> sel h_left r | Right r -> sel h_right r | GIOp op g1 g2 -> match op with | Add -> g_exp_denotation g1 h_left h_right + g_exp_denotation g2 h_left h_right | Sub -> g_exp_denotation g1 h_left h_right - g_exp_denotation g2 h_left h_right let rec rel_exp_denotation (re:rel_exp) (h_left:heap) (h_right:heap) :bool = match re with | RTrue -> true | RFalse -> false | RROp op g1 g2 -> let n1 = g_exp_denotation g1 h_left h_right in let n2 = g_exp_denotation g2 h_left h_right in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | RBOp op re1 re2 -> let bc1 = rel_exp_denotation re1 h_left h_right in let bc2 = rel_exp_denotation re2 h_left h_right in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | RNot re1 -> not (rel_exp_denotation re1 h_left h_right) assume val x:id assume val y:id assume val z:id assume Distinct_vars: x <> y /\ y <> z /\ x <> z (* * removing redundant computation * proving com1 = x := y + 1; z := y + 1 * and com2 = x := y + 1; z := x * * relate two states with equal values of y to two states with equal values of x and z *) let com11 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (IOp Add (Var y) (Const 1))) //z := y + 1 let com12 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (Var x)) //z := x let rel11 = RROp Eq (Left y) (Right y) //Left y = Right y let rel12 = RBOp And (RROp Eq (Left x) (Right x)) //Left x = Right x /\ (RROp Eq (Left z) (Right z)) //Left z = Right z let lemma_sound_optimization1 (h_left:heap) (h_right:heap) :Lemma (requires (rel_exp_denotation rel11 h_left h_right)) //h_left, h_right are related by rel1 (ensures (let _, h_left' = reify (com_denotation com11) h_left in let _, h_right' = reify (com_denotation com12) h_right in rel_exp_denotation rel12 h_left' h_right')) //[|com1|](h_left), [|com2|](h_right) are related by rel2 = () (* * dead code elimination * proving com1 = if x > 3 then y := x else y := 7 * and com2 = skip * are equivalent if all that the rest of the computation cares for is y > 2 *) let com21 = If (ROp Gt (Var x) (Const 3)) (Assign y (Var x)) (Assign y (Const 7)) //if x > 3 then y := x else y := 7 let com22 = Skip let rel21 = RBOp And (RBOp And (RROp Eq (Left x) (Right x)) //Left x = Right x (RROp Gt (Left y) (GConst 2))) //Left y > 2 (RROp Gt (Right y) (GConst 2)) //Right y > 2 let rel22 = RBOp And (RROp Gt (Left y) (GConst 2)) //Left y > 2 (RROp Gt (Right y) (GConst 2)) //Right y > 2 let lemma_sound_optimization2 (h_left:heap) (h_right:heap) :Lemma (requires (rel_exp_denotation rel21 h_left h_right)) (ensures (let _, h_left' = reify (com_denotation com21) h_left in let _, h_right' = reify (com_denotation com22) h_right in rel_exp_denotation rel22 h_left' h_right')) = () (* * optimization * proving com1 = if x = 3 then y := x else y := 3 * and com2 = y := 3 * are equivalent *) let com31 = If (ROp Eq (Var x) (Const 3)) (Assign y (Var x)) (Assign y (Const 3)) //if x = 3 then y := x else y := 3 let com32 = Assign y (Const 3) //y := 3
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.IntStoreFixed.fst.checked", "FStar.DM4F.Heap.IntStoreFixed.fsti.checked" ], "interface_file": false, "source_file": "ProgramOptimizations.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ProgramOptimizations.rel_exp
Prims.Tot
[ "total" ]
[]
[ "ProgramOptimizations.RBOp", "ProgramOptimizations.And", "ProgramOptimizations.RROp", "ProgramOptimizations.Eq", "ProgramOptimizations.Left", "ProgramOptimizations.y", "ProgramOptimizations.GConst", "ProgramOptimizations.Right" ]
[]
false
false
false
true
false
let rel32 =
RBOp And (RROp Eq (Left y) (GConst 3)) (RROp Eq (Right y) (GConst 3))
false
ProgramOptimizations.fst
ProgramOptimizations.com42
val com42 : ProgramOptimizations.com
let com42 = Seq (Assign x (Var y)) //x := y; (Assign z (IOp Add (Var z) (Var x)))
{ "file_name": "examples/rel/ProgramOptimizations.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 52, "end_line": 229, "start_col": 0, "start_line": 228 }
(* 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 ProgramOptimizations open FStar.DM4F.Heap.IntStoreFixed open FStar.DM4F.IntStoreFixed (* * language and examples from: * "Simple Relational Correctness Proofs for Static Analyses and Program Transformations" * https://research.microsoft.com/en-us/um/people/nick/correctnesspopl2004.pdf *) type var = id type i_op = | Add | Sub type i_exp = | Const : int -> i_exp | Var : id -> i_exp | IOp : i_op -> i_exp -> i_exp -> i_exp | UMinus: i_exp -> i_exp type r_op = | Lt | Gt | Eq type b_op = | And | Or type b_exp = | CTrue : b_exp | CFalse: b_exp | ROp : r_op -> i_exp -> i_exp -> b_exp | BOp : b_op -> b_exp -> b_exp -> b_exp | Not : b_exp -> b_exp type com = | Skip : com | Assign: var -> i_exp -> com | Seq : com -> com -> com | If : b_exp -> com -> com -> com let rec i_exp_denotation (e:i_exp) :ISNull int = match e with | Const n -> n | Var r -> !r | IOp op e1 e2 -> (let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in match op with | Add -> n1 + n2 | Sub -> n1 - n2) | UMinus e -> - (i_exp_denotation e) let rec b_exp_denotation (b:b_exp) :ISNull bool = match b with | CTrue -> true | CFalse -> false | ROp op e1 e2 -> let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | BOp op b1 b2 -> let bc1 = b_exp_denotation b1 in let bc2 = b_exp_denotation b2 in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | Not b -> not (b_exp_denotation b) let rec com_denotation (c:com) :ISNull unit = match c with | Skip -> () | Assign r e -> let n = i_exp_denotation e in write r n (* r := n does not work, as it goes to FStar.ST *) | Seq c1 c2 -> com_denotation c1; com_denotation c2 | If b c1 c2 -> if b_exp_denotation b then com_denotation c1 else com_denotation c2 type g_exp = | GConst: int -> g_exp | Left : id -> g_exp | Right : id -> g_exp | GIOp : i_op -> g_exp -> g_exp -> g_exp type rel_exp = | RTrue : rel_exp | RFalse: rel_exp | RROp : r_op -> g_exp -> g_exp -> rel_exp | RBOp : b_op -> rel_exp -> rel_exp -> rel_exp | RNot : rel_exp -> rel_exp let rec g_exp_denotation (g:g_exp) (h_left:heap) (h_right:heap) :int = match g with | GConst n -> n | Left r -> sel h_left r | Right r -> sel h_right r | GIOp op g1 g2 -> match op with | Add -> g_exp_denotation g1 h_left h_right + g_exp_denotation g2 h_left h_right | Sub -> g_exp_denotation g1 h_left h_right - g_exp_denotation g2 h_left h_right let rec rel_exp_denotation (re:rel_exp) (h_left:heap) (h_right:heap) :bool = match re with | RTrue -> true | RFalse -> false | RROp op g1 g2 -> let n1 = g_exp_denotation g1 h_left h_right in let n2 = g_exp_denotation g2 h_left h_right in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | RBOp op re1 re2 -> let bc1 = rel_exp_denotation re1 h_left h_right in let bc2 = rel_exp_denotation re2 h_left h_right in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | RNot re1 -> not (rel_exp_denotation re1 h_left h_right) assume val x:id assume val y:id assume val z:id assume Distinct_vars: x <> y /\ y <> z /\ x <> z (* * removing redundant computation * proving com1 = x := y + 1; z := y + 1 * and com2 = x := y + 1; z := x * * relate two states with equal values of y to two states with equal values of x and z *) let com11 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (IOp Add (Var y) (Const 1))) //z := y + 1 let com12 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (Var x)) //z := x let rel11 = RROp Eq (Left y) (Right y) //Left y = Right y let rel12 = RBOp And (RROp Eq (Left x) (Right x)) //Left x = Right x /\ (RROp Eq (Left z) (Right z)) //Left z = Right z let lemma_sound_optimization1 (h_left:heap) (h_right:heap) :Lemma (requires (rel_exp_denotation rel11 h_left h_right)) //h_left, h_right are related by rel1 (ensures (let _, h_left' = reify (com_denotation com11) h_left in let _, h_right' = reify (com_denotation com12) h_right in rel_exp_denotation rel12 h_left' h_right')) //[|com1|](h_left), [|com2|](h_right) are related by rel2 = () (* * dead code elimination * proving com1 = if x > 3 then y := x else y := 7 * and com2 = skip * are equivalent if all that the rest of the computation cares for is y > 2 *) let com21 = If (ROp Gt (Var x) (Const 3)) (Assign y (Var x)) (Assign y (Const 7)) //if x > 3 then y := x else y := 7 let com22 = Skip let rel21 = RBOp And (RBOp And (RROp Eq (Left x) (Right x)) //Left x = Right x (RROp Gt (Left y) (GConst 2))) //Left y > 2 (RROp Gt (Right y) (GConst 2)) //Right y > 2 let rel22 = RBOp And (RROp Gt (Left y) (GConst 2)) //Left y > 2 (RROp Gt (Right y) (GConst 2)) //Right y > 2 let lemma_sound_optimization2 (h_left:heap) (h_right:heap) :Lemma (requires (rel_exp_denotation rel21 h_left h_right)) (ensures (let _, h_left' = reify (com_denotation com21) h_left in let _, h_right' = reify (com_denotation com22) h_right in rel_exp_denotation rel22 h_left' h_right')) = () (* * optimization * proving com1 = if x = 3 then y := x else y := 3 * and com2 = y := 3 * are equivalent *) let com31 = If (ROp Eq (Var x) (Const 3)) (Assign y (Var x)) (Assign y (Const 3)) //if x = 3 then y := x else y := 3 let com32 = Assign y (Const 3) //y := 3 let rel31 = RTrue let rel32 = RBOp And (RROp Eq (Left y) (GConst 3)) //Left y = 3 (RROp Eq (Right y) (GConst 3)) //Right y = 3 let lemma_sound_optimization3 (h_left:heap) (h_right:heap) :Lemma (requires (rel_exp_denotation rel31 h_left h_right)) (ensures (let _, h_left' = reify (com_denotation com31) h_left in let _, h_right' = reify (com_denotation com32) h_right in rel_exp_denotation rel32 h_left' h_right')) = () (* * optimization * proving com1 = x := -y; z := z - x; x := -x and com2 = x := y; z := z + x * are equivalent *) let com41 = Seq (Assign x (UMinus (Var y))) //x := -y; (Seq (Assign z (IOp Sub (Var z) (Var x))) //z := z - x;
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.IntStoreFixed.fst.checked", "FStar.DM4F.Heap.IntStoreFixed.fsti.checked" ], "interface_file": false, "source_file": "ProgramOptimizations.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ProgramOptimizations.com
Prims.Tot
[ "total" ]
[]
[ "ProgramOptimizations.Seq", "ProgramOptimizations.Assign", "ProgramOptimizations.x", "ProgramOptimizations.Var", "ProgramOptimizations.y", "ProgramOptimizations.z", "ProgramOptimizations.IOp", "ProgramOptimizations.Add" ]
[]
false
false
false
true
false
let com42 =
Seq (Assign x (Var y)) (Assign z (IOp Add (Var z) (Var x)))
false
ProgramOptimizations.fst
ProgramOptimizations.com41
val com41 : ProgramOptimizations.com
let com41 = Seq (Assign x (UMinus (Var y))) //x := -y; (Seq (Assign z (IOp Sub (Var z) (Var x))) //z := z - x; (Assign x (UMinus (Var x))))
{ "file_name": "examples/rel/ProgramOptimizations.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 35, "end_line": 227, "start_col": 0, "start_line": 225 }
(* 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 ProgramOptimizations open FStar.DM4F.Heap.IntStoreFixed open FStar.DM4F.IntStoreFixed (* * language and examples from: * "Simple Relational Correctness Proofs for Static Analyses and Program Transformations" * https://research.microsoft.com/en-us/um/people/nick/correctnesspopl2004.pdf *) type var = id type i_op = | Add | Sub type i_exp = | Const : int -> i_exp | Var : id -> i_exp | IOp : i_op -> i_exp -> i_exp -> i_exp | UMinus: i_exp -> i_exp type r_op = | Lt | Gt | Eq type b_op = | And | Or type b_exp = | CTrue : b_exp | CFalse: b_exp | ROp : r_op -> i_exp -> i_exp -> b_exp | BOp : b_op -> b_exp -> b_exp -> b_exp | Not : b_exp -> b_exp type com = | Skip : com | Assign: var -> i_exp -> com | Seq : com -> com -> com | If : b_exp -> com -> com -> com let rec i_exp_denotation (e:i_exp) :ISNull int = match e with | Const n -> n | Var r -> !r | IOp op e1 e2 -> (let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in match op with | Add -> n1 + n2 | Sub -> n1 - n2) | UMinus e -> - (i_exp_denotation e) let rec b_exp_denotation (b:b_exp) :ISNull bool = match b with | CTrue -> true | CFalse -> false | ROp op e1 e2 -> let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | BOp op b1 b2 -> let bc1 = b_exp_denotation b1 in let bc2 = b_exp_denotation b2 in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | Not b -> not (b_exp_denotation b) let rec com_denotation (c:com) :ISNull unit = match c with | Skip -> () | Assign r e -> let n = i_exp_denotation e in write r n (* r := n does not work, as it goes to FStar.ST *) | Seq c1 c2 -> com_denotation c1; com_denotation c2 | If b c1 c2 -> if b_exp_denotation b then com_denotation c1 else com_denotation c2 type g_exp = | GConst: int -> g_exp | Left : id -> g_exp | Right : id -> g_exp | GIOp : i_op -> g_exp -> g_exp -> g_exp type rel_exp = | RTrue : rel_exp | RFalse: rel_exp | RROp : r_op -> g_exp -> g_exp -> rel_exp | RBOp : b_op -> rel_exp -> rel_exp -> rel_exp | RNot : rel_exp -> rel_exp let rec g_exp_denotation (g:g_exp) (h_left:heap) (h_right:heap) :int = match g with | GConst n -> n | Left r -> sel h_left r | Right r -> sel h_right r | GIOp op g1 g2 -> match op with | Add -> g_exp_denotation g1 h_left h_right + g_exp_denotation g2 h_left h_right | Sub -> g_exp_denotation g1 h_left h_right - g_exp_denotation g2 h_left h_right let rec rel_exp_denotation (re:rel_exp) (h_left:heap) (h_right:heap) :bool = match re with | RTrue -> true | RFalse -> false | RROp op g1 g2 -> let n1 = g_exp_denotation g1 h_left h_right in let n2 = g_exp_denotation g2 h_left h_right in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | RBOp op re1 re2 -> let bc1 = rel_exp_denotation re1 h_left h_right in let bc2 = rel_exp_denotation re2 h_left h_right in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | RNot re1 -> not (rel_exp_denotation re1 h_left h_right) assume val x:id assume val y:id assume val z:id assume Distinct_vars: x <> y /\ y <> z /\ x <> z (* * removing redundant computation * proving com1 = x := y + 1; z := y + 1 * and com2 = x := y + 1; z := x * * relate two states with equal values of y to two states with equal values of x and z *) let com11 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (IOp Add (Var y) (Const 1))) //z := y + 1 let com12 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (Var x)) //z := x let rel11 = RROp Eq (Left y) (Right y) //Left y = Right y let rel12 = RBOp And (RROp Eq (Left x) (Right x)) //Left x = Right x /\ (RROp Eq (Left z) (Right z)) //Left z = Right z let lemma_sound_optimization1 (h_left:heap) (h_right:heap) :Lemma (requires (rel_exp_denotation rel11 h_left h_right)) //h_left, h_right are related by rel1 (ensures (let _, h_left' = reify (com_denotation com11) h_left in let _, h_right' = reify (com_denotation com12) h_right in rel_exp_denotation rel12 h_left' h_right')) //[|com1|](h_left), [|com2|](h_right) are related by rel2 = () (* * dead code elimination * proving com1 = if x > 3 then y := x else y := 7 * and com2 = skip * are equivalent if all that the rest of the computation cares for is y > 2 *) let com21 = If (ROp Gt (Var x) (Const 3)) (Assign y (Var x)) (Assign y (Const 7)) //if x > 3 then y := x else y := 7 let com22 = Skip let rel21 = RBOp And (RBOp And (RROp Eq (Left x) (Right x)) //Left x = Right x (RROp Gt (Left y) (GConst 2))) //Left y > 2 (RROp Gt (Right y) (GConst 2)) //Right y > 2 let rel22 = RBOp And (RROp Gt (Left y) (GConst 2)) //Left y > 2 (RROp Gt (Right y) (GConst 2)) //Right y > 2 let lemma_sound_optimization2 (h_left:heap) (h_right:heap) :Lemma (requires (rel_exp_denotation rel21 h_left h_right)) (ensures (let _, h_left' = reify (com_denotation com21) h_left in let _, h_right' = reify (com_denotation com22) h_right in rel_exp_denotation rel22 h_left' h_right')) = () (* * optimization * proving com1 = if x = 3 then y := x else y := 3 * and com2 = y := 3 * are equivalent *) let com31 = If (ROp Eq (Var x) (Const 3)) (Assign y (Var x)) (Assign y (Const 3)) //if x = 3 then y := x else y := 3 let com32 = Assign y (Const 3) //y := 3 let rel31 = RTrue let rel32 = RBOp And (RROp Eq (Left y) (GConst 3)) //Left y = 3 (RROp Eq (Right y) (GConst 3)) //Right y = 3 let lemma_sound_optimization3 (h_left:heap) (h_right:heap) :Lemma (requires (rel_exp_denotation rel31 h_left h_right)) (ensures (let _, h_left' = reify (com_denotation com31) h_left in let _, h_right' = reify (com_denotation com32) h_right in rel_exp_denotation rel32 h_left' h_right')) = () (* * optimization * proving com1 = x := -y; z := z - x; x := -x and com2 = x := y; z := z + x * are equivalent
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.IntStoreFixed.fst.checked", "FStar.DM4F.Heap.IntStoreFixed.fsti.checked" ], "interface_file": false, "source_file": "ProgramOptimizations.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ProgramOptimizations.com
Prims.Tot
[ "total" ]
[]
[ "ProgramOptimizations.Seq", "ProgramOptimizations.Assign", "ProgramOptimizations.x", "ProgramOptimizations.UMinus", "ProgramOptimizations.Var", "ProgramOptimizations.y", "ProgramOptimizations.z", "ProgramOptimizations.IOp", "ProgramOptimizations.Sub" ]
[]
false
false
false
true
false
let com41 =
Seq (Assign x (UMinus (Var y))) (Seq (Assign z (IOp Sub (Var z) (Var x))) (Assign x (UMinus (Var x))))
false
ProgramOptimizations.fst
ProgramOptimizations.rhl
val rhl : c1: ProgramOptimizations.com -> c2: ProgramOptimizations.com -> re1: ProgramOptimizations.rel_exp -> re2: ProgramOptimizations.rel_exp -> Prims.logical
let rhl (c1:com) (c2:com) (re1:rel_exp) (re2:rel_exp) = forall (h_left:heap) (h_right:heap). rel_exp_denotation re1 h_left h_right ==> (let _, h_left' = reify (com_denotation c1) h_left in let _, h_right' = reify (com_denotation c2) h_right in rel_exp_denotation re2 h_left' h_right')
{ "file_name": "examples/rel/ProgramOptimizations.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 47, "end_line": 248, "start_col": 0, "start_line": 244 }
(* 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 ProgramOptimizations open FStar.DM4F.Heap.IntStoreFixed open FStar.DM4F.IntStoreFixed (* * language and examples from: * "Simple Relational Correctness Proofs for Static Analyses and Program Transformations" * https://research.microsoft.com/en-us/um/people/nick/correctnesspopl2004.pdf *) type var = id type i_op = | Add | Sub type i_exp = | Const : int -> i_exp | Var : id -> i_exp | IOp : i_op -> i_exp -> i_exp -> i_exp | UMinus: i_exp -> i_exp type r_op = | Lt | Gt | Eq type b_op = | And | Or type b_exp = | CTrue : b_exp | CFalse: b_exp | ROp : r_op -> i_exp -> i_exp -> b_exp | BOp : b_op -> b_exp -> b_exp -> b_exp | Not : b_exp -> b_exp type com = | Skip : com | Assign: var -> i_exp -> com | Seq : com -> com -> com | If : b_exp -> com -> com -> com let rec i_exp_denotation (e:i_exp) :ISNull int = match e with | Const n -> n | Var r -> !r | IOp op e1 e2 -> (let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in match op with | Add -> n1 + n2 | Sub -> n1 - n2) | UMinus e -> - (i_exp_denotation e) let rec b_exp_denotation (b:b_exp) :ISNull bool = match b with | CTrue -> true | CFalse -> false | ROp op e1 e2 -> let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | BOp op b1 b2 -> let bc1 = b_exp_denotation b1 in let bc2 = b_exp_denotation b2 in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | Not b -> not (b_exp_denotation b) let rec com_denotation (c:com) :ISNull unit = match c with | Skip -> () | Assign r e -> let n = i_exp_denotation e in write r n (* r := n does not work, as it goes to FStar.ST *) | Seq c1 c2 -> com_denotation c1; com_denotation c2 | If b c1 c2 -> if b_exp_denotation b then com_denotation c1 else com_denotation c2 type g_exp = | GConst: int -> g_exp | Left : id -> g_exp | Right : id -> g_exp | GIOp : i_op -> g_exp -> g_exp -> g_exp type rel_exp = | RTrue : rel_exp | RFalse: rel_exp | RROp : r_op -> g_exp -> g_exp -> rel_exp | RBOp : b_op -> rel_exp -> rel_exp -> rel_exp | RNot : rel_exp -> rel_exp let rec g_exp_denotation (g:g_exp) (h_left:heap) (h_right:heap) :int = match g with | GConst n -> n | Left r -> sel h_left r | Right r -> sel h_right r | GIOp op g1 g2 -> match op with | Add -> g_exp_denotation g1 h_left h_right + g_exp_denotation g2 h_left h_right | Sub -> g_exp_denotation g1 h_left h_right - g_exp_denotation g2 h_left h_right let rec rel_exp_denotation (re:rel_exp) (h_left:heap) (h_right:heap) :bool = match re with | RTrue -> true | RFalse -> false | RROp op g1 g2 -> let n1 = g_exp_denotation g1 h_left h_right in let n2 = g_exp_denotation g2 h_left h_right in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | RBOp op re1 re2 -> let bc1 = rel_exp_denotation re1 h_left h_right in let bc2 = rel_exp_denotation re2 h_left h_right in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | RNot re1 -> not (rel_exp_denotation re1 h_left h_right) assume val x:id assume val y:id assume val z:id assume Distinct_vars: x <> y /\ y <> z /\ x <> z (* * removing redundant computation * proving com1 = x := y + 1; z := y + 1 * and com2 = x := y + 1; z := x * * relate two states with equal values of y to two states with equal values of x and z *) let com11 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (IOp Add (Var y) (Const 1))) //z := y + 1 let com12 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (Var x)) //z := x let rel11 = RROp Eq (Left y) (Right y) //Left y = Right y let rel12 = RBOp And (RROp Eq (Left x) (Right x)) //Left x = Right x /\ (RROp Eq (Left z) (Right z)) //Left z = Right z let lemma_sound_optimization1 (h_left:heap) (h_right:heap) :Lemma (requires (rel_exp_denotation rel11 h_left h_right)) //h_left, h_right are related by rel1 (ensures (let _, h_left' = reify (com_denotation com11) h_left in let _, h_right' = reify (com_denotation com12) h_right in rel_exp_denotation rel12 h_left' h_right')) //[|com1|](h_left), [|com2|](h_right) are related by rel2 = () (* * dead code elimination * proving com1 = if x > 3 then y := x else y := 7 * and com2 = skip * are equivalent if all that the rest of the computation cares for is y > 2 *) let com21 = If (ROp Gt (Var x) (Const 3)) (Assign y (Var x)) (Assign y (Const 7)) //if x > 3 then y := x else y := 7 let com22 = Skip let rel21 = RBOp And (RBOp And (RROp Eq (Left x) (Right x)) //Left x = Right x (RROp Gt (Left y) (GConst 2))) //Left y > 2 (RROp Gt (Right y) (GConst 2)) //Right y > 2 let rel22 = RBOp And (RROp Gt (Left y) (GConst 2)) //Left y > 2 (RROp Gt (Right y) (GConst 2)) //Right y > 2 let lemma_sound_optimization2 (h_left:heap) (h_right:heap) :Lemma (requires (rel_exp_denotation rel21 h_left h_right)) (ensures (let _, h_left' = reify (com_denotation com21) h_left in let _, h_right' = reify (com_denotation com22) h_right in rel_exp_denotation rel22 h_left' h_right')) = () (* * optimization * proving com1 = if x = 3 then y := x else y := 3 * and com2 = y := 3 * are equivalent *) let com31 = If (ROp Eq (Var x) (Const 3)) (Assign y (Var x)) (Assign y (Const 3)) //if x = 3 then y := x else y := 3 let com32 = Assign y (Const 3) //y := 3 let rel31 = RTrue let rel32 = RBOp And (RROp Eq (Left y) (GConst 3)) //Left y = 3 (RROp Eq (Right y) (GConst 3)) //Right y = 3 let lemma_sound_optimization3 (h_left:heap) (h_right:heap) :Lemma (requires (rel_exp_denotation rel31 h_left h_right)) (ensures (let _, h_left' = reify (com_denotation com31) h_left in let _, h_right' = reify (com_denotation com32) h_right in rel_exp_denotation rel32 h_left' h_right')) = () (* * optimization * proving com1 = x := -y; z := z - x; x := -x and com2 = x := y; z := z + x * are equivalent *) let com41 = Seq (Assign x (UMinus (Var y))) //x := -y; (Seq (Assign z (IOp Sub (Var z) (Var x))) //z := z - x; (Assign x (UMinus (Var x)))) //x := -x let com42 = Seq (Assign x (Var y)) //x := y; (Assign z (IOp Add (Var z) (Var x))) //z := z + x let rel4 = RBOp And (RROp Eq (Left x) (Right x)) (RBOp And (RROp Eq (Left y) (Right y)) (RROp Eq (Left z) (Right z))) #set-options "--z3rlimit 20" let lemma_sound_optimization4 (h_left:heap) (h_right:heap) :Lemma (requires (rel_exp_denotation rel4 h_left h_right)) (ensures (let _, h_left' = reify (com_denotation com41) h_left in let _, h_right' = reify (com_denotation com42) h_right in rel_exp_denotation rel4 h_left' h_right')) = () #reset-options
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.IntStoreFixed.fst.checked", "FStar.DM4F.Heap.IntStoreFixed.fsti.checked" ], "interface_file": false, "source_file": "ProgramOptimizations.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c1: ProgramOptimizations.com -> c2: ProgramOptimizations.com -> re1: ProgramOptimizations.rel_exp -> re2: ProgramOptimizations.rel_exp -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "ProgramOptimizations.com", "ProgramOptimizations.rel_exp", "Prims.l_Forall", "FStar.DM4F.Heap.IntStoreFixed.heap", "Prims.l_imp", "Prims.b2t", "ProgramOptimizations.rel_exp_denotation", "Prims.unit", "Prims.logical", "FStar.Pervasives.Native.tuple2", "ProgramOptimizations.com_denotation" ]
[]
false
false
false
true
true
let rhl (c1 c2: com) (re1 re2: rel_exp) =
forall (h_left: heap) (h_right: heap). rel_exp_denotation re1 h_left h_right ==> (let _, h_left' = reify (com_denotation c1) h_left in let _, h_right' = reify (com_denotation c2) h_right in rel_exp_denotation re2 h_left' h_right')
false
Spec.Frodo.Test.fst
Spec.Frodo.Test.test1_enccoins
val test1_enccoins : Prims.list Lib.IntTypes.uint8
let test1_enccoins = List.Tot.map u8_from_UInt8 [ 0x8duy; 0xf3uy; 0xfauy; 0xe3uy; 0x83uy; 0x27uy; 0xc5uy; 0x3cuy; 0xc1uy; 0xc4uy; 0x8cuy; 0x60uy; 0xb2uy; 0x52uy; 0x2buy; 0xb5uy ]
{ "file_name": "specs/tests/Spec.Frodo.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 69, "start_col": 0, "start_line": 64 }
module Spec.Frodo.Test open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Frodo.KEM open Spec.Frodo.KEM.KeyGen open Spec.Frodo.KEM.Encaps open Spec.Frodo.KEM.Decaps open Spec.Frodo.Params open FStar.All module PS = Lib.PrintSequence #set-options "--z3rlimit 50 --fuel 0 --ifuel 1" let compare (#len: size_nat) (test_expected: lbytes len) (test_result: lbytes len) = for_all2 (fun a b -> uint_to_nat #U8 a = uint_to_nat #U8 b) test_expected test_result let test_frodo (a:frodo_alg) (gen_a:frodo_gen_a) (keypaircoins: list uint8 {List.Tot.length keypaircoins == 2 * crypto_bytes a + bytes_seed_a}) (enccoins: list uint8 {List.Tot.length enccoins == bytes_mu a}) (ss_expected: list uint8 {List.Tot.length ss_expected == crypto_bytes a}) (pk_expected: list uint8 {List.Tot.length pk_expected == crypto_publickeybytes a}) (ct_expected: list uint8 {List.Tot.length ct_expected == crypto_ciphertextbytes a}) (sk_expected: list uint8 {List.Tot.length sk_expected == crypto_secretkeybytes a}) : ML bool = let keypaircoins = createL keypaircoins in let enccoins = createL enccoins in let ss_expected = createL ss_expected in let pk_expected = createL pk_expected in let ct_expected = createL ct_expected in let sk_expected = createL sk_expected in let pk, sk = crypto_kem_keypair_ a gen_a keypaircoins in let ct, ss1 = crypto_kem_enc_ a gen_a enccoins pk in let ss2 = crypto_kem_dec a gen_a ct sk in let r_pk = compare pk_expected pk in let r_sk = compare sk_expected sk in let r_ct = compare ct_expected ct in let r_ss = PS.print_compare true (crypto_bytes a) ss1 ss2 in let r_ss1 = PS.print_compare true (crypto_bytes a) ss_expected ss2 in r_pk && r_sk && r_ct && r_ss && r_ss1 // // Test1. FrodoKEM-64. SHAKE128 // let test1_keypaircoins = List.Tot.map u8_from_UInt8 [ 0xa6uy; 0x65uy; 0x65uy; 0x9fuy; 0xfbuy; 0xe4uy; 0x06uy; 0x5cuy; 0xcauy; 0x81uy; 0x5auy; 0x45uy; 0xe4uy; 0x94uy; 0xd8uy; 0x01uy; 0x90uy; 0x30uy; 0x33uy; 0x55uy; 0x33uy; 0x84uy; 0x2euy; 0xe4uy; 0x4cuy; 0x55uy; 0x8fuy; 0xd8uy; 0xaeuy; 0x4buy; 0x4euy; 0x91uy; 0x62uy; 0xfeuy; 0xc7uy; 0x9auy; 0xc5uy; 0xcduy; 0x1fuy; 0xe2uy; 0xd2uy; 0x00uy; 0x63uy; 0x39uy; 0xaauy; 0xb1uy; 0xf3uy; 0x17uy ]
{ "checked_file": "/", "dependencies": [ "Spec.Frodo.Params.fst.checked", "Spec.Frodo.KEM.KeyGen.fst.checked", "Spec.Frodo.KEM.Encaps.fst.checked", "Spec.Frodo.KEM.Decaps.fst.checked", "Spec.Frodo.KEM.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.IO.fst.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Test.fst" }
[ { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.Params", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.KEM.Decaps", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.KEM.Encaps", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.KEM.KeyGen", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.list Lib.IntTypes.uint8
Prims.Tot
[ "total" ]
[]
[ "FStar.List.Tot.Base.map", "FStar.UInt8.t", "Lib.IntTypes.uint8", "Lib.RawIntTypes.u8_from_UInt8", "Prims.Cons", "FStar.UInt8.__uint_to_t", "Prims.Nil" ]
[]
false
false
false
true
false
let test1_enccoins =
List.Tot.map u8_from_UInt8 [ 0x8duy; 0xf3uy; 0xfauy; 0xe3uy; 0x83uy; 0x27uy; 0xc5uy; 0x3cuy; 0xc1uy; 0xc4uy; 0x8cuy; 0x60uy; 0xb2uy; 0x52uy; 0x2buy; 0xb5uy ]
false
ProgramOptimizations.fst
ProgramOptimizations.rel4
val rel4 : ProgramOptimizations.rel_exp
let rel4 = RBOp And (RROp Eq (Left x) (Right x)) (RBOp And (RROp Eq (Left y) (Right y)) (RROp Eq (Left z) (Right z)))
{ "file_name": "examples/rel/ProgramOptimizations.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 56, "end_line": 233, "start_col": 0, "start_line": 231 }
(* 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 ProgramOptimizations open FStar.DM4F.Heap.IntStoreFixed open FStar.DM4F.IntStoreFixed (* * language and examples from: * "Simple Relational Correctness Proofs for Static Analyses and Program Transformations" * https://research.microsoft.com/en-us/um/people/nick/correctnesspopl2004.pdf *) type var = id type i_op = | Add | Sub type i_exp = | Const : int -> i_exp | Var : id -> i_exp | IOp : i_op -> i_exp -> i_exp -> i_exp | UMinus: i_exp -> i_exp type r_op = | Lt | Gt | Eq type b_op = | And | Or type b_exp = | CTrue : b_exp | CFalse: b_exp | ROp : r_op -> i_exp -> i_exp -> b_exp | BOp : b_op -> b_exp -> b_exp -> b_exp | Not : b_exp -> b_exp type com = | Skip : com | Assign: var -> i_exp -> com | Seq : com -> com -> com | If : b_exp -> com -> com -> com let rec i_exp_denotation (e:i_exp) :ISNull int = match e with | Const n -> n | Var r -> !r | IOp op e1 e2 -> (let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in match op with | Add -> n1 + n2 | Sub -> n1 - n2) | UMinus e -> - (i_exp_denotation e) let rec b_exp_denotation (b:b_exp) :ISNull bool = match b with | CTrue -> true | CFalse -> false | ROp op e1 e2 -> let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | BOp op b1 b2 -> let bc1 = b_exp_denotation b1 in let bc2 = b_exp_denotation b2 in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | Not b -> not (b_exp_denotation b) let rec com_denotation (c:com) :ISNull unit = match c with | Skip -> () | Assign r e -> let n = i_exp_denotation e in write r n (* r := n does not work, as it goes to FStar.ST *) | Seq c1 c2 -> com_denotation c1; com_denotation c2 | If b c1 c2 -> if b_exp_denotation b then com_denotation c1 else com_denotation c2 type g_exp = | GConst: int -> g_exp | Left : id -> g_exp | Right : id -> g_exp | GIOp : i_op -> g_exp -> g_exp -> g_exp type rel_exp = | RTrue : rel_exp | RFalse: rel_exp | RROp : r_op -> g_exp -> g_exp -> rel_exp | RBOp : b_op -> rel_exp -> rel_exp -> rel_exp | RNot : rel_exp -> rel_exp let rec g_exp_denotation (g:g_exp) (h_left:heap) (h_right:heap) :int = match g with | GConst n -> n | Left r -> sel h_left r | Right r -> sel h_right r | GIOp op g1 g2 -> match op with | Add -> g_exp_denotation g1 h_left h_right + g_exp_denotation g2 h_left h_right | Sub -> g_exp_denotation g1 h_left h_right - g_exp_denotation g2 h_left h_right let rec rel_exp_denotation (re:rel_exp) (h_left:heap) (h_right:heap) :bool = match re with | RTrue -> true | RFalse -> false | RROp op g1 g2 -> let n1 = g_exp_denotation g1 h_left h_right in let n2 = g_exp_denotation g2 h_left h_right in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | RBOp op re1 re2 -> let bc1 = rel_exp_denotation re1 h_left h_right in let bc2 = rel_exp_denotation re2 h_left h_right in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | RNot re1 -> not (rel_exp_denotation re1 h_left h_right) assume val x:id assume val y:id assume val z:id assume Distinct_vars: x <> y /\ y <> z /\ x <> z (* * removing redundant computation * proving com1 = x := y + 1; z := y + 1 * and com2 = x := y + 1; z := x * * relate two states with equal values of y to two states with equal values of x and z *) let com11 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (IOp Add (Var y) (Const 1))) //z := y + 1 let com12 = Seq (Assign x (IOp Add (Var y) (Const 1))) //x := y + 1; (Assign z (Var x)) //z := x let rel11 = RROp Eq (Left y) (Right y) //Left y = Right y let rel12 = RBOp And (RROp Eq (Left x) (Right x)) //Left x = Right x /\ (RROp Eq (Left z) (Right z)) //Left z = Right z let lemma_sound_optimization1 (h_left:heap) (h_right:heap) :Lemma (requires (rel_exp_denotation rel11 h_left h_right)) //h_left, h_right are related by rel1 (ensures (let _, h_left' = reify (com_denotation com11) h_left in let _, h_right' = reify (com_denotation com12) h_right in rel_exp_denotation rel12 h_left' h_right')) //[|com1|](h_left), [|com2|](h_right) are related by rel2 = () (* * dead code elimination * proving com1 = if x > 3 then y := x else y := 7 * and com2 = skip * are equivalent if all that the rest of the computation cares for is y > 2 *) let com21 = If (ROp Gt (Var x) (Const 3)) (Assign y (Var x)) (Assign y (Const 7)) //if x > 3 then y := x else y := 7 let com22 = Skip let rel21 = RBOp And (RBOp And (RROp Eq (Left x) (Right x)) //Left x = Right x (RROp Gt (Left y) (GConst 2))) //Left y > 2 (RROp Gt (Right y) (GConst 2)) //Right y > 2 let rel22 = RBOp And (RROp Gt (Left y) (GConst 2)) //Left y > 2 (RROp Gt (Right y) (GConst 2)) //Right y > 2 let lemma_sound_optimization2 (h_left:heap) (h_right:heap) :Lemma (requires (rel_exp_denotation rel21 h_left h_right)) (ensures (let _, h_left' = reify (com_denotation com21) h_left in let _, h_right' = reify (com_denotation com22) h_right in rel_exp_denotation rel22 h_left' h_right')) = () (* * optimization * proving com1 = if x = 3 then y := x else y := 3 * and com2 = y := 3 * are equivalent *) let com31 = If (ROp Eq (Var x) (Const 3)) (Assign y (Var x)) (Assign y (Const 3)) //if x = 3 then y := x else y := 3 let com32 = Assign y (Const 3) //y := 3 let rel31 = RTrue let rel32 = RBOp And (RROp Eq (Left y) (GConst 3)) //Left y = 3 (RROp Eq (Right y) (GConst 3)) //Right y = 3 let lemma_sound_optimization3 (h_left:heap) (h_right:heap) :Lemma (requires (rel_exp_denotation rel31 h_left h_right)) (ensures (let _, h_left' = reify (com_denotation com31) h_left in let _, h_right' = reify (com_denotation com32) h_right in rel_exp_denotation rel32 h_left' h_right')) = () (* * optimization * proving com1 = x := -y; z := z - x; x := -x and com2 = x := y; z := z + x * are equivalent *) let com41 = Seq (Assign x (UMinus (Var y))) //x := -y; (Seq (Assign z (IOp Sub (Var z) (Var x))) //z := z - x; (Assign x (UMinus (Var x)))) //x := -x let com42 = Seq (Assign x (Var y)) //x := y; (Assign z (IOp Add (Var z) (Var x))) //z := z + x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.IntStoreFixed.fst.checked", "FStar.DM4F.Heap.IntStoreFixed.fsti.checked" ], "interface_file": false, "source_file": "ProgramOptimizations.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ProgramOptimizations.rel_exp
Prims.Tot
[ "total" ]
[]
[ "ProgramOptimizations.RBOp", "ProgramOptimizations.And", "ProgramOptimizations.RROp", "ProgramOptimizations.Eq", "ProgramOptimizations.Left", "ProgramOptimizations.x", "ProgramOptimizations.Right", "ProgramOptimizations.y", "ProgramOptimizations.z" ]
[]
false
false
false
true
false
let rel4 =
RBOp And (RROp Eq (Left x) (Right x)) (RBOp And (RROp Eq (Left y) (Right y)) (RROp Eq (Left z) (Right z)))
false
ProgramOptimizations.fst
ProgramOptimizations.com_denotation
val com_denotation (c: com) : ISNull unit
val com_denotation (c: com) : ISNull unit
let rec com_denotation (c:com) :ISNull unit = match c with | Skip -> () | Assign r e -> let n = i_exp_denotation e in write r n (* r := n does not work, as it goes to FStar.ST *) | Seq c1 c2 -> com_denotation c1; com_denotation c2 | If b c1 c2 -> if b_exp_denotation b then com_denotation c1 else com_denotation c2
{ "file_name": "examples/rel/ProgramOptimizations.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 71, "end_line": 100, "start_col": 1, "start_line": 92 }
(* 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 ProgramOptimizations open FStar.DM4F.Heap.IntStoreFixed open FStar.DM4F.IntStoreFixed (* * language and examples from: * "Simple Relational Correctness Proofs for Static Analyses and Program Transformations" * https://research.microsoft.com/en-us/um/people/nick/correctnesspopl2004.pdf *) type var = id type i_op = | Add | Sub type i_exp = | Const : int -> i_exp | Var : id -> i_exp | IOp : i_op -> i_exp -> i_exp -> i_exp | UMinus: i_exp -> i_exp type r_op = | Lt | Gt | Eq type b_op = | And | Or type b_exp = | CTrue : b_exp | CFalse: b_exp | ROp : r_op -> i_exp -> i_exp -> b_exp | BOp : b_op -> b_exp -> b_exp -> b_exp | Not : b_exp -> b_exp type com = | Skip : com | Assign: var -> i_exp -> com | Seq : com -> com -> com | If : b_exp -> com -> com -> com let rec i_exp_denotation (e:i_exp) :ISNull int = match e with | Const n -> n | Var r -> !r | IOp op e1 e2 -> (let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in match op with | Add -> n1 + n2 | Sub -> n1 - n2) | UMinus e -> - (i_exp_denotation e) let rec b_exp_denotation (b:b_exp) :ISNull bool = match b with | CTrue -> true | CFalse -> false | ROp op e1 e2 -> let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | BOp op b1 b2 -> let bc1 = b_exp_denotation b1 in let bc2 = b_exp_denotation b2 in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | Not b -> not (b_exp_denotation b)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.IntStoreFixed.fst.checked", "FStar.DM4F.Heap.IntStoreFixed.fsti.checked" ], "interface_file": false, "source_file": "ProgramOptimizations.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: ProgramOptimizations.com -> FStar.DM4F.IntStoreFixed.ISNull Prims.unit
FStar.DM4F.IntStoreFixed.ISNull
[]
[]
[ "ProgramOptimizations.com", "Prims.unit", "ProgramOptimizations.var", "ProgramOptimizations.i_exp", "FStar.DM4F.IntStoreFixed.write", "Prims.int", "ProgramOptimizations.i_exp_denotation", "ProgramOptimizations.com_denotation", "ProgramOptimizations.b_exp", "Prims.bool", "ProgramOptimizations.b_exp_denotation" ]
[ "recursion" ]
false
true
false
false
false
let rec com_denotation (c: com) : ISNull unit =
match c with | Skip -> () | Assign r e -> let n = i_exp_denotation e in write r n | Seq c1 c2 -> com_denotation c1; com_denotation c2 | If b c1 c2 -> if b_exp_denotation b then com_denotation c1 else com_denotation c2
false
ProgramOptimizations.fst
ProgramOptimizations.b_exp_denotation
val b_exp_denotation (b: b_exp) : ISNull bool
val b_exp_denotation (b: b_exp) : ISNull bool
let rec b_exp_denotation (b:b_exp) :ISNull bool = match b with | CTrue -> true | CFalse -> false | ROp op e1 e2 -> let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | BOp op b1 b2 -> let bc1 = b_exp_denotation b1 in let bc2 = b_exp_denotation b2 in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | Not b -> not (b_exp_denotation b)
{ "file_name": "examples/rel/ProgramOptimizations.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 37, "end_line": 90, "start_col": 1, "start_line": 73 }
(* 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 ProgramOptimizations open FStar.DM4F.Heap.IntStoreFixed open FStar.DM4F.IntStoreFixed (* * language and examples from: * "Simple Relational Correctness Proofs for Static Analyses and Program Transformations" * https://research.microsoft.com/en-us/um/people/nick/correctnesspopl2004.pdf *) type var = id type i_op = | Add | Sub type i_exp = | Const : int -> i_exp | Var : id -> i_exp | IOp : i_op -> i_exp -> i_exp -> i_exp | UMinus: i_exp -> i_exp type r_op = | Lt | Gt | Eq type b_op = | And | Or type b_exp = | CTrue : b_exp | CFalse: b_exp | ROp : r_op -> i_exp -> i_exp -> b_exp | BOp : b_op -> b_exp -> b_exp -> b_exp | Not : b_exp -> b_exp type com = | Skip : com | Assign: var -> i_exp -> com | Seq : com -> com -> com | If : b_exp -> com -> com -> com let rec i_exp_denotation (e:i_exp) :ISNull int = match e with | Const n -> n | Var r -> !r | IOp op e1 e2 -> (let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in match op with | Add -> n1 + n2 | Sub -> n1 - n2) | UMinus e -> - (i_exp_denotation e)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.IntStoreFixed.fst.checked", "FStar.DM4F.Heap.IntStoreFixed.fsti.checked" ], "interface_file": false, "source_file": "ProgramOptimizations.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: ProgramOptimizations.b_exp -> FStar.DM4F.IntStoreFixed.ISNull Prims.bool
FStar.DM4F.IntStoreFixed.ISNull
[]
[]
[ "ProgramOptimizations.b_exp", "Prims.bool", "ProgramOptimizations.r_op", "ProgramOptimizations.i_exp", "Prims.op_LessThan", "Prims.op_GreaterThan", "Prims.op_Equality", "Prims.int", "ProgramOptimizations.i_exp_denotation", "ProgramOptimizations.b_op", "Prims.op_AmpAmp", "Prims.op_BarBar", "ProgramOptimizations.b_exp_denotation", "Prims.op_Negation" ]
[ "recursion" ]
false
true
false
false
false
let rec b_exp_denotation (b: b_exp) : ISNull bool =
match b with | CTrue -> true | CFalse -> false | ROp op e1 e2 -> let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | BOp op b1 b2 -> let bc1 = b_exp_denotation b1 in let bc2 = b_exp_denotation b2 in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | Not b -> not (b_exp_denotation b)
false
ProgramOptimizations.fst
ProgramOptimizations.i_exp_denotation
val i_exp_denotation (e: i_exp) : ISNull int
val i_exp_denotation (e: i_exp) : ISNull int
let rec i_exp_denotation (e:i_exp) :ISNull int = match e with | Const n -> n | Var r -> !r | IOp op e1 e2 -> (let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in match op with | Add -> n1 + n2 | Sub -> n1 - n2) | UMinus e -> - (i_exp_denotation e)
{ "file_name": "examples/rel/ProgramOptimizations.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 42, "end_line": 71, "start_col": 1, "start_line": 61 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module ProgramOptimizations open FStar.DM4F.Heap.IntStoreFixed open FStar.DM4F.IntStoreFixed (* * language and examples from: * "Simple Relational Correctness Proofs for Static Analyses and Program Transformations" * https://research.microsoft.com/en-us/um/people/nick/correctnesspopl2004.pdf *) type var = id type i_op = | Add | Sub type i_exp = | Const : int -> i_exp | Var : id -> i_exp | IOp : i_op -> i_exp -> i_exp -> i_exp | UMinus: i_exp -> i_exp type r_op = | Lt | Gt | Eq type b_op = | And | Or type b_exp = | CTrue : b_exp | CFalse: b_exp | ROp : r_op -> i_exp -> i_exp -> b_exp | BOp : b_op -> b_exp -> b_exp -> b_exp | Not : b_exp -> b_exp type com = | Skip : com | Assign: var -> i_exp -> com | Seq : com -> com -> com | If : b_exp -> com -> com -> com
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.IntStoreFixed.fst.checked", "FStar.DM4F.Heap.IntStoreFixed.fsti.checked" ], "interface_file": false, "source_file": "ProgramOptimizations.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e: ProgramOptimizations.i_exp -> FStar.DM4F.IntStoreFixed.ISNull Prims.int
FStar.DM4F.IntStoreFixed.ISNull
[]
[]
[ "ProgramOptimizations.i_exp", "Prims.int", "FStar.DM4F.Heap.IntStoreFixed.id", "FStar.DM4F.IntStoreFixed.op_Bang", "ProgramOptimizations.i_op", "Prims.op_Addition", "Prims.op_Subtraction", "ProgramOptimizations.i_exp_denotation", "Prims.op_Minus" ]
[ "recursion" ]
false
true
false
false
false
let rec i_exp_denotation (e: i_exp) : ISNull int =
match e with | Const n -> n | Var r -> !r | IOp op e1 e2 -> (let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in match op with | Add -> n1 + n2 | Sub -> n1 - n2) | UMinus e -> - (i_exp_denotation e)
false
ProgramOptimizations.fst
ProgramOptimizations.g_exp_denotation
val g_exp_denotation (g: g_exp) (h_left h_right: heap) : int
val g_exp_denotation (g: g_exp) (h_left h_right: heap) : int
let rec g_exp_denotation (g:g_exp) (h_left:heap) (h_right:heap) :int = match g with | GConst n -> n | Left r -> sel h_left r | Right r -> sel h_right r | GIOp op g1 g2 -> match op with | Add -> g_exp_denotation g1 h_left h_right + g_exp_denotation g2 h_left h_right | Sub -> g_exp_denotation g1 h_left h_right - g_exp_denotation g2 h_left h_right
{ "file_name": "examples/rel/ProgramOptimizations.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 84, "end_line": 123, "start_col": 0, "start_line": 115 }
(* 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 ProgramOptimizations open FStar.DM4F.Heap.IntStoreFixed open FStar.DM4F.IntStoreFixed (* * language and examples from: * "Simple Relational Correctness Proofs for Static Analyses and Program Transformations" * https://research.microsoft.com/en-us/um/people/nick/correctnesspopl2004.pdf *) type var = id type i_op = | Add | Sub type i_exp = | Const : int -> i_exp | Var : id -> i_exp | IOp : i_op -> i_exp -> i_exp -> i_exp | UMinus: i_exp -> i_exp type r_op = | Lt | Gt | Eq type b_op = | And | Or type b_exp = | CTrue : b_exp | CFalse: b_exp | ROp : r_op -> i_exp -> i_exp -> b_exp | BOp : b_op -> b_exp -> b_exp -> b_exp | Not : b_exp -> b_exp type com = | Skip : com | Assign: var -> i_exp -> com | Seq : com -> com -> com | If : b_exp -> com -> com -> com let rec i_exp_denotation (e:i_exp) :ISNull int = match e with | Const n -> n | Var r -> !r | IOp op e1 e2 -> (let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in match op with | Add -> n1 + n2 | Sub -> n1 - n2) | UMinus e -> - (i_exp_denotation e) let rec b_exp_denotation (b:b_exp) :ISNull bool = match b with | CTrue -> true | CFalse -> false | ROp op e1 e2 -> let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | BOp op b1 b2 -> let bc1 = b_exp_denotation b1 in let bc2 = b_exp_denotation b2 in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | Not b -> not (b_exp_denotation b) let rec com_denotation (c:com) :ISNull unit = match c with | Skip -> () | Assign r e -> let n = i_exp_denotation e in write r n (* r := n does not work, as it goes to FStar.ST *) | Seq c1 c2 -> com_denotation c1; com_denotation c2 | If b c1 c2 -> if b_exp_denotation b then com_denotation c1 else com_denotation c2 type g_exp = | GConst: int -> g_exp | Left : id -> g_exp | Right : id -> g_exp | GIOp : i_op -> g_exp -> g_exp -> g_exp type rel_exp = | RTrue : rel_exp | RFalse: rel_exp | RROp : r_op -> g_exp -> g_exp -> rel_exp | RBOp : b_op -> rel_exp -> rel_exp -> rel_exp | RNot : rel_exp -> rel_exp
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.IntStoreFixed.fst.checked", "FStar.DM4F.Heap.IntStoreFixed.fsti.checked" ], "interface_file": false, "source_file": "ProgramOptimizations.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: ProgramOptimizations.g_exp -> h_left: FStar.DM4F.Heap.IntStoreFixed.heap -> h_right: FStar.DM4F.Heap.IntStoreFixed.heap -> Prims.int
Prims.Tot
[ "total" ]
[]
[ "ProgramOptimizations.g_exp", "FStar.DM4F.Heap.IntStoreFixed.heap", "Prims.int", "FStar.DM4F.Heap.IntStoreFixed.id", "FStar.DM4F.Heap.IntStoreFixed.sel", "ProgramOptimizations.i_op", "Prims.op_Addition", "ProgramOptimizations.g_exp_denotation", "Prims.op_Subtraction" ]
[ "recursion" ]
false
false
false
true
false
let rec g_exp_denotation (g: g_exp) (h_left h_right: heap) : int =
match g with | GConst n -> n | Left r -> sel h_left r | Right r -> sel h_right r | GIOp op g1 g2 -> match op with | Add -> g_exp_denotation g1 h_left h_right + g_exp_denotation g2 h_left h_right | Sub -> g_exp_denotation g1 h_left h_right - g_exp_denotation g2 h_left h_right
false
FStar.Tactics.V1.Logic.fst
FStar.Tactics.V1.Logic.lemma_from_squash
val lemma_from_squash : #a:Type -> #b:(a -> Type) -> (x:a -> squash (b x)) -> x:a -> Lemma (b x)
val lemma_from_squash : #a:Type -> #b:(a -> Type) -> (x:a -> squash (b x)) -> x:a -> Lemma (b x)
let lemma_from_squash #a #b f x = let _ = f x in assert (b x)
{ "file_name": "ulib/FStar.Tactics.V1.Logic.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 61, "end_line": 317, "start_col": 0, "start_line": 317 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V1.Logic open FStar.Tactics.Effect open FStar.Stubs.Tactics.V1.Builtins open FStar.Tactics.V1.Derived open FStar.Tactics.Util open FStar.Reflection.V1 open FStar.Reflection.V1.Formula (** Returns the current goal as a [formula]. *) let cur_formula () : Tac formula = term_as_formula (cur_goal ()) private val revert_squash : (#a:Type) -> (#b : (a -> Type)) -> (squash (forall (x:a). b x)) -> x:a -> squash (b x) let revert_squash #a #b s x = let x : (_:unit{forall x. b x}) = s in () (** Revert an introduced binder as a forall. *) let l_revert () : Tac unit = revert (); apply (`revert_squash) (** Repeated [l_revert]. *) let rec l_revert_all (bs:binders) : Tac unit = match bs with | [] -> () | _::tl -> begin l_revert (); l_revert_all tl end private let fa_intro_lem (#a:Type) (#p:a -> Type) (f:(x:a -> squash (p x))) : Lemma (forall (x:a). p x) = FStar.Classical.lemma_forall_intro_gtot ((fun x -> FStar.IndefiniteDescription.elim_squash (f x)) <: (x:a -> GTot (p x))) (** Introduce a forall. *) let forall_intro () : Tac binder = apply_lemma (`fa_intro_lem); intro () (** Introduce a forall, with some given name. *) let forall_intro_as (s:string) : Tac binder = apply_lemma (`fa_intro_lem); intro_as s (** Repeated [forall_intro]. *) let forall_intros () : Tac binders = repeat1 forall_intro private val split_lem : (#a:Type) -> (#b:Type) -> squash a -> squash b -> Lemma (a /\ b) let split_lem #a #b sa sb = () (** Split a conjunction into two goals. *) let split () : Tac unit = try apply_lemma (`split_lem) with | _ -> fail "Could not split goal" private val imp_intro_lem : (#a:Type) -> (#b : Type) -> (a -> squash b) -> Lemma (a ==> b) let imp_intro_lem #a #b f = FStar.Classical.give_witness (FStar.Classical.arrow_to_impl (fun (x:squash a) -> FStar.Squash.bind_squash x f)) (** Introduce an implication. *) let implies_intro () : Tac binder = apply_lemma (`imp_intro_lem); intro () let implies_intro_as (s:string) : Tac binder = apply_lemma (`imp_intro_lem); intro_as s (** Repeated [implies_intro]. *) let implies_intros () : Tac binders = repeat1 implies_intro (** "Logical" intro: introduce a forall or an implication. *) let l_intro () = forall_intro `or_else` implies_intro (** Repeated [l]. *) let l_intros () = repeat l_intro let squash_intro () : Tac unit = apply (`FStar.Squash.return_squash) let l_exact (t:term) = try exact t with | _ -> (squash_intro (); exact t) let hyp (b:binder) : Tac unit = l_exact (binder_to_term b) private let __lemma_to_squash #req #ens (_ : squash req) (h : (unit -> Lemma (requires req) (ensures ens))) : squash ens = h () let pose_lemma (t : term) : Tac binder = let c = tcc (cur_env ()) t in let pre, post = match inspect_comp c with | C_Lemma pre post _ -> pre, post | _ -> fail "" in let post = `((`#post) ()) in (* unthunk *) let post = norm_term [] post in (* If the precondition is trivial, do not cut by it *) match term_as_formula' pre with | True_ -> pose (`(__lemma_to_squash #(`#pre) #(`#post) () (fun () -> (`#t)))) | _ -> let reqb = tcut (`squash (`#pre)) in let b = pose (`(__lemma_to_squash #(`#pre) #(`#post) (`#(binder_to_term reqb)) (fun () -> (`#t)))) in flip (); ignore (trytac trivial); b let explode () : Tac unit = ignore ( repeatseq (fun () -> first [(fun () -> ignore (l_intro ())); (fun () -> ignore (split ()))])) let rec visit (callback:unit -> Tac unit) : Tac unit = focus (fun () -> or_else callback (fun () -> let g = cur_goal () in match term_as_formula g with | Forall _b _sort _phi -> let binders = forall_intros () in seq (fun () -> visit callback) (fun () -> l_revert_all binders) | And p q -> seq split (fun () -> visit callback) | Implies p q -> let _ = implies_intro () in seq (fun () -> visit callback) l_revert | _ -> () ) ) let rec simplify_eq_implication () : Tac unit = let e = cur_env () in let g = cur_goal () in let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in // G, eq_h:x=e |- P rewrite eq_h; // G, eq_h:x=e |- P[e/x] clear_top (); // G |- P[e/x] visit simplify_eq_implication let rewrite_all_equalities () : Tac unit = visit simplify_eq_implication let rec unfold_definition_and_simplify_eq (tm:term) : Tac unit = let g = cur_goal () in match term_as_formula g with | App hd arg -> if term_eq hd tm then trivial () else () | _ -> begin let r = destruct_equality_implication g in match r with | None -> fail "Not an equality implication" | Some (_, rhs) -> let eq_h = implies_intro () in rewrite eq_h; clear_top (); visit (fun () -> unfold_definition_and_simplify_eq tm) end private val vbind : (#p:Type) -> (#q:Type) -> squash p -> (p -> squash q) -> Lemma q let vbind #p #q sq f = FStar.Classical.give_witness_from_squash (FStar.Squash.bind_squash sq f) (** A tactic to unsquash a hypothesis. Perhaps you are looking for [unsquash_term]. *) let unsquash (t:term) : Tac term = let v = `vbind in apply_lemma (mk_e_app v [t]); let b = intro () in pack_ln (Tv_Var (bv_of_binder b)) private val or_ind : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p \/ q) -> (squash (p ==> phi)) -> (squash (q ==> phi)) -> Lemma phi let or_ind #p #q #phi o l r = () let cases_or (o:term) : Tac unit = apply_lemma (mk_e_app (`or_ind) [o]) private val bool_ind : (b:bool) -> (phi:Type) -> (squash (b == true ==> phi)) -> (squash (b == false ==> phi)) -> Lemma phi let bool_ind b phi l r = () let cases_bool (b:term) : Tac unit = let bi = `bool_ind in seq (fun () -> apply_lemma (mk_e_app bi [b])) (fun () -> let _ = trytac (fun () -> let b = implies_intro () in rewrite b; clear_top ()) in ()) private val or_intro_1 : (#p:Type) -> (#q:Type) -> squash p -> Lemma (p \/ q) let or_intro_1 #p #q _ = () private val or_intro_2 : (#p:Type) -> (#q:Type) -> squash q -> Lemma (p \/ q) let or_intro_2 #p #q _ = () let left () : Tac unit = apply_lemma (`or_intro_1) let right () : Tac unit = apply_lemma (`or_intro_2) private val __and_elim : (#p:Type) -> (#q:Type) -> (#phi:Type) -> (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim #p #q #phi p_and_q f = () private val __and_elim' : (#p:Type) -> (#q:Type) -> (#phi:Type) -> squash (p /\ q) -> squash (p ==> q ==> phi) -> Lemma phi let __and_elim' #p #q #phi p_and_q f = () let and_elim (t : term) : Tac unit = begin try apply_lemma (`(__and_elim (`#t))) with | _ -> apply_lemma (`(__and_elim' (`#t))) end let destruct_and (t : term) : Tac (binder * binder) = and_elim t; (implies_intro (), implies_intro ()) private val __witness : (#a:Type) -> (x:a) -> (#p:(a -> Type)) -> squash (p x) -> squash (exists (x:a). p x) private let __witness #a x #p _ = () let witness (t : term) : Tac unit = apply_raw (`__witness); exact t private let __elim_exists' #t (#pred : t -> Type0) #goal (h : (exists x. pred x)) (k : (x:t -> pred x -> squash goal)) : squash goal = FStar.Squash.bind_squash #(x:t & pred x) h (fun (|x, pf|) -> k x pf) (* returns witness and proof as binders *) let elim_exists (t : term) : Tac (binder & binder) = apply_lemma (`(__elim_exists' (`#(t)))); let x = intro () in let pf = intro () in (x, pf) private let __forall_inst #t (#pred : t -> Type0) (h : (forall x. pred x)) (x : t) : squash (pred x) = () (* GM: annoying that this doesn't just work by SMT *) private let __forall_inst_sq #t (#pred : t -> Type0) (h : squash (forall x. pred x)) (x : t) : squash (pred x) = FStar.Squash.bind_squash h (fun (f : (forall x. pred x)) -> __forall_inst f x) let instantiate (fa : term) (x : term) : Tac binder = try pose (`__forall_inst_sq (`#fa) (`#x)) with | _ -> try pose (`__forall_inst (`#fa) (`#x)) with | _ -> fail "could not instantiate" let instantiate_as (fa : term) (x : term) (s : string) : Tac binder = let b = instantiate fa x in rename_to b s private let sklem0 (#a:Type) (#p : a -> Type0) ($v : (exists (x:a). p x)) (phi:Type0) : Lemma (requires (forall x. p x ==> phi)) (ensures phi) = () private let rec sk_binder' (acc:binders) (b:binder) : Tac (binders * binder) = focus (fun () -> try apply_lemma (`(sklem0 (`#(binder_to_term b)))); if ngoals () <> 1 then fail "no"; clear b; let bx = forall_intro () in let b' = implies_intro () in sk_binder' (bx::acc) b' (* We might have introduced a new existential, so possibly recurse *) with | _ -> (acc, b) (* If the above failed, just return *) ) (* Skolemizes a given binder for an existential, returning the introduced new binders * and the skolemized formula. *) let sk_binder b = sk_binder' [] b let skolem () = let bs = binders_of_env (cur_env ()) in map sk_binder bs private val lemma_from_squash : #a:Type -> #b:(a -> Type) -> (x:a -> squash (b x)) -> x:a -> Lemma (b x)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V1.Derived.fst.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Stubs.Tactics.V1.Builtins.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V1.Formula.fst.checked", "FStar.Reflection.V1.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V1.Logic.fst" }
[ { "abbrev": false, "full_module": "FStar.Reflection.V1.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Tactics.V1.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V1", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (x: a -> Prims.squash (b x)) -> x: a -> FStar.Pervasives.Lemma (ensures b x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.squash", "Prims._assert", "Prims.unit" ]
[]
true
false
true
false
false
let lemma_from_squash #a #b f x =
let _ = f x in assert (b x)
false
ProgramOptimizations.fst
ProgramOptimizations.rel_exp_denotation
val rel_exp_denotation (re: rel_exp) (h_left h_right: heap) : bool
val rel_exp_denotation (re: rel_exp) (h_left h_right: heap) : bool
let rec rel_exp_denotation (re:rel_exp) (h_left:heap) (h_right:heap) :bool = match re with | RTrue -> true | RFalse -> false | RROp op g1 g2 -> let n1 = g_exp_denotation g1 h_left h_right in let n2 = g_exp_denotation g2 h_left h_right in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | RBOp op re1 re2 -> let bc1 = rel_exp_denotation re1 h_left h_right in let bc2 = rel_exp_denotation re2 h_left h_right in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | RNot re1 -> not (rel_exp_denotation re1 h_left h_right)
{ "file_name": "examples/rel/ProgramOptimizations.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 59, "end_line": 142, "start_col": 0, "start_line": 125 }
(* 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 ProgramOptimizations open FStar.DM4F.Heap.IntStoreFixed open FStar.DM4F.IntStoreFixed (* * language and examples from: * "Simple Relational Correctness Proofs for Static Analyses and Program Transformations" * https://research.microsoft.com/en-us/um/people/nick/correctnesspopl2004.pdf *) type var = id type i_op = | Add | Sub type i_exp = | Const : int -> i_exp | Var : id -> i_exp | IOp : i_op -> i_exp -> i_exp -> i_exp | UMinus: i_exp -> i_exp type r_op = | Lt | Gt | Eq type b_op = | And | Or type b_exp = | CTrue : b_exp | CFalse: b_exp | ROp : r_op -> i_exp -> i_exp -> b_exp | BOp : b_op -> b_exp -> b_exp -> b_exp | Not : b_exp -> b_exp type com = | Skip : com | Assign: var -> i_exp -> com | Seq : com -> com -> com | If : b_exp -> com -> com -> com let rec i_exp_denotation (e:i_exp) :ISNull int = match e with | Const n -> n | Var r -> !r | IOp op e1 e2 -> (let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in match op with | Add -> n1 + n2 | Sub -> n1 - n2) | UMinus e -> - (i_exp_denotation e) let rec b_exp_denotation (b:b_exp) :ISNull bool = match b with | CTrue -> true | CFalse -> false | ROp op e1 e2 -> let n1 = i_exp_denotation e1 in let n2 = i_exp_denotation e2 in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | BOp op b1 b2 -> let bc1 = b_exp_denotation b1 in let bc2 = b_exp_denotation b2 in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | Not b -> not (b_exp_denotation b) let rec com_denotation (c:com) :ISNull unit = match c with | Skip -> () | Assign r e -> let n = i_exp_denotation e in write r n (* r := n does not work, as it goes to FStar.ST *) | Seq c1 c2 -> com_denotation c1; com_denotation c2 | If b c1 c2 -> if b_exp_denotation b then com_denotation c1 else com_denotation c2 type g_exp = | GConst: int -> g_exp | Left : id -> g_exp | Right : id -> g_exp | GIOp : i_op -> g_exp -> g_exp -> g_exp type rel_exp = | RTrue : rel_exp | RFalse: rel_exp | RROp : r_op -> g_exp -> g_exp -> rel_exp | RBOp : b_op -> rel_exp -> rel_exp -> rel_exp | RNot : rel_exp -> rel_exp let rec g_exp_denotation (g:g_exp) (h_left:heap) (h_right:heap) :int = match g with | GConst n -> n | Left r -> sel h_left r | Right r -> sel h_right r | GIOp op g1 g2 -> match op with | Add -> g_exp_denotation g1 h_left h_right + g_exp_denotation g2 h_left h_right | Sub -> g_exp_denotation g1 h_left h_right - g_exp_denotation g2 h_left h_right
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.IntStoreFixed.fst.checked", "FStar.DM4F.Heap.IntStoreFixed.fsti.checked" ], "interface_file": false, "source_file": "ProgramOptimizations.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap.IntStoreFixed", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
re: ProgramOptimizations.rel_exp -> h_left: FStar.DM4F.Heap.IntStoreFixed.heap -> h_right: FStar.DM4F.Heap.IntStoreFixed.heap -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "ProgramOptimizations.rel_exp", "FStar.DM4F.Heap.IntStoreFixed.heap", "ProgramOptimizations.r_op", "ProgramOptimizations.g_exp", "Prims.op_LessThan", "Prims.op_GreaterThan", "Prims.op_Equality", "Prims.int", "Prims.bool", "ProgramOptimizations.g_exp_denotation", "ProgramOptimizations.b_op", "Prims.op_AmpAmp", "Prims.op_BarBar", "ProgramOptimizations.rel_exp_denotation", "Prims.op_Negation" ]
[ "recursion" ]
false
false
false
true
false
let rec rel_exp_denotation (re: rel_exp) (h_left h_right: heap) : bool =
match re with | RTrue -> true | RFalse -> false | RROp op g1 g2 -> let n1 = g_exp_denotation g1 h_left h_right in let n2 = g_exp_denotation g2 h_left h_right in (match op with | Lt -> n1 < n2 | Gt -> n1 > n2 | Eq -> n1 = n2) | RBOp op re1 re2 -> let bc1 = rel_exp_denotation re1 h_left h_right in let bc2 = rel_exp_denotation re2 h_left h_right in (match op with | And -> bc1 && bc2 | Or -> bc1 || bc2) | RNot re1 -> not (rel_exp_denotation re1 h_left h_right)
false
Spec.Frodo.Test.fst
Spec.Frodo.Test.compare
val compare : test_expected: Lib.ByteSequence.lbytes len -> test_result: Lib.ByteSequence.lbytes len -> Prims.bool
let compare (#len: size_nat) (test_expected: lbytes len) (test_result: lbytes len) = for_all2 (fun a b -> uint_to_nat #U8 a = uint_to_nat #U8 b) test_expected test_result
{ "file_name": "specs/tests/Spec.Frodo.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 87, "end_line": 23, "start_col": 0, "start_line": 22 }
module Spec.Frodo.Test open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Frodo.KEM open Spec.Frodo.KEM.KeyGen open Spec.Frodo.KEM.Encaps open Spec.Frodo.KEM.Decaps open Spec.Frodo.Params open FStar.All module PS = Lib.PrintSequence #set-options "--z3rlimit 50 --fuel 0 --ifuel 1"
{ "checked_file": "/", "dependencies": [ "Spec.Frodo.Params.fst.checked", "Spec.Frodo.KEM.KeyGen.fst.checked", "Spec.Frodo.KEM.Encaps.fst.checked", "Spec.Frodo.KEM.Decaps.fst.checked", "Spec.Frodo.KEM.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.IO.fst.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Test.fst" }
[ { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.Params", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.KEM.Decaps", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.KEM.Encaps", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.KEM.KeyGen", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
test_expected: Lib.ByteSequence.lbytes len -> test_result: Lib.ByteSequence.lbytes len -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_nat", "Lib.ByteSequence.lbytes", "Lib.Sequence.for_all2", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.op_Equality", "Prims.nat", "Prims.l_or", "Prims.b2t", "Prims.int", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.range", "Lib.IntTypes.uint_v", "Lib.RawIntTypes.uint_to_nat", "Prims.bool" ]
[]
false
false
false
false
false
let compare (#len: size_nat) (test_expected test_result: lbytes len) =
for_all2 (fun a b -> uint_to_nat #U8 a = uint_to_nat #U8 b) test_expected test_result
false
LowStar.Lens.fst
LowStar.Lens.view
val view (#roots:_) (#view:_) (l:hs_lens roots view) (h:imem (inv l)) : GTot view
val view (#roots:_) (#view:_) (l:hs_lens roots view) (h:imem (inv l)) : GTot view
let view #roots #view (l:hs_lens roots view) (h:imem (inv l)) = l.l.get h
{ "file_name": "examples/data_structures/LowStar.Lens.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 11, "end_line": 31, "start_col": 0, "start_line": 30 }
(* 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 LowStar.Lens open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack module HST = FStar.HyperStack.ST let mods (l:hs_lens 'a 'b) (h:HS.mem) = B.modifies (as_loc l.footprint) l.snapshot h /\ FStar.HyperStack.ST.equal_domains l.snapshot h let inv #roots #view (l:hs_lens roots view) (h:HS.mem) = l.invariant l.x h /\ mods l h
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "LowStar.Lens.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
l: LowStar.Lens.hs_lens roots view -> h: LowStar.Lens.imem (LowStar.Lens.inv l) -> Prims.GTot view
Prims.GTot
[ "sometrivial" ]
[]
[ "LowStar.Lens.hs_lens", "LowStar.Lens.imem", "LowStar.Lens.inv", "LowStar.Lens.__proj__Mklens__item__get", "LowStar.Lens.__proj__Mkhs_lens__item__invariant", "LowStar.Lens.__proj__Mkhs_lens__item__x", "LowStar.Lens.__proj__Mkhs_lens__item__l" ]
[]
false
false
false
false
false
let view #roots #view (l: hs_lens roots view) (h: imem (inv l)) =
l.l.get h
false
Demo.MultiplyByRepeatedAddition.fst
Demo.MultiplyByRepeatedAddition.i
val i (x: U32.t) : GTot int
val i (x: U32.t) : GTot int
let i (x:U32.t) : GTot int = U32.v x
{ "file_name": "share/steel/examples/pulse/Demo.MultiplyByRepeatedAddition.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 36, "end_line": 83, "start_col": 0, "start_line": 83 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Demo.MultiplyByRepeatedAddition open Pulse.Lib.Pervasives open FStar.UInt32 #push-options "--using_facts_from '* -FStar.Tactics -FStar.Reflection'" #set-options "--ext 'pulse:rvalues' --split_queries always" #set-options "--z3rlimit 40" module U32 = FStar.UInt32 open FStar.Mul let rec multiply (x y:nat) : z:nat { z == x * y} = if x = 0 then 0 else multiply (x - 1) y + y ```pulse fn mult (x y:nat) requires emp returns z:nat ensures pure (z == x * y) { let mut ctr = 0; let mut acc = 0; while ((ctr < x)) invariant b. exists* c a. pts_to ctr c ** pts_to acc a ** pure (a == (c * y) /\ c <= x /\ b == (c < x)) { acc := acc + y; ctr := ctr + 1; }; acc } ``` open Pulse.Lib.BoundedIntegers #push-options "--z3rlimit 75 --split_queries always --retry 5" // batch mode fails without these options, IDE works ```pulse fn mult32 (x y:U32.t) requires pure (fits #U32.t (v x * v y)) returns z:U32.t ensures pure (v z == v x * v y) { let mut ctr = 0ul; let mut acc = 0ul; while ((ctr < x)) invariant b. exists* c a. pts_to ctr c ** pts_to acc a ** pure (c <= x /\ v a == (v c * v y) /\ b == (c < x)) { acc := acc + y; ctr := ctr + 1ul; }; acc } ``` #pop-options
{ "checked_file": "/", "dependencies": [ "Pulse.Lib.Pervasives.fst.checked", "Pulse.Lib.BoundedIntegers.fst.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Demo.MultiplyByRepeatedAddition.fst" }
[ { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.BoundedIntegers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Demo", "short_module": null }, { "abbrev": false, "full_module": "Demo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.UInt32.t -> Prims.GTot Prims.int
Prims.GTot
[ "sometrivial" ]
[]
[ "FStar.UInt32.t", "FStar.UInt32.v", "Prims.int" ]
[]
false
false
false
false
false
let i (x: U32.t) : GTot int =
U32.v x
false
Vale.Stdcalls.X64.GCM_IV.fst
Vale.Stdcalls.X64.GCM_IV.uint64
val uint64 : Prims.eqtype
let uint64 = UInt64.t
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCM_IV.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 21, "end_line": 27, "start_col": 0, "start_line": 27 }
module Vale.Stdcalls.X64.GCM_IV open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module GC = Vale.AES.X64.GCMencryptOpt open Vale.AES.GCM_s
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMencryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCM_IV.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMencryptOpt", "short_module": "GC" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.eqtype
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt64.t" ]
[]
false
false
false
true
false
let uint64 =
UInt64.t
false
Vale.Stdcalls.X64.GCM_IV.fst
Vale.Stdcalls.X64.GCM_IV.t128_no_mod
val t128_no_mod : Vale.Interop.Base.td
let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCM_IV.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 106, "end_line": 40, "start_col": 0, "start_line": 40 }
module Vale.Stdcalls.X64.GCM_IV open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module GC = Vale.AES.X64.GCMencryptOpt open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b128 = buf_t TUInt8 TUInt128 [@__reduce__] noextract let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMencryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCM_IV.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMencryptOpt", "short_module": "GC" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.Interop.Base.td
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.Base.TD_Buffer", "Vale.Arch.HeapTypes_s.TUInt8", "Vale.Arch.HeapTypes_s.TUInt128", "Vale.Interop.Base.Mkbuffer_qualifiers", "Vale.Arch.HeapTypes_s.Secret" ]
[]
false
false
false
true
false
let t128_no_mod =
TD_Buffer TUInt8 TUInt128 ({ modified = false; strict_disjointness = false; taint = MS.Secret })
false
RecordOfArrays.fst
RecordOfArrays.rec_array_perm
val rec_array_perm (r: rec_array) (v: rec_array_repr) : vprop
val rec_array_perm (r: rec_array) (v: rec_array_repr) : vprop
let rec_array_perm (r:rec_array) (v:rec_array_repr) : vprop = A.pts_to r.r1 v.v1 ** A.pts_to r.r2 v.v2
{ "file_name": "share/steel/examples/pulse/bug-reports/RecordOfArrays.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 20, "end_line": 40, "start_col": 0, "start_line": 37 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module RecordOfArrays open Pulse.Lib.Pervasives module R = Pulse.Lib.Reference module A = Pulse.Lib.Array module U8 = FStar.UInt8 module US = FStar.SizeT // Similar to Records, but with arrays noeq type rec_array = { r1: A.array U8.t; r2: A.array U8.t; } type rec_array_repr = { v1: Seq.seq U8.t; v2: Seq.seq U8.t; }
{ "checked_file": "/", "dependencies": [ "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Pervasives.fst.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "RecordOfArrays.fst" }
[ { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "Pulse.Lib.Array", "short_module": "A" }, { "abbrev": true, "full_module": "Pulse.Lib.Reference", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Lib.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: RecordOfArrays.rec_array -> v: RecordOfArrays.rec_array_repr -> Pulse.Lib.Core.vprop
Prims.Tot
[ "total" ]
[]
[ "RecordOfArrays.rec_array", "RecordOfArrays.rec_array_repr", "Pulse.Lib.Core.op_Star_Star", "Pulse.Lib.Array.Core.pts_to", "FStar.UInt8.t", "RecordOfArrays.__proj__Mkrec_array__item__r1", "PulseCore.FractionalPermission.full_perm", "RecordOfArrays.__proj__Mkrec_array_repr__item__v1", "RecordOfArrays.__proj__Mkrec_array__item__r2", "RecordOfArrays.__proj__Mkrec_array_repr__item__v2", "Pulse.Lib.Core.vprop" ]
[]
false
false
false
true
false
let rec_array_perm (r: rec_array) (v: rec_array_repr) : vprop =
A.pts_to r.r1 v.v1 ** A.pts_to r.r2 v.v2
false
Vale.Stdcalls.X64.GCM_IV.fst
Vale.Stdcalls.X64.GCM_IV.tuint64
val tuint64 : Vale.Interop.Base.td
let tuint64 = TD_Base TUInt64
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCM_IV.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 29, "end_line": 42, "start_col": 0, "start_line": 42 }
module Vale.Stdcalls.X64.GCM_IV open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module GC = Vale.AES.X64.GCMencryptOpt open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b128 = buf_t TUInt8 TUInt128 [@__reduce__] noextract let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq [@__reduce__] noextract let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMencryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCM_IV.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMencryptOpt", "short_module": "GC" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.Interop.Base.td
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.Base.TD_Base", "Vale.Arch.HeapTypes_s.TUInt64" ]
[]
false
false
false
true
false
let tuint64 =
TD_Base TUInt64
false
RecordOfArrays.fst
RecordOfArrays.mk_rec_array_repr
val mk_rec_array_repr : v1: FStar.Seq.Base.seq FStar.UInt8.t -> v2: FStar.Seq.Base.seq FStar.UInt8.t -> RecordOfArrays.rec_array_repr
let mk_rec_array_repr (v1 v2:Seq.seq U8.t) = { v1=v1; v2=v2 }
{ "file_name": "share/steel/examples/pulse/bug-reports/RecordOfArrays.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 61, "end_line": 44, "start_col": 0, "start_line": 44 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module RecordOfArrays open Pulse.Lib.Pervasives module R = Pulse.Lib.Reference module A = Pulse.Lib.Array module U8 = FStar.UInt8 module US = FStar.SizeT // Similar to Records, but with arrays noeq type rec_array = { r1: A.array U8.t; r2: A.array U8.t; } type rec_array_repr = { v1: Seq.seq U8.t; v2: Seq.seq U8.t; } let rec_array_perm (r:rec_array) (v:rec_array_repr) : vprop = A.pts_to r.r1 v.v1 ** A.pts_to r.r2 v.v2 //Using record syntax directly in Pulse vprops
{ "checked_file": "/", "dependencies": [ "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Pervasives.fst.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "RecordOfArrays.fst" }
[ { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "Pulse.Lib.Array", "short_module": "A" }, { "abbrev": true, "full_module": "Pulse.Lib.Reference", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Lib.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
v1: FStar.Seq.Base.seq FStar.UInt8.t -> v2: FStar.Seq.Base.seq FStar.UInt8.t -> RecordOfArrays.rec_array_repr
Prims.Tot
[ "total" ]
[]
[ "FStar.Seq.Base.seq", "FStar.UInt8.t", "RecordOfArrays.Mkrec_array_repr", "RecordOfArrays.rec_array_repr" ]
[]
false
false
false
true
false
let mk_rec_array_repr (v1 v2: Seq.seq U8.t) =
{ v1 = v1; v2 = v2 }
false
Vale.Stdcalls.X64.GCM_IV.fst
Vale.Stdcalls.X64.GCM_IV.t128_mod
val t128_mod : Vale.Interop.Base.td
let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCM_IV.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 51, "end_line": 38, "start_col": 0, "start_line": 38 }
module Vale.Stdcalls.X64.GCM_IV open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module GC = Vale.AES.X64.GCMencryptOpt open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b128 = buf_t TUInt8 TUInt128
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMencryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCM_IV.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMencryptOpt", "short_module": "GC" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.Interop.Base.td
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.Base.TD_Buffer", "Vale.Arch.HeapTypes_s.TUInt8", "Vale.Arch.HeapTypes_s.TUInt128", "Vale.Interop.Base.default_bq" ]
[]
false
false
false
true
false
let t128_mod =
TD_Buffer TUInt8 TUInt128 default_bq
false
Spec.Frodo.Test.fst
Spec.Frodo.Test.test1_ct_expected
val test1_ct_expected : Prims.list Lib.IntTypes.uint8
let test1_ct_expected = List.Tot.map u8_from_UInt8 [ 0xebuy; 0x01uy; 0x36uy; 0x7duy; 0xe9uy; 0xdauy; 0x51uy; 0x3fuy; 0x8duy; 0xc7uy; 0x53uy; 0xdeuy; 0xfcuy; 0xa2uy; 0x2cuy; 0xacuy; 0x2duy; 0xbcuy; 0x9buy; 0xacuy; 0x9cuy; 0xc0uy; 0xc5uy; 0x08uy; 0x9duy; 0x0duy; 0x07uy; 0xbcuy; 0xd8uy; 0x69uy; 0x20uy; 0xccuy; 0x18uy; 0x0cuy; 0xbcuy; 0x7buy; 0x49uy; 0x23uy; 0x06uy; 0x8cuy; 0x9cuy; 0xc4uy; 0x1fuy; 0xffuy; 0x53uy; 0x91uy; 0x9cuy; 0x7fuy; 0xb4uy; 0xa7uy; 0x28uy; 0xdfuy; 0x30uy; 0x5euy; 0x9euy; 0x19uy; 0xd1uy; 0xbbuy; 0xe7uy; 0xacuy; 0x0cuy; 0xb2uy; 0xbduy; 0x58uy; 0xd6uy; 0x96uy; 0x8buy; 0x04uy; 0x66uy; 0xf6uy; 0xbeuy; 0x58uy; 0x25uy; 0xf9uy; 0xfbuy; 0xe1uy; 0x13uy; 0x7auy; 0x88uy; 0x57uy; 0xb6uy; 0xb5uy; 0x71uy; 0xe6uy; 0xe2uy; 0x63uy; 0xd2uy; 0x85uy; 0x8duy; 0x07uy; 0x37uy; 0xe9uy; 0xaduy; 0xe9uy; 0x3duy; 0x95uy; 0xccuy; 0x7euy; 0x56uy; 0x2duy; 0xaauy; 0x0buy; 0x13uy; 0xdfuy; 0xe8uy; 0x19uy; 0x7euy; 0x52uy; 0x8duy; 0x7buy; 0xaauy; 0x09uy; 0x10uy; 0xb2uy; 0x32uy; 0x9cuy; 0x91uy; 0xf3uy; 0x14uy; 0x49uy; 0x4auy; 0x9fuy; 0x38uy; 0xc0uy; 0xf5uy; 0xf4uy; 0x44uy; 0xc6uy; 0xf6uy; 0xf8uy; 0xd0uy; 0xb0uy; 0x4fuy; 0xc1uy; 0xc3uy; 0xd7uy; 0x71uy; 0x18uy; 0xe3uy; 0xc0uy; 0xf5uy; 0x7auy; 0xd0uy; 0x04uy; 0x4fuy; 0xcfuy; 0x76uy; 0xdcuy; 0xeeuy; 0x35uy; 0x21uy; 0xe0uy; 0x9euy; 0x41uy; 0x10uy; 0x06uy; 0x2duy; 0xb8uy; 0x0cuy; 0xabuy; 0x1duy; 0x3duy; 0x60uy; 0xefuy; 0xaduy; 0xc5uy; 0x80uy; 0x09uy; 0x56uy; 0xeeuy; 0xcbuy; 0x53uy; 0x1buy; 0x50uy; 0x95uy; 0x34uy; 0x47uy; 0xaeuy; 0x70uy; 0x96uy; 0xbauy; 0x19uy; 0x55uy; 0x99uy; 0xd1uy; 0xb1uy; 0xe6uy; 0x32uy; 0xf0uy; 0x19uy; 0x3buy; 0x2buy; 0xc7uy; 0x9cuy; 0xf7uy; 0xcauy; 0xa7uy; 0x3auy; 0xd3uy; 0xdcuy; 0xecuy; 0xf2uy; 0x49uy; 0x43uy; 0x64uy; 0x7cuy; 0xfduy; 0x35uy; 0xe8uy; 0xfauy; 0xa5uy; 0x98uy; 0x01uy; 0x6buy; 0x4euy; 0xe5uy; 0x84uy; 0x03uy; 0x24uy; 0xb6uy; 0xc7uy; 0x30uy; 0x13uy; 0x44uy; 0xd3uy; 0xe6uy; 0x97uy; 0xefuy; 0xf7uy; 0x13uy; 0xefuy; 0x0euy; 0x9fuy; 0x12uy; 0x75uy; 0x76uy; 0x69uy; 0x7cuy; 0x91uy; 0x15uy; 0x6cuy; 0xc0uy; 0xc2uy; 0x60uy; 0x8cuy; 0x63uy; 0xa7uy; 0xfauy; 0xc2uy; 0xf4uy; 0x17uy; 0xbauy; 0x8buy; 0xd4uy; 0xcfuy; 0x4auy; 0x8duy; 0x63uy; 0xb8uy; 0xa4uy; 0x6buy; 0x9cuy; 0x87uy; 0x94uy; 0x37uy; 0x05uy; 0x9duy; 0xc4uy; 0x76uy; 0x24uy; 0x77uy; 0x79uy; 0x4duy; 0x93uy; 0x62uy; 0x0buy; 0xbcuy; 0x72uy; 0x7euy; 0xb2uy; 0xefuy; 0x3cuy; 0x00uy; 0x1cuy; 0x18uy; 0x18uy; 0xbbuy; 0xe8uy; 0x60uy; 0x6euy; 0xc5uy; 0x9buy; 0x47uy; 0x93uy; 0x77uy; 0xd8uy; 0xf0uy; 0x45uy; 0x16uy; 0x97uy; 0x15uy; 0xc0uy; 0xd3uy; 0x4euy; 0x6duy; 0xe9uy; 0xfeuy; 0x89uy; 0xc3uy; 0x87uy; 0x3auy; 0x49uy; 0xfbuy; 0x9duy; 0x86uy; 0xffuy; 0xcauy; 0xa1uy; 0x3fuy; 0x15uy; 0x37uy; 0xd8uy; 0x98uy; 0xeeuy; 0xd9uy; 0x36uy; 0x06uy; 0x33uy; 0xd8uy; 0xdauy; 0x82uy; 0xeeuy; 0x60uy; 0x8cuy; 0xc7uy; 0xf3uy; 0x19uy; 0x47uy; 0x15uy; 0x7fuy; 0xd3uy; 0xf1uy; 0x30uy; 0xa2uy; 0xc6uy; 0xc4uy; 0x04uy; 0x5cuy; 0x50uy; 0xa3uy; 0x48uy; 0xc8uy; 0x1buy; 0x35uy; 0xfeuy; 0xa5uy; 0xeauy; 0x8auy; 0x4auy; 0x8cuy; 0x9cuy; 0x85uy; 0x8cuy; 0x1fuy; 0xbbuy; 0x3duy; 0xafuy; 0x2euy; 0x3auy; 0xaduy; 0x34uy; 0x6cuy; 0x5duy; 0x87uy; 0xc9uy; 0xc9uy; 0x7fuy; 0x30uy; 0xc1uy; 0x8duy; 0x4cuy; 0xd6uy; 0xbfuy; 0xc0uy; 0xf8uy; 0xa7uy; 0xb2uy; 0x91uy; 0x9buy; 0xe7uy; 0x85uy; 0x96uy; 0xe8uy; 0xb3uy; 0xaeuy; 0x89uy; 0x53uy; 0x41uy; 0x48uy; 0x0euy; 0xd0uy; 0x6auy; 0x4euy; 0x0cuy; 0x7duy; 0x10uy; 0xa1uy; 0xe8uy; 0x9duy; 0x7cuy; 0xdcuy; 0x76uy; 0x91uy; 0x86uy; 0x70uy; 0x67uy; 0xe1uy; 0x76uy; 0x4duy; 0x23uy; 0xeauy; 0x55uy; 0x62uy; 0xb9uy; 0x61uy; 0x7fuy; 0x24uy; 0xd3uy; 0x06uy; 0xd8uy; 0x15uy; 0x88uy; 0x52uy; 0x92uy; 0x8auy; 0xc1uy; 0x8auy; 0x1cuy; 0x7buy; 0x40uy; 0xfauy; 0x03uy; 0xe0uy; 0x93uy; 0xf7uy; 0x2duy; 0xf1uy; 0xdcuy; 0x27uy; 0x10uy; 0xd4uy; 0x28uy; 0x0auy; 0x61uy; 0x87uy; 0xbfuy; 0x09uy; 0xfbuy; 0xb1uy; 0xc7uy; 0xd8uy; 0xe9uy; 0xfauy; 0xa5uy; 0xa8uy; 0x6buy; 0x6duy; 0xa0uy; 0x64uy; 0xb7uy; 0xe4uy; 0x86uy; 0x79uy; 0x6euy; 0x85uy; 0x93uy; 0x94uy; 0xc9uy; 0xdeuy; 0xa9uy; 0x40uy; 0xb3uy; 0x6euy; 0xa0uy; 0xa6uy; 0xc8uy; 0xc9uy; 0x84uy; 0x3euy; 0xdbuy; 0x1duy; 0xa8uy; 0xbcuy; 0x04uy; 0x1cuy; 0xa4uy; 0x4fuy; 0x70uy; 0x77uy; 0xafuy; 0x98uy; 0x71uy; 0xc6uy; 0xbeuy; 0x24uy; 0x58uy; 0xc9uy; 0x53uy; 0x20uy; 0xd2uy; 0xeauy; 0x3duy; 0xe7uy; 0x3fuy; 0x8cuy; 0x44uy; 0xc8uy; 0x3fuy; 0x14uy; 0x50uy; 0xcduy; 0xc8uy; 0x45uy; 0x99uy; 0xf8uy; 0xb6uy; 0xd5uy; 0x99uy; 0x5auy; 0x77uy; 0x61uy; 0x48uy; 0x9fuy; 0x1auy; 0xb0uy; 0x6fuy; 0x1cuy; 0x27uy; 0x35uy; 0x80uy; 0xe6uy; 0x1euy; 0xe2uy; 0x75uy; 0xafuy; 0xf8uy; 0x10uy; 0x6duy; 0x0euy; 0xe6uy; 0x8auy; 0xb5uy; 0xffuy; 0x6cuy; 0x1euy; 0x41uy; 0x60uy; 0x93uy; 0xebuy; 0xffuy; 0x9fuy; 0xffuy; 0xf7uy; 0xcauy; 0x77uy; 0x2fuy; 0xc2uy; 0x44uy; 0xe8uy; 0x86uy; 0x23uy; 0x8auy; 0x2euy; 0xa7uy; 0x1buy; 0xb2uy; 0x8auy; 0x6cuy; 0x79uy; 0x0euy; 0x4duy; 0xe2uy; 0x09uy; 0xa7uy; 0xdauy; 0x60uy; 0x54uy; 0x55uy; 0x36uy; 0xb9uy; 0x06uy; 0x51uy; 0xd9uy; 0x1duy; 0x6cuy; 0xaauy; 0x0buy; 0x03uy; 0xb1uy; 0x38uy; 0x63uy; 0xd7uy; 0x29uy; 0x76uy; 0xf6uy; 0xc5uy; 0x73uy; 0x0auy; 0x0euy; 0x1duy; 0xf7uy; 0xc9uy; 0x5auy; 0xdauy; 0xdcuy; 0x64uy; 0xd5uy; 0x9fuy; 0x51uy; 0xc8uy; 0x8euy; 0x6fuy; 0xf6uy; 0xb9uy; 0x0cuy; 0xd4uy; 0x57uy; 0x5duy; 0x82uy; 0x4euy; 0xeeuy; 0xc6uy; 0x8auy; 0xf5uy; 0x7fuy; 0x59uy; 0xe1uy; 0x0cuy; 0xb8uy; 0xe7uy; 0xf6uy; 0xc6uy; 0x2auy; 0xb1uy; 0x5auy; 0xbauy; 0x77uy; 0xa0uy; 0x30uy; 0x19uy; 0x10uy; 0xe6uy; 0x5auy; 0x90uy; 0x03uy; 0x21uy; 0x3euy; 0xd8uy; 0xc1uy; 0xc5uy; 0xc5uy; 0x81uy; 0xf7uy; 0xc1uy; 0x6auy; 0xfauy; 0xecuy; 0xf6uy; 0x31uy; 0x0duy; 0xf6uy; 0x85uy; 0x9fuy; 0xb5uy; 0x34uy; 0x38uy; 0xf8uy; 0xc1uy; 0xe6uy; 0x7euy; 0x67uy; 0x8buy; 0x14uy; 0x01uy; 0x3buy; 0x32uy; 0xb6uy; 0xb1uy; 0x90uy; 0x91uy; 0xbcuy; 0x40uy; 0x90uy; 0x72uy; 0x55uy; 0x76uy; 0x2buy; 0x34uy; 0x3buy; 0x05uy; 0x65uy; 0x87uy; 0x0euy; 0x4buy; 0xb5uy; 0xcduy; 0x94uy; 0x88uy; 0x60uy; 0xf0uy; 0x7duy; 0xc9uy; 0x21uy; 0x71uy; 0xe2uy; 0x55uy; 0x43uy; 0x06uy; 0x1cuy; 0x84uy; 0x02uy; 0xd0uy; 0x4euy; 0xcbuy; 0x1buy; 0x38uy; 0x6duy; 0x58uy; 0x62uy; 0xabuy; 0x50uy; 0xcfuy; 0xb5uy; 0x47uy; 0x24uy; 0xb8uy; 0x6cuy; 0x00uy; 0xa4uy; 0xf2uy; 0x97uy; 0x9fuy; 0xf3uy; 0x98uy; 0x2euy; 0xf9uy; 0x4fuy; 0x02uy; 0xdcuy; 0x1duy; 0xc6uy; 0x08uy; 0x35uy; 0x57uy; 0xe5uy; 0x9buy; 0xd7uy; 0xf4uy; 0xd7uy; 0x28uy; 0x50uy; 0x39uy; 0xfduy; 0xd8uy; 0xe6uy; 0xbfuy; 0xcauy; 0x61uy; 0x65uy; 0xe3uy; 0xd0uy; 0x95uy; 0x65uy; 0x68uy; 0xb1uy; 0x41uy; 0x65uy; 0x1auy; 0x62uy; 0xceuy; 0x65uy; 0x8fuy; 0xeeuy; 0xe7uy; 0x7auy; 0x3cuy; 0x04uy; 0x95uy; 0x01uy; 0xd1uy; 0x31uy; 0x75uy; 0x80uy; 0x69uy; 0x1euy; 0x4buy; 0xb3uy; 0x4fuy; 0xb9uy; 0x5buy; 0x5cuy; 0x8euy; 0x16uy; 0x01uy; 0x99uy; 0x02uy; 0x55uy; 0x94uy; 0x0buy; 0xa9uy; 0x49uy; 0x7cuy; 0x10uy; 0xd4uy; 0xc9uy; 0xdduy; 0x2buy; 0xabuy; 0x8buy; 0x4cuy; 0x21uy; 0x7auy; 0x7duy; 0x53uy; 0x7buy; 0xd0uy; 0x69uy; 0x45uy; 0xcauy; 0x9auy; 0x91uy; 0x40uy; 0x54uy; 0x03uy; 0xb3uy; 0x56uy; 0x0euy; 0xc6uy; 0x68uy; 0x30uy; 0xdcuy; 0xb1uy; 0xffuy; 0xe4uy; 0x3fuy; 0x0euy; 0x1euy; 0xc0uy; 0x56uy; 0xb2uy; 0xe1uy; 0xfcuy; 0x58uy; 0xf5uy; 0xabuy; 0x39uy; 0x4euy; 0xdduy; 0x33uy; 0xbcuy; 0x12uy; 0xc5uy; 0xdcuy; 0x77uy; 0x46uy; 0x84uy; 0x82uy; 0xb2uy; 0x7fuy; 0xa2uy; 0xf6uy; 0x06uy; 0x24uy; 0xd6uy; 0x3cuy; 0xe3uy; 0xc5uy; 0xc2uy; 0x18uy; 0xc4uy; 0xc9uy; 0xf5uy; 0xa3uy; 0x2auy; 0x56uy; 0x5buy; 0x59uy; 0xe7uy; 0x00uy; 0x92uy; 0xb4uy; 0xd6uy; 0xf9uy; 0x96uy; 0x7cuy; 0x01uy; 0x26uy; 0x1euy; 0x5fuy; 0x27uy; 0x9cuy; 0x1buy; 0xb7uy; 0xf7uy; 0x36uy; 0xebuy; 0x7auy; 0xf3uy; 0xa7uy; 0x5euy; 0x38uy; 0xb2uy; 0x7buy; 0x7fuy; 0xd1uy; 0x4euy; 0x68uy; 0xb9uy; 0xa9uy; 0xf8uy; 0x7auy; 0x06uy; 0xb4uy; 0xe8uy; 0x42uy; 0xd8uy; 0xc7uy; 0x5auy; 0x08uy; 0xd5uy; 0x67uy; 0xa7uy; 0x30uy; 0xb6uy; 0x2euy; 0x80uy; 0xacuy; 0xa9uy; 0x07uy; 0xbbuy; 0x18uy; 0x54uy; 0xc3uy; 0x81uy; 0x6euy; 0x8auy; 0x24uy; 0xc0uy; 0x7fuy; 0xd0uy; 0x54uy; 0xb2uy; 0xe7uy; 0x1auy; 0x11uy; 0xf4uy; 0x9duy; 0x2cuy; 0x75uy; 0x37uy; 0x2euy; 0xc6uy; 0xfcuy; 0x85uy; 0x5duy; 0x46uy; 0x44uy; 0x7auy; 0x36uy; 0xe5uy; 0x62uy; 0xa4uy; 0x26uy; 0xdduy; 0x4cuy; 0x20uy; 0x33uy; 0x7auy; 0x8auy; 0x41uy; 0x8auy; 0x0fuy; 0xa4uy; 0xf8uy; 0x74uy; 0x45uy; 0x98uy; 0xe3uy; 0x73uy; 0xa1uy; 0x4euy; 0x40uy; 0x10uy; 0x5buy; 0x0fuy; 0xa0uy; 0xe4uy; 0x5euy; 0x97uy; 0x40uy; 0xdcuy; 0x68uy; 0x79uy; 0xd7uy; 0xfeuy; 0xfduy; 0x34uy; 0xd0uy; 0xb7uy; 0xcbuy; 0x4auy; 0xf3uy; 0xb0uy; 0xc7uy; 0xf5uy; 0xbauy; 0x6cuy; 0xa9uy; 0xf0uy; 0x82uy; 0x01uy; 0xb2uy; 0x3fuy; 0x9euy; 0x56uy; 0x9cuy; 0x86uy; 0x05uy; 0x03uy; 0x99uy; 0x2euy; 0xe7uy; 0xeduy; 0xdfuy; 0xfeuy; 0x05uy; 0x3buy; 0xdbuy; 0x3cuy; 0x30uy; 0x98uy; 0xa2uy; 0x23uy; 0x86uy; 0xefuy; 0x80uy; 0xe4uy; 0x2fuy; 0xdeuy; 0x8cuy; 0x7duy; 0x2euy; 0x78uy; 0xdbuy; 0xd6uy; 0xcauy; 0x7fuy; 0x79uy; 0x7auy; 0x3buy; 0xafuy; 0x2auy; 0xeduy; 0xf3uy; 0x03uy; 0x15uy; 0xccuy; 0x3duy; 0x52uy; 0x50uy; 0x1duy; 0x08uy; 0x93uy; 0xa2uy; 0xd8uy; 0x63uy; 0x91uy; 0xa0uy; 0x6cuy; 0xccuy ]
{ "file_name": "specs/tests/Spec.Frodo.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 258, "start_col": 0, "start_line": 165 }
module Spec.Frodo.Test open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Frodo.KEM open Spec.Frodo.KEM.KeyGen open Spec.Frodo.KEM.Encaps open Spec.Frodo.KEM.Decaps open Spec.Frodo.Params open FStar.All module PS = Lib.PrintSequence #set-options "--z3rlimit 50 --fuel 0 --ifuel 1" let compare (#len: size_nat) (test_expected: lbytes len) (test_result: lbytes len) = for_all2 (fun a b -> uint_to_nat #U8 a = uint_to_nat #U8 b) test_expected test_result let test_frodo (a:frodo_alg) (gen_a:frodo_gen_a) (keypaircoins: list uint8 {List.Tot.length keypaircoins == 2 * crypto_bytes a + bytes_seed_a}) (enccoins: list uint8 {List.Tot.length enccoins == bytes_mu a}) (ss_expected: list uint8 {List.Tot.length ss_expected == crypto_bytes a}) (pk_expected: list uint8 {List.Tot.length pk_expected == crypto_publickeybytes a}) (ct_expected: list uint8 {List.Tot.length ct_expected == crypto_ciphertextbytes a}) (sk_expected: list uint8 {List.Tot.length sk_expected == crypto_secretkeybytes a}) : ML bool = let keypaircoins = createL keypaircoins in let enccoins = createL enccoins in let ss_expected = createL ss_expected in let pk_expected = createL pk_expected in let ct_expected = createL ct_expected in let sk_expected = createL sk_expected in let pk, sk = crypto_kem_keypair_ a gen_a keypaircoins in let ct, ss1 = crypto_kem_enc_ a gen_a enccoins pk in let ss2 = crypto_kem_dec a gen_a ct sk in let r_pk = compare pk_expected pk in let r_sk = compare sk_expected sk in let r_ct = compare ct_expected ct in let r_ss = PS.print_compare true (crypto_bytes a) ss1 ss2 in let r_ss1 = PS.print_compare true (crypto_bytes a) ss_expected ss2 in r_pk && r_sk && r_ct && r_ss && r_ss1 // // Test1. FrodoKEM-64. SHAKE128 // let test1_keypaircoins = List.Tot.map u8_from_UInt8 [ 0xa6uy; 0x65uy; 0x65uy; 0x9fuy; 0xfbuy; 0xe4uy; 0x06uy; 0x5cuy; 0xcauy; 0x81uy; 0x5auy; 0x45uy; 0xe4uy; 0x94uy; 0xd8uy; 0x01uy; 0x90uy; 0x30uy; 0x33uy; 0x55uy; 0x33uy; 0x84uy; 0x2euy; 0xe4uy; 0x4cuy; 0x55uy; 0x8fuy; 0xd8uy; 0xaeuy; 0x4buy; 0x4euy; 0x91uy; 0x62uy; 0xfeuy; 0xc7uy; 0x9auy; 0xc5uy; 0xcduy; 0x1fuy; 0xe2uy; 0xd2uy; 0x00uy; 0x63uy; 0x39uy; 0xaauy; 0xb1uy; 0xf3uy; 0x17uy ] let test1_enccoins = List.Tot.map u8_from_UInt8 [ 0x8duy; 0xf3uy; 0xfauy; 0xe3uy; 0x83uy; 0x27uy; 0xc5uy; 0x3cuy; 0xc1uy; 0xc4uy; 0x8cuy; 0x60uy; 0xb2uy; 0x52uy; 0x2buy; 0xb5uy ] let test1_ss_expected = List.Tot.map u8_from_UInt8 [ 0xf8uy; 0x96uy; 0x15uy; 0x94uy; 0x80uy; 0x9fuy; 0xebuy; 0x77uy; 0x56uy; 0xbeuy; 0x37uy; 0x69uy; 0xa0uy; 0xeauy; 0x60uy; 0x16uy ] let test1_pk_expected = List.Tot.map u8_from_UInt8 [ 0x0duy; 0xacuy; 0x6fuy; 0x83uy; 0x94uy; 0x00uy; 0x1auy; 0xcauy; 0x97uy; 0xa1uy; 0xaauy; 0x42uy; 0x80uy; 0x9duy; 0x6buy; 0xa5uy; 0xfcuy; 0x64uy; 0x43uy; 0xdbuy; 0xbeuy; 0x6fuy; 0x12uy; 0x2auy; 0x94uy; 0x58uy; 0x36uy; 0xf2uy; 0xb1uy; 0xf8uy; 0xe5uy; 0xf0uy; 0x57uy; 0x4buy; 0x35uy; 0x51uy; 0xdduy; 0x8cuy; 0x36uy; 0x28uy; 0x34uy; 0x46uy; 0xd6uy; 0xafuy; 0x5duy; 0x49uy; 0x0euy; 0x27uy; 0xd8uy; 0xd3uy; 0xaduy; 0xe1uy; 0xeduy; 0x8buy; 0x2duy; 0x13uy; 0xf5uy; 0x5auy; 0xb6uy; 0xdduy; 0xc0uy; 0x54uy; 0x76uy; 0x09uy; 0xa6uy; 0xa4uy; 0x01uy; 0xb9uy; 0xb7uy; 0xd1uy; 0x26uy; 0xd5uy; 0x1euy; 0xa8uy; 0x20uy; 0x4duy; 0xe8uy; 0xefuy; 0xaduy; 0xb9uy; 0xf0uy; 0x65uy; 0xe9uy; 0xc4uy; 0xf4uy; 0x11uy; 0x98uy; 0x99uy; 0xf0uy; 0x2cuy; 0x63uy; 0x7buy; 0x98uy; 0xd7uy; 0x60uy; 0x43uy; 0x5duy; 0x8cuy; 0x85uy; 0xe9uy; 0xc5uy; 0x83uy; 0x83uy; 0x62uy; 0xe2uy; 0x13uy; 0x33uy; 0x54uy; 0x4buy; 0x71uy; 0xaeuy; 0x63uy; 0xbauy; 0x5auy; 0x4euy; 0x32uy; 0x59uy; 0x78uy; 0x6buy; 0x4duy; 0x39uy; 0xcfuy; 0xe1uy; 0x82uy; 0x58uy; 0x0auy; 0xc3uy; 0x61uy; 0x6auy; 0x89uy; 0x2fuy; 0x1buy; 0x70uy; 0xdduy; 0x16uy; 0x3euy; 0x96uy; 0xb1uy; 0x4cuy; 0x71uy; 0xb1uy; 0x79uy; 0x0cuy; 0x3fuy; 0xe2uy; 0xeduy; 0x05uy; 0x07uy; 0x72uy; 0xf3uy; 0x89uy; 0x08uy; 0x8cuy; 0x22uy; 0xa7uy; 0x36uy; 0x40uy; 0xcauy; 0x52uy; 0x70uy; 0x1buy; 0x09uy; 0xcbuy; 0xabuy; 0x3buy; 0x64uy; 0x61uy; 0x6duy; 0x5duy; 0xf7uy; 0x15uy; 0x69uy; 0x71uy; 0x3buy; 0x3auy; 0x2euy; 0x53uy; 0x33uy; 0x26uy; 0xe6uy; 0x29uy; 0x5cuy; 0xfbuy; 0x0duy; 0xc6uy; 0xe4uy; 0xbduy; 0x9cuy; 0x43uy; 0xffuy; 0xa6uy; 0x5buy; 0x49uy; 0x47uy; 0x93uy; 0x1cuy; 0x81uy; 0x6fuy; 0xd4uy; 0xaauy; 0x3duy; 0xaduy; 0x86uy; 0xf5uy; 0x94uy; 0x16uy; 0x7fuy; 0x31uy; 0x91uy; 0x30uy; 0x97uy; 0xc4uy; 0xa3uy; 0xe4uy; 0x01uy; 0x2buy; 0x06uy; 0xcfuy; 0x69uy; 0xfbuy; 0x69uy; 0x35uy; 0xaauy; 0x81uy; 0xeduy; 0x90uy; 0x0cuy; 0x3auy; 0xc0uy; 0xa6uy; 0x06uy; 0xabuy; 0x51uy; 0x3fuy; 0x39uy; 0xb2uy; 0x1euy; 0xb0uy; 0x4buy; 0xbcuy; 0xd0uy; 0xd0uy; 0x3auy; 0xdauy; 0x89uy; 0x88uy; 0xa6uy; 0x56uy; 0xd8uy; 0x02uy; 0x98uy; 0xeeuy; 0xa2uy; 0xf5uy; 0x0euy; 0xbauy; 0x7cuy; 0x52uy; 0xafuy; 0xf4uy; 0xbbuy; 0xe7uy; 0x36uy; 0x4auy; 0xdduy; 0x90uy; 0x93uy; 0xe9uy; 0x5duy; 0xbeuy; 0x68uy; 0x99uy; 0xc2uy; 0xaduy; 0x4duy; 0x79uy; 0x25uy; 0x0buy; 0x69uy; 0x79uy; 0x7buy; 0xe2uy; 0x3duy; 0xa8uy; 0xe7uy; 0xf1uy; 0x42uy; 0x0cuy; 0x22uy; 0x85uy; 0x95uy; 0xf0uy; 0xd5uy; 0x5cuy; 0x96uy; 0x35uy; 0xb6uy; 0x19uy; 0xaeuy; 0xb3uy; 0xcfuy; 0x22uy; 0xcauy; 0xbauy; 0x28uy; 0xd6uy; 0xdduy; 0xd5uy; 0x8euy; 0xe8uy; 0xd6uy; 0x90uy; 0x23uy; 0x8euy; 0x97uy; 0x37uy; 0xe9uy; 0xcduy; 0xabuy; 0xdcuy; 0x08uy; 0x04uy; 0xe1uy; 0x32uy; 0x02uy; 0xffuy; 0x7fuy; 0x82uy; 0x41uy; 0xf3uy; 0x9buy; 0x1duy; 0x42uy; 0x8auy; 0x98uy; 0x80uy; 0x81uy; 0xaauy; 0xbeuy; 0x7duy; 0x3buy; 0x83uy; 0x30uy; 0x4duy; 0x4auy; 0x22uy; 0x2duy; 0xafuy; 0x61uy; 0xd1uy; 0xa0uy; 0x66uy; 0xd4uy; 0x48uy; 0x0fuy; 0xe1uy; 0xd9uy; 0x77uy; 0x82uy; 0xc5uy; 0xa1uy; 0x2auy; 0x03uy; 0x1fuy; 0xd0uy; 0x7auy; 0xccuy; 0x77uy; 0x09uy; 0x4auy; 0xbduy; 0xaduy; 0xf7uy; 0x76uy; 0xdcuy; 0x10uy; 0xeduy; 0x5buy; 0xdfuy; 0x89uy; 0xfbuy; 0x52uy; 0x60uy; 0x5cuy; 0x08uy; 0x42uy; 0x50uy; 0xd1uy; 0xdauy; 0x24uy; 0xbbuy; 0x59uy; 0x3euy; 0x14uy; 0xf4uy; 0xf0uy; 0xf4uy; 0xdauy; 0xb8uy; 0x00uy; 0xe2uy; 0x0buy; 0xfauy; 0xc3uy; 0xf6uy; 0x28uy; 0x8duy; 0x20uy; 0x26uy; 0xe9uy; 0x5buy; 0x25uy; 0xa8uy; 0x80uy; 0x4cuy; 0xeeuy; 0xc9uy; 0xb6uy; 0x7auy; 0x8buy; 0x87uy; 0x21uy; 0xfduy; 0xaeuy; 0xd5uy; 0xa8uy; 0x49uy; 0x33uy; 0x58uy; 0x90uy; 0x2cuy; 0x0auy; 0xcauy; 0xb0uy; 0x9duy; 0xbeuy; 0xcduy; 0xe0uy; 0xa4uy; 0x99uy; 0x76uy; 0x01uy; 0x80uy; 0xdduy; 0x66uy; 0x76uy; 0x70uy; 0x05uy; 0xf3uy; 0xd6uy; 0x31uy; 0xa1uy; 0x9euy; 0xd5uy; 0x5fuy; 0x1buy; 0xdduy; 0x7fuy; 0x81uy; 0x6duy; 0x5cuy; 0xe9uy; 0xa3uy; 0x1auy; 0x6auy; 0x87uy; 0x93uy; 0xaduy; 0x1duy; 0x73uy; 0x44uy; 0xbcuy; 0xe4uy; 0x42uy; 0x78uy; 0x6auy; 0x71uy; 0x58uy; 0x9buy; 0x73uy; 0x55uy; 0x63uy; 0xa5uy; 0x32uy; 0xf6uy; 0x55uy; 0x68uy; 0x05uy; 0xcfuy; 0xeduy; 0x5fuy; 0x86uy; 0xe2uy; 0x65uy; 0xefuy; 0xf1uy; 0xb9uy; 0x69uy; 0xbbuy; 0x79uy; 0xb1uy; 0xf4uy; 0x7fuy; 0xa5uy; 0xfauy; 0x62uy; 0xbcuy; 0x68uy; 0xe7uy; 0xf6uy; 0xf8uy; 0xf0uy; 0x55uy; 0xf4uy; 0x93uy; 0x47uy; 0x06uy; 0xf0uy; 0x3euy; 0x94uy; 0x4auy; 0x95uy; 0xc8uy; 0x0cuy; 0xb0uy; 0x04uy; 0x4euy; 0x3fuy; 0x67uy; 0x14uy; 0xeduy; 0xbbuy; 0xbeuy; 0xf0uy; 0xabuy; 0xdduy; 0x6cuy; 0x23uy; 0x4euy; 0x07uy; 0x66uy; 0x41uy; 0x55uy; 0xbeuy; 0x22uy; 0x59uy; 0xd5uy; 0xdauy; 0xd4uy; 0xd8uy; 0x3duy; 0xb0uy; 0x74uy; 0xc4uy; 0x4fuy; 0x9buy; 0x43uy; 0xe5uy; 0x75uy; 0xfbuy; 0x33uy; 0x0euy; 0xdfuy; 0xe1uy; 0xe3uy; 0x7duy; 0x2euy; 0x80uy; 0x10uy; 0x79uy; 0x17uy; 0xeauy; 0xd3uy; 0x18uy; 0x98uy; 0x08uy; 0xeduy; 0x79uy; 0x4cuy; 0xb9uy; 0x66uy; 0x03uy; 0x04uy; 0x50uy; 0xfeuy; 0x62uy; 0x0duy; 0x48uy; 0x1auy; 0x6cuy; 0xeeuy; 0xb7uy; 0x03uy; 0x15uy; 0x92uy; 0x41uy; 0x1euy; 0xa1uy; 0x88uy; 0x46uy; 0x1auy; 0x43uy; 0x49uy; 0xf5uy; 0x93uy; 0x33uy; 0x00uy; 0x65uy; 0x69uy; 0xa8uy; 0x82uy; 0xbduy; 0xbeuy; 0x5cuy; 0x56uy; 0xa3uy; 0x06uy; 0x00uy; 0x8buy; 0x2fuy; 0x7duy; 0xecuy; 0xa4uy; 0x9auy; 0x2auy; 0xaeuy; 0x66uy; 0x07uy; 0x46uy; 0xb3uy; 0xbeuy; 0xf8uy; 0x07uy; 0x08uy; 0x10uy; 0x87uy; 0xd5uy; 0x6cuy; 0x6auy; 0xa5uy; 0xa6uy; 0x07uy; 0x4buy; 0x00uy; 0xc1uy; 0x5auy; 0xeduy; 0x7fuy; 0x14uy; 0x4buy; 0x60uy; 0x02uy; 0xc2uy; 0x67uy; 0x0cuy; 0xa4uy; 0x64uy; 0x54uy; 0x3euy; 0x22uy; 0xfeuy; 0x21uy; 0xcduy; 0x0duy; 0xcbuy; 0x60uy; 0x3buy; 0x13uy; 0xb0uy; 0x8euy; 0x36uy; 0xcauy; 0xcduy; 0x78uy; 0x8duy; 0x08uy; 0x2auy; 0xf1uy; 0x9cuy; 0x17uy; 0x11uy; 0x14uy; 0x57uy; 0x57uy; 0xe8uy; 0x3buy; 0x84uy; 0xe8uy; 0x59uy; 0xdbuy; 0x5buy; 0x77uy; 0x2euy; 0x54uy; 0x3buy; 0x6euy; 0x9cuy; 0x5euy; 0x7fuy; 0x52uy; 0xe5uy; 0x06uy; 0x8auy; 0x2duy; 0xc3uy; 0xbfuy; 0x30uy; 0x34uy; 0x8cuy; 0xaauy; 0x3buy; 0x23uy; 0x59uy; 0x32uy; 0x5fuy; 0xf7uy; 0xc9uy; 0xb2uy; 0xeeuy; 0xb2uy; 0x72uy; 0x75uy; 0x33uy; 0x8euy; 0xa9uy; 0x68uy; 0x6euy; 0xf5uy; 0x61uy; 0x7auy; 0x20uy; 0x01uy; 0xecuy; 0xabuy; 0x19uy; 0x26uy; 0xbeuy; 0x38uy; 0x49uy; 0xe2uy; 0x16uy; 0xceuy; 0x17uy; 0xafuy; 0xcauy; 0xe3uy; 0x06uy; 0xeauy; 0x37uy; 0x98uy; 0xf2uy; 0x8fuy; 0x04uy; 0x9buy; 0xabuy; 0xd8uy; 0xbduy; 0x78uy; 0x68uy; 0xacuy; 0xefuy; 0xb9uy; 0x28uy; 0x6fuy; 0x0buy; 0x37uy; 0x90uy; 0xb3uy; 0x74uy; 0x0cuy; 0x38uy; 0x12uy; 0x70uy; 0xa2uy; 0xbeuy; 0xdcuy; 0xa7uy; 0x18uy; 0xdfuy; 0x5euy; 0xd2uy; 0x62uy; 0xccuy; 0x43uy; 0x24uy; 0x32uy; 0x58uy; 0x45uy; 0x18uy; 0x0auy; 0xe1uy; 0x0duy; 0x82uy; 0xbcuy; 0x08uy; 0xb1uy; 0xa9uy; 0x7euy; 0x63uy; 0x09uy; 0xc6uy; 0x83uy; 0xa1uy; 0xe6uy; 0x5cuy; 0x9cuy; 0xefuy; 0x57uy; 0xecuy; 0xc7uy; 0x73uy; 0x19uy; 0xfbuy; 0x5cuy; 0x20uy; 0xe1uy; 0xdfuy; 0x85uy; 0x76uy; 0xabuy; 0x89uy; 0xb7uy; 0x96uy; 0x8duy; 0xd9uy; 0x8euy; 0xb7uy; 0x00uy; 0xa8uy; 0xc6uy; 0x98uy; 0x47uy; 0x03uy; 0xafuy; 0x56uy; 0x1fuy; 0x35uy; 0x49uy; 0x75uy; 0x4cuy; 0xa2uy; 0xa2uy; 0xdcuy; 0x98uy; 0xbfuy; 0x87uy; 0xeduy; 0x73uy; 0x5fuy; 0x9buy; 0xabuy; 0x3euy; 0x02uy; 0xdcuy; 0xa1uy; 0x4buy; 0x6cuy; 0xacuy; 0x10uy; 0xb2uy; 0x0buy; 0x99uy; 0xeeuy; 0xc8uy; 0xc2uy; 0x82uy; 0xa9uy; 0xf9uy; 0xa9uy; 0xa5uy; 0x4duy; 0xc9uy; 0x39uy; 0x41uy; 0x89uy; 0x0cuy; 0xc6uy; 0xe3uy; 0xaauy; 0x76uy; 0xe7uy; 0x11uy; 0x16uy; 0x8auy; 0x28uy; 0x6buy; 0x22uy; 0x3auy; 0x1euy; 0x7duy; 0xe6uy; 0xf7uy; 0x55uy; 0x85uy; 0x8cuy; 0x36uy; 0x57uy; 0x0buy; 0xdbuy; 0xe6uy; 0xefuy; 0xd9uy; 0xf6uy; 0x94uy; 0x48uy; 0x31uy; 0x7euy; 0xaauy; 0x13uy; 0xd4uy; 0x58uy; 0x9buy; 0xebuy; 0x7cuy; 0x2auy; 0x39uy; 0xdduy; 0xa3uy; 0x3fuy; 0x70uy; 0xfduy; 0x7fuy; 0x30uy; 0xa3uy; 0x34uy; 0xe6uy; 0xacuy; 0x64uy; 0x9buy; 0xf8uy; 0xbbuy; 0x1euy; 0x51uy; 0xe1uy; 0xaduy; 0x61uy; 0xf6uy; 0xffuy; 0xd4uy; 0x4auy; 0x5euy; 0x12uy; 0x40uy; 0xdcuy; 0x07uy; 0x8buy; 0xb2uy; 0xe0uy; 0xb9uy; 0x29uy; 0xaauy; 0x4euy; 0x85uy; 0xf5uy; 0xbduy; 0x5buy; 0x43uy; 0x77uy; 0xc7uy; 0x0buy; 0xfeuy; 0x66uy; 0x49uy; 0xccuy; 0xb5uy; 0x92uy; 0x4auy; 0x14uy; 0x1euy; 0xe2uy; 0xe5uy; 0x20uy; 0xfauy; 0xecuy; 0x0fuy; 0xc9uy ]
{ "checked_file": "/", "dependencies": [ "Spec.Frodo.Params.fst.checked", "Spec.Frodo.KEM.KeyGen.fst.checked", "Spec.Frodo.KEM.Encaps.fst.checked", "Spec.Frodo.KEM.Decaps.fst.checked", "Spec.Frodo.KEM.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.IO.fst.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Test.fst" }
[ { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.Params", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.KEM.Decaps", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.KEM.Encaps", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.KEM.KeyGen", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.list Lib.IntTypes.uint8
Prims.Tot
[ "total" ]
[]
[ "FStar.List.Tot.Base.map", "FStar.UInt8.t", "Lib.IntTypes.uint8", "Lib.RawIntTypes.u8_from_UInt8", "Prims.Cons", "FStar.UInt8.__uint_to_t", "Prims.Nil" ]
[]
false
false
false
true
false
let test1_ct_expected =
List.Tot.map u8_from_UInt8 [ 0xebuy; 0x01uy; 0x36uy; 0x7duy; 0xe9uy; 0xdauy; 0x51uy; 0x3fuy; 0x8duy; 0xc7uy; 0x53uy; 0xdeuy; 0xfcuy; 0xa2uy; 0x2cuy; 0xacuy; 0x2duy; 0xbcuy; 0x9buy; 0xacuy; 0x9cuy; 0xc0uy; 0xc5uy; 0x08uy; 0x9duy; 0x0duy; 0x07uy; 0xbcuy; 0xd8uy; 0x69uy; 0x20uy; 0xccuy; 0x18uy; 0x0cuy; 0xbcuy; 0x7buy; 0x49uy; 0x23uy; 0x06uy; 0x8cuy; 0x9cuy; 0xc4uy; 0x1fuy; 0xffuy; 0x53uy; 0x91uy; 0x9cuy; 0x7fuy; 0xb4uy; 0xa7uy; 0x28uy; 0xdfuy; 0x30uy; 0x5euy; 0x9euy; 0x19uy; 0xd1uy; 0xbbuy; 0xe7uy; 0xacuy; 0x0cuy; 0xb2uy; 0xbduy; 0x58uy; 0xd6uy; 0x96uy; 0x8buy; 0x04uy; 0x66uy; 0xf6uy; 0xbeuy; 0x58uy; 0x25uy; 0xf9uy; 0xfbuy; 0xe1uy; 0x13uy; 0x7auy; 0x88uy; 0x57uy; 0xb6uy; 0xb5uy; 0x71uy; 0xe6uy; 0xe2uy; 0x63uy; 0xd2uy; 0x85uy; 0x8duy; 0x07uy; 0x37uy; 0xe9uy; 0xaduy; 0xe9uy; 0x3duy; 0x95uy; 0xccuy; 0x7euy; 0x56uy; 0x2duy; 0xaauy; 0x0buy; 0x13uy; 0xdfuy; 0xe8uy; 0x19uy; 0x7euy; 0x52uy; 0x8duy; 0x7buy; 0xaauy; 0x09uy; 0x10uy; 0xb2uy; 0x32uy; 0x9cuy; 0x91uy; 0xf3uy; 0x14uy; 0x49uy; 0x4auy; 0x9fuy; 0x38uy; 0xc0uy; 0xf5uy; 0xf4uy; 0x44uy; 0xc6uy; 0xf6uy; 0xf8uy; 0xd0uy; 0xb0uy; 0x4fuy; 0xc1uy; 0xc3uy; 0xd7uy; 0x71uy; 0x18uy; 0xe3uy; 0xc0uy; 0xf5uy; 0x7auy; 0xd0uy; 0x04uy; 0x4fuy; 0xcfuy; 0x76uy; 0xdcuy; 0xeeuy; 0x35uy; 0x21uy; 0xe0uy; 0x9euy; 0x41uy; 0x10uy; 0x06uy; 0x2duy; 0xb8uy; 0x0cuy; 0xabuy; 0x1duy; 0x3duy; 0x60uy; 0xefuy; 0xaduy; 0xc5uy; 0x80uy; 0x09uy; 0x56uy; 0xeeuy; 0xcbuy; 0x53uy; 0x1buy; 0x50uy; 0x95uy; 0x34uy; 0x47uy; 0xaeuy; 0x70uy; 0x96uy; 0xbauy; 0x19uy; 0x55uy; 0x99uy; 0xd1uy; 0xb1uy; 0xe6uy; 0x32uy; 0xf0uy; 0x19uy; 0x3buy; 0x2buy; 0xc7uy; 0x9cuy; 0xf7uy; 0xcauy; 0xa7uy; 0x3auy; 0xd3uy; 0xdcuy; 0xecuy; 0xf2uy; 0x49uy; 0x43uy; 0x64uy; 0x7cuy; 0xfduy; 0x35uy; 0xe8uy; 0xfauy; 0xa5uy; 0x98uy; 0x01uy; 0x6buy; 0x4euy; 0xe5uy; 0x84uy; 0x03uy; 0x24uy; 0xb6uy; 0xc7uy; 0x30uy; 0x13uy; 0x44uy; 0xd3uy; 0xe6uy; 0x97uy; 0xefuy; 0xf7uy; 0x13uy; 0xefuy; 0x0euy; 0x9fuy; 0x12uy; 0x75uy; 0x76uy; 0x69uy; 0x7cuy; 0x91uy; 0x15uy; 0x6cuy; 0xc0uy; 0xc2uy; 0x60uy; 0x8cuy; 0x63uy; 0xa7uy; 0xfauy; 0xc2uy; 0xf4uy; 0x17uy; 0xbauy; 0x8buy; 0xd4uy; 0xcfuy; 0x4auy; 0x8duy; 0x63uy; 0xb8uy; 0xa4uy; 0x6buy; 0x9cuy; 0x87uy; 0x94uy; 0x37uy; 0x05uy; 0x9duy; 0xc4uy; 0x76uy; 0x24uy; 0x77uy; 0x79uy; 0x4duy; 0x93uy; 0x62uy; 0x0buy; 0xbcuy; 0x72uy; 0x7euy; 0xb2uy; 0xefuy; 0x3cuy; 0x00uy; 0x1cuy; 0x18uy; 0x18uy; 0xbbuy; 0xe8uy; 0x60uy; 0x6euy; 0xc5uy; 0x9buy; 0x47uy; 0x93uy; 0x77uy; 0xd8uy; 0xf0uy; 0x45uy; 0x16uy; 0x97uy; 0x15uy; 0xc0uy; 0xd3uy; 0x4euy; 0x6duy; 0xe9uy; 0xfeuy; 0x89uy; 0xc3uy; 0x87uy; 0x3auy; 0x49uy; 0xfbuy; 0x9duy; 0x86uy; 0xffuy; 0xcauy; 0xa1uy; 0x3fuy; 0x15uy; 0x37uy; 0xd8uy; 0x98uy; 0xeeuy; 0xd9uy; 0x36uy; 0x06uy; 0x33uy; 0xd8uy; 0xdauy; 0x82uy; 0xeeuy; 0x60uy; 0x8cuy; 0xc7uy; 0xf3uy; 0x19uy; 0x47uy; 0x15uy; 0x7fuy; 0xd3uy; 0xf1uy; 0x30uy; 0xa2uy; 0xc6uy; 0xc4uy; 0x04uy; 0x5cuy; 0x50uy; 0xa3uy; 0x48uy; 0xc8uy; 0x1buy; 0x35uy; 0xfeuy; 0xa5uy; 0xeauy; 0x8auy; 0x4auy; 0x8cuy; 0x9cuy; 0x85uy; 0x8cuy; 0x1fuy; 0xbbuy; 0x3duy; 0xafuy; 0x2euy; 0x3auy; 0xaduy; 0x34uy; 0x6cuy; 0x5duy; 0x87uy; 0xc9uy; 0xc9uy; 0x7fuy; 0x30uy; 0xc1uy; 0x8duy; 0x4cuy; 0xd6uy; 0xbfuy; 0xc0uy; 0xf8uy; 0xa7uy; 0xb2uy; 0x91uy; 0x9buy; 0xe7uy; 0x85uy; 0x96uy; 0xe8uy; 0xb3uy; 0xaeuy; 0x89uy; 0x53uy; 0x41uy; 0x48uy; 0x0euy; 0xd0uy; 0x6auy; 0x4euy; 0x0cuy; 0x7duy; 0x10uy; 0xa1uy; 0xe8uy; 0x9duy; 0x7cuy; 0xdcuy; 0x76uy; 0x91uy; 0x86uy; 0x70uy; 0x67uy; 0xe1uy; 0x76uy; 0x4duy; 0x23uy; 0xeauy; 0x55uy; 0x62uy; 0xb9uy; 0x61uy; 0x7fuy; 0x24uy; 0xd3uy; 0x06uy; 0xd8uy; 0x15uy; 0x88uy; 0x52uy; 0x92uy; 0x8auy; 0xc1uy; 0x8auy; 0x1cuy; 0x7buy; 0x40uy; 0xfauy; 0x03uy; 0xe0uy; 0x93uy; 0xf7uy; 0x2duy; 0xf1uy; 0xdcuy; 0x27uy; 0x10uy; 0xd4uy; 0x28uy; 0x0auy; 0x61uy; 0x87uy; 0xbfuy; 0x09uy; 0xfbuy; 0xb1uy; 0xc7uy; 0xd8uy; 0xe9uy; 0xfauy; 0xa5uy; 0xa8uy; 0x6buy; 0x6duy; 0xa0uy; 0x64uy; 0xb7uy; 0xe4uy; 0x86uy; 0x79uy; 0x6euy; 0x85uy; 0x93uy; 0x94uy; 0xc9uy; 0xdeuy; 0xa9uy; 0x40uy; 0xb3uy; 0x6euy; 0xa0uy; 0xa6uy; 0xc8uy; 0xc9uy; 0x84uy; 0x3euy; 0xdbuy; 0x1duy; 0xa8uy; 0xbcuy; 0x04uy; 0x1cuy; 0xa4uy; 0x4fuy; 0x70uy; 0x77uy; 0xafuy; 0x98uy; 0x71uy; 0xc6uy; 0xbeuy; 0x24uy; 0x58uy; 0xc9uy; 0x53uy; 0x20uy; 0xd2uy; 0xeauy; 0x3duy; 0xe7uy; 0x3fuy; 0x8cuy; 0x44uy; 0xc8uy; 0x3fuy; 0x14uy; 0x50uy; 0xcduy; 0xc8uy; 0x45uy; 0x99uy; 0xf8uy; 0xb6uy; 0xd5uy; 0x99uy; 0x5auy; 0x77uy; 0x61uy; 0x48uy; 0x9fuy; 0x1auy; 0xb0uy; 0x6fuy; 0x1cuy; 0x27uy; 0x35uy; 0x80uy; 0xe6uy; 0x1euy; 0xe2uy; 0x75uy; 0xafuy; 0xf8uy; 0x10uy; 0x6duy; 0x0euy; 0xe6uy; 0x8auy; 0xb5uy; 0xffuy; 0x6cuy; 0x1euy; 0x41uy; 0x60uy; 0x93uy; 0xebuy; 0xffuy; 0x9fuy; 0xffuy; 0xf7uy; 0xcauy; 0x77uy; 0x2fuy; 0xc2uy; 0x44uy; 0xe8uy; 0x86uy; 0x23uy; 0x8auy; 0x2euy; 0xa7uy; 0x1buy; 0xb2uy; 0x8auy; 0x6cuy; 0x79uy; 0x0euy; 0x4duy; 0xe2uy; 0x09uy; 0xa7uy; 0xdauy; 0x60uy; 0x54uy; 0x55uy; 0x36uy; 0xb9uy; 0x06uy; 0x51uy; 0xd9uy; 0x1duy; 0x6cuy; 0xaauy; 0x0buy; 0x03uy; 0xb1uy; 0x38uy; 0x63uy; 0xd7uy; 0x29uy; 0x76uy; 0xf6uy; 0xc5uy; 0x73uy; 0x0auy; 0x0euy; 0x1duy; 0xf7uy; 0xc9uy; 0x5auy; 0xdauy; 0xdcuy; 0x64uy; 0xd5uy; 0x9fuy; 0x51uy; 0xc8uy; 0x8euy; 0x6fuy; 0xf6uy; 0xb9uy; 0x0cuy; 0xd4uy; 0x57uy; 0x5duy; 0x82uy; 0x4euy; 0xeeuy; 0xc6uy; 0x8auy; 0xf5uy; 0x7fuy; 0x59uy; 0xe1uy; 0x0cuy; 0xb8uy; 0xe7uy; 0xf6uy; 0xc6uy; 0x2auy; 0xb1uy; 0x5auy; 0xbauy; 0x77uy; 0xa0uy; 0x30uy; 0x19uy; 0x10uy; 0xe6uy; 0x5auy; 0x90uy; 0x03uy; 0x21uy; 0x3euy; 0xd8uy; 0xc1uy; 0xc5uy; 0xc5uy; 0x81uy; 0xf7uy; 0xc1uy; 0x6auy; 0xfauy; 0xecuy; 0xf6uy; 0x31uy; 0x0duy; 0xf6uy; 0x85uy; 0x9fuy; 0xb5uy; 0x34uy; 0x38uy; 0xf8uy; 0xc1uy; 0xe6uy; 0x7euy; 0x67uy; 0x8buy; 0x14uy; 0x01uy; 0x3buy; 0x32uy; 0xb6uy; 0xb1uy; 0x90uy; 0x91uy; 0xbcuy; 0x40uy; 0x90uy; 0x72uy; 0x55uy; 0x76uy; 0x2buy; 0x34uy; 0x3buy; 0x05uy; 0x65uy; 0x87uy; 0x0euy; 0x4buy; 0xb5uy; 0xcduy; 0x94uy; 0x88uy; 0x60uy; 0xf0uy; 0x7duy; 0xc9uy; 0x21uy; 0x71uy; 0xe2uy; 0x55uy; 0x43uy; 0x06uy; 0x1cuy; 0x84uy; 0x02uy; 0xd0uy; 0x4euy; 0xcbuy; 0x1buy; 0x38uy; 0x6duy; 0x58uy; 0x62uy; 0xabuy; 0x50uy; 0xcfuy; 0xb5uy; 0x47uy; 0x24uy; 0xb8uy; 0x6cuy; 0x00uy; 0xa4uy; 0xf2uy; 0x97uy; 0x9fuy; 0xf3uy; 0x98uy; 0x2euy; 0xf9uy; 0x4fuy; 0x02uy; 0xdcuy; 0x1duy; 0xc6uy; 0x08uy; 0x35uy; 0x57uy; 0xe5uy; 0x9buy; 0xd7uy; 0xf4uy; 0xd7uy; 0x28uy; 0x50uy; 0x39uy; 0xfduy; 0xd8uy; 0xe6uy; 0xbfuy; 0xcauy; 0x61uy; 0x65uy; 0xe3uy; 0xd0uy; 0x95uy; 0x65uy; 0x68uy; 0xb1uy; 0x41uy; 0x65uy; 0x1auy; 0x62uy; 0xceuy; 0x65uy; 0x8fuy; 0xeeuy; 0xe7uy; 0x7auy; 0x3cuy; 0x04uy; 0x95uy; 0x01uy; 0xd1uy; 0x31uy; 0x75uy; 0x80uy; 0x69uy; 0x1euy; 0x4buy; 0xb3uy; 0x4fuy; 0xb9uy; 0x5buy; 0x5cuy; 0x8euy; 0x16uy; 0x01uy; 0x99uy; 0x02uy; 0x55uy; 0x94uy; 0x0buy; 0xa9uy; 0x49uy; 0x7cuy; 0x10uy; 0xd4uy; 0xc9uy; 0xdduy; 0x2buy; 0xabuy; 0x8buy; 0x4cuy; 0x21uy; 0x7auy; 0x7duy; 0x53uy; 0x7buy; 0xd0uy; 0x69uy; 0x45uy; 0xcauy; 0x9auy; 0x91uy; 0x40uy; 0x54uy; 0x03uy; 0xb3uy; 0x56uy; 0x0euy; 0xc6uy; 0x68uy; 0x30uy; 0xdcuy; 0xb1uy; 0xffuy; 0xe4uy; 0x3fuy; 0x0euy; 0x1euy; 0xc0uy; 0x56uy; 0xb2uy; 0xe1uy; 0xfcuy; 0x58uy; 0xf5uy; 0xabuy; 0x39uy; 0x4euy; 0xdduy; 0x33uy; 0xbcuy; 0x12uy; 0xc5uy; 0xdcuy; 0x77uy; 0x46uy; 0x84uy; 0x82uy; 0xb2uy; 0x7fuy; 0xa2uy; 0xf6uy; 0x06uy; 0x24uy; 0xd6uy; 0x3cuy; 0xe3uy; 0xc5uy; 0xc2uy; 0x18uy; 0xc4uy; 0xc9uy; 0xf5uy; 0xa3uy; 0x2auy; 0x56uy; 0x5buy; 0x59uy; 0xe7uy; 0x00uy; 0x92uy; 0xb4uy; 0xd6uy; 0xf9uy; 0x96uy; 0x7cuy; 0x01uy; 0x26uy; 0x1euy; 0x5fuy; 0x27uy; 0x9cuy; 0x1buy; 0xb7uy; 0xf7uy; 0x36uy; 0xebuy; 0x7auy; 0xf3uy; 0xa7uy; 0x5euy; 0x38uy; 0xb2uy; 0x7buy; 0x7fuy; 0xd1uy; 0x4euy; 0x68uy; 0xb9uy; 0xa9uy; 0xf8uy; 0x7auy; 0x06uy; 0xb4uy; 0xe8uy; 0x42uy; 0xd8uy; 0xc7uy; 0x5auy; 0x08uy; 0xd5uy; 0x67uy; 0xa7uy; 0x30uy; 0xb6uy; 0x2euy; 0x80uy; 0xacuy; 0xa9uy; 0x07uy; 0xbbuy; 0x18uy; 0x54uy; 0xc3uy; 0x81uy; 0x6euy; 0x8auy; 0x24uy; 0xc0uy; 0x7fuy; 0xd0uy; 0x54uy; 0xb2uy; 0xe7uy; 0x1auy; 0x11uy; 0xf4uy; 0x9duy; 0x2cuy; 0x75uy; 0x37uy; 0x2euy; 0xc6uy; 0xfcuy; 0x85uy; 0x5duy; 0x46uy; 0x44uy; 0x7auy; 0x36uy; 0xe5uy; 0x62uy; 0xa4uy; 0x26uy; 0xdduy; 0x4cuy; 0x20uy; 0x33uy; 0x7auy; 0x8auy; 0x41uy; 0x8auy; 0x0fuy; 0xa4uy; 0xf8uy; 0x74uy; 0x45uy; 0x98uy; 0xe3uy; 0x73uy; 0xa1uy; 0x4euy; 0x40uy; 0x10uy; 0x5buy; 0x0fuy; 0xa0uy; 0xe4uy; 0x5euy; 0x97uy; 0x40uy; 0xdcuy; 0x68uy; 0x79uy; 0xd7uy; 0xfeuy; 0xfduy; 0x34uy; 0xd0uy; 0xb7uy; 0xcbuy; 0x4auy; 0xf3uy; 0xb0uy; 0xc7uy; 0xf5uy; 0xbauy; 0x6cuy; 0xa9uy; 0xf0uy; 0x82uy; 0x01uy; 0xb2uy; 0x3fuy; 0x9euy; 0x56uy; 0x9cuy; 0x86uy; 0x05uy; 0x03uy; 0x99uy; 0x2euy; 0xe7uy; 0xeduy; 0xdfuy; 0xfeuy; 0x05uy; 0x3buy; 0xdbuy; 0x3cuy; 0x30uy; 0x98uy; 0xa2uy; 0x23uy; 0x86uy; 0xefuy; 0x80uy; 0xe4uy; 0x2fuy; 0xdeuy; 0x8cuy; 0x7duy; 0x2euy; 0x78uy; 0xdbuy; 0xd6uy; 0xcauy; 0x7fuy; 0x79uy; 0x7auy; 0x3buy; 0xafuy; 0x2auy; 0xeduy; 0xf3uy; 0x03uy; 0x15uy; 0xccuy; 0x3duy; 0x52uy; 0x50uy; 0x1duy; 0x08uy; 0x93uy; 0xa2uy; 0xd8uy; 0x63uy; 0x91uy; 0xa0uy; 0x6cuy; 0xccuy ]
false
Spec.Frodo.Test.fst
Spec.Frodo.Test.test_frodo
val test_frodo (a: frodo_alg) (gen_a: frodo_gen_a) (keypaircoins: list uint8 {List.Tot.length keypaircoins == 2 * crypto_bytes a + bytes_seed_a}) (enccoins: list uint8 {List.Tot.length enccoins == bytes_mu a}) (ss_expected: list uint8 {List.Tot.length ss_expected == crypto_bytes a}) (pk_expected: list uint8 {List.Tot.length pk_expected == crypto_publickeybytes a}) (ct_expected: list uint8 {List.Tot.length ct_expected == crypto_ciphertextbytes a}) (sk_expected: list uint8 {List.Tot.length sk_expected == crypto_secretkeybytes a}) : ML bool
val test_frodo (a: frodo_alg) (gen_a: frodo_gen_a) (keypaircoins: list uint8 {List.Tot.length keypaircoins == 2 * crypto_bytes a + bytes_seed_a}) (enccoins: list uint8 {List.Tot.length enccoins == bytes_mu a}) (ss_expected: list uint8 {List.Tot.length ss_expected == crypto_bytes a}) (pk_expected: list uint8 {List.Tot.length pk_expected == crypto_publickeybytes a}) (ct_expected: list uint8 {List.Tot.length ct_expected == crypto_ciphertextbytes a}) (sk_expected: list uint8 {List.Tot.length sk_expected == crypto_secretkeybytes a}) : ML bool
let test_frodo (a:frodo_alg) (gen_a:frodo_gen_a) (keypaircoins: list uint8 {List.Tot.length keypaircoins == 2 * crypto_bytes a + bytes_seed_a}) (enccoins: list uint8 {List.Tot.length enccoins == bytes_mu a}) (ss_expected: list uint8 {List.Tot.length ss_expected == crypto_bytes a}) (pk_expected: list uint8 {List.Tot.length pk_expected == crypto_publickeybytes a}) (ct_expected: list uint8 {List.Tot.length ct_expected == crypto_ciphertextbytes a}) (sk_expected: list uint8 {List.Tot.length sk_expected == crypto_secretkeybytes a}) : ML bool = let keypaircoins = createL keypaircoins in let enccoins = createL enccoins in let ss_expected = createL ss_expected in let pk_expected = createL pk_expected in let ct_expected = createL ct_expected in let sk_expected = createL sk_expected in let pk, sk = crypto_kem_keypair_ a gen_a keypaircoins in let ct, ss1 = crypto_kem_enc_ a gen_a enccoins pk in let ss2 = crypto_kem_dec a gen_a ct sk in let r_pk = compare pk_expected pk in let r_sk = compare sk_expected sk in let r_ct = compare ct_expected ct in let r_ss = PS.print_compare true (crypto_bytes a) ss1 ss2 in let r_ss1 = PS.print_compare true (crypto_bytes a) ss_expected ss2 in r_pk && r_sk && r_ct && r_ss && r_ss1
{ "file_name": "specs/tests/Spec.Frodo.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 39, "end_line": 50, "start_col": 0, "start_line": 26 }
module Spec.Frodo.Test open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Frodo.KEM open Spec.Frodo.KEM.KeyGen open Spec.Frodo.KEM.Encaps open Spec.Frodo.KEM.Decaps open Spec.Frodo.Params open FStar.All module PS = Lib.PrintSequence #set-options "--z3rlimit 50 --fuel 0 --ifuel 1" let compare (#len: size_nat) (test_expected: lbytes len) (test_result: lbytes len) = for_all2 (fun a b -> uint_to_nat #U8 a = uint_to_nat #U8 b) test_expected test_result
{ "checked_file": "/", "dependencies": [ "Spec.Frodo.Params.fst.checked", "Spec.Frodo.KEM.KeyGen.fst.checked", "Spec.Frodo.KEM.Encaps.fst.checked", "Spec.Frodo.KEM.Decaps.fst.checked", "Spec.Frodo.KEM.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.IO.fst.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Test.fst" }
[ { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.Params", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.KEM.Decaps", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.KEM.Encaps", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.KEM.KeyGen", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Frodo.Params.frodo_alg -> gen_a: Spec.Frodo.Params.frodo_gen_a -> keypaircoins: Prims.list Lib.IntTypes.uint8 { FStar.List.Tot.Base.length keypaircoins == 2 * Spec.Frodo.Params.crypto_bytes a + Spec.Frodo.Params.bytes_seed_a } -> enccoins: Prims.list Lib.IntTypes.uint8 {FStar.List.Tot.Base.length enccoins == Spec.Frodo.Params.bytes_mu a} -> ss_expected: Prims.list Lib.IntTypes.uint8 {FStar.List.Tot.Base.length ss_expected == Spec.Frodo.Params.crypto_bytes a} -> pk_expected: Prims.list Lib.IntTypes.uint8 {FStar.List.Tot.Base.length pk_expected == Spec.Frodo.Params.crypto_publickeybytes a} -> ct_expected: Prims.list Lib.IntTypes.uint8 {FStar.List.Tot.Base.length ct_expected == Spec.Frodo.Params.crypto_ciphertextbytes a} -> sk_expected: Prims.list Lib.IntTypes.uint8 {FStar.List.Tot.Base.length sk_expected == Spec.Frodo.Params.crypto_secretkeybytes a} -> FStar.All.ML Prims.bool
FStar.All.ML
[ "ml" ]
[]
[ "Spec.Frodo.Params.frodo_alg", "Spec.Frodo.Params.frodo_gen_a", "Prims.list", "Lib.IntTypes.uint8", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Prims.op_Addition", "FStar.Mul.op_Star", "Spec.Frodo.Params.crypto_bytes", "Spec.Frodo.Params.bytes_seed_a", "Prims.l_or", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.l_and", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "Spec.Frodo.Params.bytes_mu", "Spec.Frodo.Params.crypto_publickeybytes", "Spec.Frodo.Params.crypto_ciphertextbytes", "Spec.Frodo.Params.crypto_secretkeybytes", "Lib.ByteSequence.lbytes", "Prims.op_AmpAmp", "Prims.bool", "Lib.PrintSequence.print_compare", "Spec.Frodo.Test.compare", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.Frodo.KEM.Decaps.crypto_kem_dec", "FStar.Pervasives.Native.tuple2", "Spec.Frodo.KEM.Encaps.crypto_kem_enc_", "Spec.Frodo.KEM.KeyGen.crypto_kem_keypair_", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.seq_of_list", "Lib.Sequence.createL" ]
[]
false
true
false
false
false
let test_frodo (a: frodo_alg) (gen_a: frodo_gen_a) (keypaircoins: list uint8 {List.Tot.length keypaircoins == 2 * crypto_bytes a + bytes_seed_a}) (enccoins: list uint8 {List.Tot.length enccoins == bytes_mu a}) (ss_expected: list uint8 {List.Tot.length ss_expected == crypto_bytes a}) (pk_expected: list uint8 {List.Tot.length pk_expected == crypto_publickeybytes a}) (ct_expected: list uint8 {List.Tot.length ct_expected == crypto_ciphertextbytes a}) (sk_expected: list uint8 {List.Tot.length sk_expected == crypto_secretkeybytes a}) : ML bool =
let keypaircoins = createL keypaircoins in let enccoins = createL enccoins in let ss_expected = createL ss_expected in let pk_expected = createL pk_expected in let ct_expected = createL ct_expected in let sk_expected = createL sk_expected in let pk, sk = crypto_kem_keypair_ a gen_a keypaircoins in let ct, ss1 = crypto_kem_enc_ a gen_a enccoins pk in let ss2 = crypto_kem_dec a gen_a ct sk in let r_pk = compare pk_expected pk in let r_sk = compare sk_expected sk in let r_ct = compare ct_expected ct in let r_ss = PS.print_compare true (crypto_bytes a) ss1 ss2 in let r_ss1 = PS.print_compare true (crypto_bytes a) ss_expected ss2 in r_pk && r_sk && r_ct && r_ss && r_ss1
false
Vale.Stdcalls.X64.GCM_IV.fst
Vale.Stdcalls.X64.GCM_IV.b128
val b128 : Type0
let b128 = buf_t TUInt8 TUInt128
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCM_IV.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 32, "end_line": 36, "start_col": 0, "start_line": 36 }
module Vale.Stdcalls.X64.GCM_IV open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module GC = Vale.AES.X64.GCMencryptOpt open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMencryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCM_IV.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMencryptOpt", "short_module": "GC" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.Base.buf_t", "Vale.Arch.HeapTypes_s.TUInt8", "Vale.Arch.HeapTypes_s.TUInt128" ]
[]
false
false
false
true
true
let b128 =
buf_t TUInt8 TUInt128
false
Spec.Frodo.Test.fst
Spec.Frodo.Test.test1_pk_expected
val test1_pk_expected : Prims.list Lib.IntTypes.uint8
let test1_pk_expected = List.Tot.map u8_from_UInt8 [ 0x0duy; 0xacuy; 0x6fuy; 0x83uy; 0x94uy; 0x00uy; 0x1auy; 0xcauy; 0x97uy; 0xa1uy; 0xaauy; 0x42uy; 0x80uy; 0x9duy; 0x6buy; 0xa5uy; 0xfcuy; 0x64uy; 0x43uy; 0xdbuy; 0xbeuy; 0x6fuy; 0x12uy; 0x2auy; 0x94uy; 0x58uy; 0x36uy; 0xf2uy; 0xb1uy; 0xf8uy; 0xe5uy; 0xf0uy; 0x57uy; 0x4buy; 0x35uy; 0x51uy; 0xdduy; 0x8cuy; 0x36uy; 0x28uy; 0x34uy; 0x46uy; 0xd6uy; 0xafuy; 0x5duy; 0x49uy; 0x0euy; 0x27uy; 0xd8uy; 0xd3uy; 0xaduy; 0xe1uy; 0xeduy; 0x8buy; 0x2duy; 0x13uy; 0xf5uy; 0x5auy; 0xb6uy; 0xdduy; 0xc0uy; 0x54uy; 0x76uy; 0x09uy; 0xa6uy; 0xa4uy; 0x01uy; 0xb9uy; 0xb7uy; 0xd1uy; 0x26uy; 0xd5uy; 0x1euy; 0xa8uy; 0x20uy; 0x4duy; 0xe8uy; 0xefuy; 0xaduy; 0xb9uy; 0xf0uy; 0x65uy; 0xe9uy; 0xc4uy; 0xf4uy; 0x11uy; 0x98uy; 0x99uy; 0xf0uy; 0x2cuy; 0x63uy; 0x7buy; 0x98uy; 0xd7uy; 0x60uy; 0x43uy; 0x5duy; 0x8cuy; 0x85uy; 0xe9uy; 0xc5uy; 0x83uy; 0x83uy; 0x62uy; 0xe2uy; 0x13uy; 0x33uy; 0x54uy; 0x4buy; 0x71uy; 0xaeuy; 0x63uy; 0xbauy; 0x5auy; 0x4euy; 0x32uy; 0x59uy; 0x78uy; 0x6buy; 0x4duy; 0x39uy; 0xcfuy; 0xe1uy; 0x82uy; 0x58uy; 0x0auy; 0xc3uy; 0x61uy; 0x6auy; 0x89uy; 0x2fuy; 0x1buy; 0x70uy; 0xdduy; 0x16uy; 0x3euy; 0x96uy; 0xb1uy; 0x4cuy; 0x71uy; 0xb1uy; 0x79uy; 0x0cuy; 0x3fuy; 0xe2uy; 0xeduy; 0x05uy; 0x07uy; 0x72uy; 0xf3uy; 0x89uy; 0x08uy; 0x8cuy; 0x22uy; 0xa7uy; 0x36uy; 0x40uy; 0xcauy; 0x52uy; 0x70uy; 0x1buy; 0x09uy; 0xcbuy; 0xabuy; 0x3buy; 0x64uy; 0x61uy; 0x6duy; 0x5duy; 0xf7uy; 0x15uy; 0x69uy; 0x71uy; 0x3buy; 0x3auy; 0x2euy; 0x53uy; 0x33uy; 0x26uy; 0xe6uy; 0x29uy; 0x5cuy; 0xfbuy; 0x0duy; 0xc6uy; 0xe4uy; 0xbduy; 0x9cuy; 0x43uy; 0xffuy; 0xa6uy; 0x5buy; 0x49uy; 0x47uy; 0x93uy; 0x1cuy; 0x81uy; 0x6fuy; 0xd4uy; 0xaauy; 0x3duy; 0xaduy; 0x86uy; 0xf5uy; 0x94uy; 0x16uy; 0x7fuy; 0x31uy; 0x91uy; 0x30uy; 0x97uy; 0xc4uy; 0xa3uy; 0xe4uy; 0x01uy; 0x2buy; 0x06uy; 0xcfuy; 0x69uy; 0xfbuy; 0x69uy; 0x35uy; 0xaauy; 0x81uy; 0xeduy; 0x90uy; 0x0cuy; 0x3auy; 0xc0uy; 0xa6uy; 0x06uy; 0xabuy; 0x51uy; 0x3fuy; 0x39uy; 0xb2uy; 0x1euy; 0xb0uy; 0x4buy; 0xbcuy; 0xd0uy; 0xd0uy; 0x3auy; 0xdauy; 0x89uy; 0x88uy; 0xa6uy; 0x56uy; 0xd8uy; 0x02uy; 0x98uy; 0xeeuy; 0xa2uy; 0xf5uy; 0x0euy; 0xbauy; 0x7cuy; 0x52uy; 0xafuy; 0xf4uy; 0xbbuy; 0xe7uy; 0x36uy; 0x4auy; 0xdduy; 0x90uy; 0x93uy; 0xe9uy; 0x5duy; 0xbeuy; 0x68uy; 0x99uy; 0xc2uy; 0xaduy; 0x4duy; 0x79uy; 0x25uy; 0x0buy; 0x69uy; 0x79uy; 0x7buy; 0xe2uy; 0x3duy; 0xa8uy; 0xe7uy; 0xf1uy; 0x42uy; 0x0cuy; 0x22uy; 0x85uy; 0x95uy; 0xf0uy; 0xd5uy; 0x5cuy; 0x96uy; 0x35uy; 0xb6uy; 0x19uy; 0xaeuy; 0xb3uy; 0xcfuy; 0x22uy; 0xcauy; 0xbauy; 0x28uy; 0xd6uy; 0xdduy; 0xd5uy; 0x8euy; 0xe8uy; 0xd6uy; 0x90uy; 0x23uy; 0x8euy; 0x97uy; 0x37uy; 0xe9uy; 0xcduy; 0xabuy; 0xdcuy; 0x08uy; 0x04uy; 0xe1uy; 0x32uy; 0x02uy; 0xffuy; 0x7fuy; 0x82uy; 0x41uy; 0xf3uy; 0x9buy; 0x1duy; 0x42uy; 0x8auy; 0x98uy; 0x80uy; 0x81uy; 0xaauy; 0xbeuy; 0x7duy; 0x3buy; 0x83uy; 0x30uy; 0x4duy; 0x4auy; 0x22uy; 0x2duy; 0xafuy; 0x61uy; 0xd1uy; 0xa0uy; 0x66uy; 0xd4uy; 0x48uy; 0x0fuy; 0xe1uy; 0xd9uy; 0x77uy; 0x82uy; 0xc5uy; 0xa1uy; 0x2auy; 0x03uy; 0x1fuy; 0xd0uy; 0x7auy; 0xccuy; 0x77uy; 0x09uy; 0x4auy; 0xbduy; 0xaduy; 0xf7uy; 0x76uy; 0xdcuy; 0x10uy; 0xeduy; 0x5buy; 0xdfuy; 0x89uy; 0xfbuy; 0x52uy; 0x60uy; 0x5cuy; 0x08uy; 0x42uy; 0x50uy; 0xd1uy; 0xdauy; 0x24uy; 0xbbuy; 0x59uy; 0x3euy; 0x14uy; 0xf4uy; 0xf0uy; 0xf4uy; 0xdauy; 0xb8uy; 0x00uy; 0xe2uy; 0x0buy; 0xfauy; 0xc3uy; 0xf6uy; 0x28uy; 0x8duy; 0x20uy; 0x26uy; 0xe9uy; 0x5buy; 0x25uy; 0xa8uy; 0x80uy; 0x4cuy; 0xeeuy; 0xc9uy; 0xb6uy; 0x7auy; 0x8buy; 0x87uy; 0x21uy; 0xfduy; 0xaeuy; 0xd5uy; 0xa8uy; 0x49uy; 0x33uy; 0x58uy; 0x90uy; 0x2cuy; 0x0auy; 0xcauy; 0xb0uy; 0x9duy; 0xbeuy; 0xcduy; 0xe0uy; 0xa4uy; 0x99uy; 0x76uy; 0x01uy; 0x80uy; 0xdduy; 0x66uy; 0x76uy; 0x70uy; 0x05uy; 0xf3uy; 0xd6uy; 0x31uy; 0xa1uy; 0x9euy; 0xd5uy; 0x5fuy; 0x1buy; 0xdduy; 0x7fuy; 0x81uy; 0x6duy; 0x5cuy; 0xe9uy; 0xa3uy; 0x1auy; 0x6auy; 0x87uy; 0x93uy; 0xaduy; 0x1duy; 0x73uy; 0x44uy; 0xbcuy; 0xe4uy; 0x42uy; 0x78uy; 0x6auy; 0x71uy; 0x58uy; 0x9buy; 0x73uy; 0x55uy; 0x63uy; 0xa5uy; 0x32uy; 0xf6uy; 0x55uy; 0x68uy; 0x05uy; 0xcfuy; 0xeduy; 0x5fuy; 0x86uy; 0xe2uy; 0x65uy; 0xefuy; 0xf1uy; 0xb9uy; 0x69uy; 0xbbuy; 0x79uy; 0xb1uy; 0xf4uy; 0x7fuy; 0xa5uy; 0xfauy; 0x62uy; 0xbcuy; 0x68uy; 0xe7uy; 0xf6uy; 0xf8uy; 0xf0uy; 0x55uy; 0xf4uy; 0x93uy; 0x47uy; 0x06uy; 0xf0uy; 0x3euy; 0x94uy; 0x4auy; 0x95uy; 0xc8uy; 0x0cuy; 0xb0uy; 0x04uy; 0x4euy; 0x3fuy; 0x67uy; 0x14uy; 0xeduy; 0xbbuy; 0xbeuy; 0xf0uy; 0xabuy; 0xdduy; 0x6cuy; 0x23uy; 0x4euy; 0x07uy; 0x66uy; 0x41uy; 0x55uy; 0xbeuy; 0x22uy; 0x59uy; 0xd5uy; 0xdauy; 0xd4uy; 0xd8uy; 0x3duy; 0xb0uy; 0x74uy; 0xc4uy; 0x4fuy; 0x9buy; 0x43uy; 0xe5uy; 0x75uy; 0xfbuy; 0x33uy; 0x0euy; 0xdfuy; 0xe1uy; 0xe3uy; 0x7duy; 0x2euy; 0x80uy; 0x10uy; 0x79uy; 0x17uy; 0xeauy; 0xd3uy; 0x18uy; 0x98uy; 0x08uy; 0xeduy; 0x79uy; 0x4cuy; 0xb9uy; 0x66uy; 0x03uy; 0x04uy; 0x50uy; 0xfeuy; 0x62uy; 0x0duy; 0x48uy; 0x1auy; 0x6cuy; 0xeeuy; 0xb7uy; 0x03uy; 0x15uy; 0x92uy; 0x41uy; 0x1euy; 0xa1uy; 0x88uy; 0x46uy; 0x1auy; 0x43uy; 0x49uy; 0xf5uy; 0x93uy; 0x33uy; 0x00uy; 0x65uy; 0x69uy; 0xa8uy; 0x82uy; 0xbduy; 0xbeuy; 0x5cuy; 0x56uy; 0xa3uy; 0x06uy; 0x00uy; 0x8buy; 0x2fuy; 0x7duy; 0xecuy; 0xa4uy; 0x9auy; 0x2auy; 0xaeuy; 0x66uy; 0x07uy; 0x46uy; 0xb3uy; 0xbeuy; 0xf8uy; 0x07uy; 0x08uy; 0x10uy; 0x87uy; 0xd5uy; 0x6cuy; 0x6auy; 0xa5uy; 0xa6uy; 0x07uy; 0x4buy; 0x00uy; 0xc1uy; 0x5auy; 0xeduy; 0x7fuy; 0x14uy; 0x4buy; 0x60uy; 0x02uy; 0xc2uy; 0x67uy; 0x0cuy; 0xa4uy; 0x64uy; 0x54uy; 0x3euy; 0x22uy; 0xfeuy; 0x21uy; 0xcduy; 0x0duy; 0xcbuy; 0x60uy; 0x3buy; 0x13uy; 0xb0uy; 0x8euy; 0x36uy; 0xcauy; 0xcduy; 0x78uy; 0x8duy; 0x08uy; 0x2auy; 0xf1uy; 0x9cuy; 0x17uy; 0x11uy; 0x14uy; 0x57uy; 0x57uy; 0xe8uy; 0x3buy; 0x84uy; 0xe8uy; 0x59uy; 0xdbuy; 0x5buy; 0x77uy; 0x2euy; 0x54uy; 0x3buy; 0x6euy; 0x9cuy; 0x5euy; 0x7fuy; 0x52uy; 0xe5uy; 0x06uy; 0x8auy; 0x2duy; 0xc3uy; 0xbfuy; 0x30uy; 0x34uy; 0x8cuy; 0xaauy; 0x3buy; 0x23uy; 0x59uy; 0x32uy; 0x5fuy; 0xf7uy; 0xc9uy; 0xb2uy; 0xeeuy; 0xb2uy; 0x72uy; 0x75uy; 0x33uy; 0x8euy; 0xa9uy; 0x68uy; 0x6euy; 0xf5uy; 0x61uy; 0x7auy; 0x20uy; 0x01uy; 0xecuy; 0xabuy; 0x19uy; 0x26uy; 0xbeuy; 0x38uy; 0x49uy; 0xe2uy; 0x16uy; 0xceuy; 0x17uy; 0xafuy; 0xcauy; 0xe3uy; 0x06uy; 0xeauy; 0x37uy; 0x98uy; 0xf2uy; 0x8fuy; 0x04uy; 0x9buy; 0xabuy; 0xd8uy; 0xbduy; 0x78uy; 0x68uy; 0xacuy; 0xefuy; 0xb9uy; 0x28uy; 0x6fuy; 0x0buy; 0x37uy; 0x90uy; 0xb3uy; 0x74uy; 0x0cuy; 0x38uy; 0x12uy; 0x70uy; 0xa2uy; 0xbeuy; 0xdcuy; 0xa7uy; 0x18uy; 0xdfuy; 0x5euy; 0xd2uy; 0x62uy; 0xccuy; 0x43uy; 0x24uy; 0x32uy; 0x58uy; 0x45uy; 0x18uy; 0x0auy; 0xe1uy; 0x0duy; 0x82uy; 0xbcuy; 0x08uy; 0xb1uy; 0xa9uy; 0x7euy; 0x63uy; 0x09uy; 0xc6uy; 0x83uy; 0xa1uy; 0xe6uy; 0x5cuy; 0x9cuy; 0xefuy; 0x57uy; 0xecuy; 0xc7uy; 0x73uy; 0x19uy; 0xfbuy; 0x5cuy; 0x20uy; 0xe1uy; 0xdfuy; 0x85uy; 0x76uy; 0xabuy; 0x89uy; 0xb7uy; 0x96uy; 0x8duy; 0xd9uy; 0x8euy; 0xb7uy; 0x00uy; 0xa8uy; 0xc6uy; 0x98uy; 0x47uy; 0x03uy; 0xafuy; 0x56uy; 0x1fuy; 0x35uy; 0x49uy; 0x75uy; 0x4cuy; 0xa2uy; 0xa2uy; 0xdcuy; 0x98uy; 0xbfuy; 0x87uy; 0xeduy; 0x73uy; 0x5fuy; 0x9buy; 0xabuy; 0x3euy; 0x02uy; 0xdcuy; 0xa1uy; 0x4buy; 0x6cuy; 0xacuy; 0x10uy; 0xb2uy; 0x0buy; 0x99uy; 0xeeuy; 0xc8uy; 0xc2uy; 0x82uy; 0xa9uy; 0xf9uy; 0xa9uy; 0xa5uy; 0x4duy; 0xc9uy; 0x39uy; 0x41uy; 0x89uy; 0x0cuy; 0xc6uy; 0xe3uy; 0xaauy; 0x76uy; 0xe7uy; 0x11uy; 0x16uy; 0x8auy; 0x28uy; 0x6buy; 0x22uy; 0x3auy; 0x1euy; 0x7duy; 0xe6uy; 0xf7uy; 0x55uy; 0x85uy; 0x8cuy; 0x36uy; 0x57uy; 0x0buy; 0xdbuy; 0xe6uy; 0xefuy; 0xd9uy; 0xf6uy; 0x94uy; 0x48uy; 0x31uy; 0x7euy; 0xaauy; 0x13uy; 0xd4uy; 0x58uy; 0x9buy; 0xebuy; 0x7cuy; 0x2auy; 0x39uy; 0xdduy; 0xa3uy; 0x3fuy; 0x70uy; 0xfduy; 0x7fuy; 0x30uy; 0xa3uy; 0x34uy; 0xe6uy; 0xacuy; 0x64uy; 0x9buy; 0xf8uy; 0xbbuy; 0x1euy; 0x51uy; 0xe1uy; 0xaduy; 0x61uy; 0xf6uy; 0xffuy; 0xd4uy; 0x4auy; 0x5euy; 0x12uy; 0x40uy; 0xdcuy; 0x07uy; 0x8buy; 0xb2uy; 0xe0uy; 0xb9uy; 0x29uy; 0xaauy; 0x4euy; 0x85uy; 0xf5uy; 0xbduy; 0x5buy; 0x43uy; 0x77uy; 0xc7uy; 0x0buy; 0xfeuy; 0x66uy; 0x49uy; 0xccuy; 0xb5uy; 0x92uy; 0x4auy; 0x14uy; 0x1euy; 0xe2uy; 0xe5uy; 0x20uy; 0xfauy; 0xecuy; 0x0fuy; 0xc9uy ]
{ "file_name": "specs/tests/Spec.Frodo.Test.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 163, "start_col": 0, "start_line": 78 }
module Spec.Frodo.Test open FStar.Mul open Lib.IntTypes open Lib.RawIntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Frodo.KEM open Spec.Frodo.KEM.KeyGen open Spec.Frodo.KEM.Encaps open Spec.Frodo.KEM.Decaps open Spec.Frodo.Params open FStar.All module PS = Lib.PrintSequence #set-options "--z3rlimit 50 --fuel 0 --ifuel 1" let compare (#len: size_nat) (test_expected: lbytes len) (test_result: lbytes len) = for_all2 (fun a b -> uint_to_nat #U8 a = uint_to_nat #U8 b) test_expected test_result let test_frodo (a:frodo_alg) (gen_a:frodo_gen_a) (keypaircoins: list uint8 {List.Tot.length keypaircoins == 2 * crypto_bytes a + bytes_seed_a}) (enccoins: list uint8 {List.Tot.length enccoins == bytes_mu a}) (ss_expected: list uint8 {List.Tot.length ss_expected == crypto_bytes a}) (pk_expected: list uint8 {List.Tot.length pk_expected == crypto_publickeybytes a}) (ct_expected: list uint8 {List.Tot.length ct_expected == crypto_ciphertextbytes a}) (sk_expected: list uint8 {List.Tot.length sk_expected == crypto_secretkeybytes a}) : ML bool = let keypaircoins = createL keypaircoins in let enccoins = createL enccoins in let ss_expected = createL ss_expected in let pk_expected = createL pk_expected in let ct_expected = createL ct_expected in let sk_expected = createL sk_expected in let pk, sk = crypto_kem_keypair_ a gen_a keypaircoins in let ct, ss1 = crypto_kem_enc_ a gen_a enccoins pk in let ss2 = crypto_kem_dec a gen_a ct sk in let r_pk = compare pk_expected pk in let r_sk = compare sk_expected sk in let r_ct = compare ct_expected ct in let r_ss = PS.print_compare true (crypto_bytes a) ss1 ss2 in let r_ss1 = PS.print_compare true (crypto_bytes a) ss_expected ss2 in r_pk && r_sk && r_ct && r_ss && r_ss1 // // Test1. FrodoKEM-64. SHAKE128 // let test1_keypaircoins = List.Tot.map u8_from_UInt8 [ 0xa6uy; 0x65uy; 0x65uy; 0x9fuy; 0xfbuy; 0xe4uy; 0x06uy; 0x5cuy; 0xcauy; 0x81uy; 0x5auy; 0x45uy; 0xe4uy; 0x94uy; 0xd8uy; 0x01uy; 0x90uy; 0x30uy; 0x33uy; 0x55uy; 0x33uy; 0x84uy; 0x2euy; 0xe4uy; 0x4cuy; 0x55uy; 0x8fuy; 0xd8uy; 0xaeuy; 0x4buy; 0x4euy; 0x91uy; 0x62uy; 0xfeuy; 0xc7uy; 0x9auy; 0xc5uy; 0xcduy; 0x1fuy; 0xe2uy; 0xd2uy; 0x00uy; 0x63uy; 0x39uy; 0xaauy; 0xb1uy; 0xf3uy; 0x17uy ] let test1_enccoins = List.Tot.map u8_from_UInt8 [ 0x8duy; 0xf3uy; 0xfauy; 0xe3uy; 0x83uy; 0x27uy; 0xc5uy; 0x3cuy; 0xc1uy; 0xc4uy; 0x8cuy; 0x60uy; 0xb2uy; 0x52uy; 0x2buy; 0xb5uy ] let test1_ss_expected = List.Tot.map u8_from_UInt8 [ 0xf8uy; 0x96uy; 0x15uy; 0x94uy; 0x80uy; 0x9fuy; 0xebuy; 0x77uy; 0x56uy; 0xbeuy; 0x37uy; 0x69uy; 0xa0uy; 0xeauy; 0x60uy; 0x16uy ]
{ "checked_file": "/", "dependencies": [ "Spec.Frodo.Params.fst.checked", "Spec.Frodo.KEM.KeyGen.fst.checked", "Spec.Frodo.KEM.Encaps.fst.checked", "Spec.Frodo.KEM.Decaps.fst.checked", "Spec.Frodo.KEM.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.PrintSequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.IO.fst.checked", "FStar.All.fst.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Test.fst" }
[ { "abbrev": true, "full_module": "Lib.PrintSequence", "short_module": "PS" }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.Params", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.KEM.Decaps", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.KEM.Encaps", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.KEM.KeyGen", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.RawIntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.list Lib.IntTypes.uint8
Prims.Tot
[ "total" ]
[]
[ "FStar.List.Tot.Base.map", "FStar.UInt8.t", "Lib.IntTypes.uint8", "Lib.RawIntTypes.u8_from_UInt8", "Prims.Cons", "FStar.UInt8.__uint_to_t", "Prims.Nil" ]
[]
false
false
false
true
false
let test1_pk_expected =
List.Tot.map u8_from_UInt8 [ 0x0duy; 0xacuy; 0x6fuy; 0x83uy; 0x94uy; 0x00uy; 0x1auy; 0xcauy; 0x97uy; 0xa1uy; 0xaauy; 0x42uy; 0x80uy; 0x9duy; 0x6buy; 0xa5uy; 0xfcuy; 0x64uy; 0x43uy; 0xdbuy; 0xbeuy; 0x6fuy; 0x12uy; 0x2auy; 0x94uy; 0x58uy; 0x36uy; 0xf2uy; 0xb1uy; 0xf8uy; 0xe5uy; 0xf0uy; 0x57uy; 0x4buy; 0x35uy; 0x51uy; 0xdduy; 0x8cuy; 0x36uy; 0x28uy; 0x34uy; 0x46uy; 0xd6uy; 0xafuy; 0x5duy; 0x49uy; 0x0euy; 0x27uy; 0xd8uy; 0xd3uy; 0xaduy; 0xe1uy; 0xeduy; 0x8buy; 0x2duy; 0x13uy; 0xf5uy; 0x5auy; 0xb6uy; 0xdduy; 0xc0uy; 0x54uy; 0x76uy; 0x09uy; 0xa6uy; 0xa4uy; 0x01uy; 0xb9uy; 0xb7uy; 0xd1uy; 0x26uy; 0xd5uy; 0x1euy; 0xa8uy; 0x20uy; 0x4duy; 0xe8uy; 0xefuy; 0xaduy; 0xb9uy; 0xf0uy; 0x65uy; 0xe9uy; 0xc4uy; 0xf4uy; 0x11uy; 0x98uy; 0x99uy; 0xf0uy; 0x2cuy; 0x63uy; 0x7buy; 0x98uy; 0xd7uy; 0x60uy; 0x43uy; 0x5duy; 0x8cuy; 0x85uy; 0xe9uy; 0xc5uy; 0x83uy; 0x83uy; 0x62uy; 0xe2uy; 0x13uy; 0x33uy; 0x54uy; 0x4buy; 0x71uy; 0xaeuy; 0x63uy; 0xbauy; 0x5auy; 0x4euy; 0x32uy; 0x59uy; 0x78uy; 0x6buy; 0x4duy; 0x39uy; 0xcfuy; 0xe1uy; 0x82uy; 0x58uy; 0x0auy; 0xc3uy; 0x61uy; 0x6auy; 0x89uy; 0x2fuy; 0x1buy; 0x70uy; 0xdduy; 0x16uy; 0x3euy; 0x96uy; 0xb1uy; 0x4cuy; 0x71uy; 0xb1uy; 0x79uy; 0x0cuy; 0x3fuy; 0xe2uy; 0xeduy; 0x05uy; 0x07uy; 0x72uy; 0xf3uy; 0x89uy; 0x08uy; 0x8cuy; 0x22uy; 0xa7uy; 0x36uy; 0x40uy; 0xcauy; 0x52uy; 0x70uy; 0x1buy; 0x09uy; 0xcbuy; 0xabuy; 0x3buy; 0x64uy; 0x61uy; 0x6duy; 0x5duy; 0xf7uy; 0x15uy; 0x69uy; 0x71uy; 0x3buy; 0x3auy; 0x2euy; 0x53uy; 0x33uy; 0x26uy; 0xe6uy; 0x29uy; 0x5cuy; 0xfbuy; 0x0duy; 0xc6uy; 0xe4uy; 0xbduy; 0x9cuy; 0x43uy; 0xffuy; 0xa6uy; 0x5buy; 0x49uy; 0x47uy; 0x93uy; 0x1cuy; 0x81uy; 0x6fuy; 0xd4uy; 0xaauy; 0x3duy; 0xaduy; 0x86uy; 0xf5uy; 0x94uy; 0x16uy; 0x7fuy; 0x31uy; 0x91uy; 0x30uy; 0x97uy; 0xc4uy; 0xa3uy; 0xe4uy; 0x01uy; 0x2buy; 0x06uy; 0xcfuy; 0x69uy; 0xfbuy; 0x69uy; 0x35uy; 0xaauy; 0x81uy; 0xeduy; 0x90uy; 0x0cuy; 0x3auy; 0xc0uy; 0xa6uy; 0x06uy; 0xabuy; 0x51uy; 0x3fuy; 0x39uy; 0xb2uy; 0x1euy; 0xb0uy; 0x4buy; 0xbcuy; 0xd0uy; 0xd0uy; 0x3auy; 0xdauy; 0x89uy; 0x88uy; 0xa6uy; 0x56uy; 0xd8uy; 0x02uy; 0x98uy; 0xeeuy; 0xa2uy; 0xf5uy; 0x0euy; 0xbauy; 0x7cuy; 0x52uy; 0xafuy; 0xf4uy; 0xbbuy; 0xe7uy; 0x36uy; 0x4auy; 0xdduy; 0x90uy; 0x93uy; 0xe9uy; 0x5duy; 0xbeuy; 0x68uy; 0x99uy; 0xc2uy; 0xaduy; 0x4duy; 0x79uy; 0x25uy; 0x0buy; 0x69uy; 0x79uy; 0x7buy; 0xe2uy; 0x3duy; 0xa8uy; 0xe7uy; 0xf1uy; 0x42uy; 0x0cuy; 0x22uy; 0x85uy; 0x95uy; 0xf0uy; 0xd5uy; 0x5cuy; 0x96uy; 0x35uy; 0xb6uy; 0x19uy; 0xaeuy; 0xb3uy; 0xcfuy; 0x22uy; 0xcauy; 0xbauy; 0x28uy; 0xd6uy; 0xdduy; 0xd5uy; 0x8euy; 0xe8uy; 0xd6uy; 0x90uy; 0x23uy; 0x8euy; 0x97uy; 0x37uy; 0xe9uy; 0xcduy; 0xabuy; 0xdcuy; 0x08uy; 0x04uy; 0xe1uy; 0x32uy; 0x02uy; 0xffuy; 0x7fuy; 0x82uy; 0x41uy; 0xf3uy; 0x9buy; 0x1duy; 0x42uy; 0x8auy; 0x98uy; 0x80uy; 0x81uy; 0xaauy; 0xbeuy; 0x7duy; 0x3buy; 0x83uy; 0x30uy; 0x4duy; 0x4auy; 0x22uy; 0x2duy; 0xafuy; 0x61uy; 0xd1uy; 0xa0uy; 0x66uy; 0xd4uy; 0x48uy; 0x0fuy; 0xe1uy; 0xd9uy; 0x77uy; 0x82uy; 0xc5uy; 0xa1uy; 0x2auy; 0x03uy; 0x1fuy; 0xd0uy; 0x7auy; 0xccuy; 0x77uy; 0x09uy; 0x4auy; 0xbduy; 0xaduy; 0xf7uy; 0x76uy; 0xdcuy; 0x10uy; 0xeduy; 0x5buy; 0xdfuy; 0x89uy; 0xfbuy; 0x52uy; 0x60uy; 0x5cuy; 0x08uy; 0x42uy; 0x50uy; 0xd1uy; 0xdauy; 0x24uy; 0xbbuy; 0x59uy; 0x3euy; 0x14uy; 0xf4uy; 0xf0uy; 0xf4uy; 0xdauy; 0xb8uy; 0x00uy; 0xe2uy; 0x0buy; 0xfauy; 0xc3uy; 0xf6uy; 0x28uy; 0x8duy; 0x20uy; 0x26uy; 0xe9uy; 0x5buy; 0x25uy; 0xa8uy; 0x80uy; 0x4cuy; 0xeeuy; 0xc9uy; 0xb6uy; 0x7auy; 0x8buy; 0x87uy; 0x21uy; 0xfduy; 0xaeuy; 0xd5uy; 0xa8uy; 0x49uy; 0x33uy; 0x58uy; 0x90uy; 0x2cuy; 0x0auy; 0xcauy; 0xb0uy; 0x9duy; 0xbeuy; 0xcduy; 0xe0uy; 0xa4uy; 0x99uy; 0x76uy; 0x01uy; 0x80uy; 0xdduy; 0x66uy; 0x76uy; 0x70uy; 0x05uy; 0xf3uy; 0xd6uy; 0x31uy; 0xa1uy; 0x9euy; 0xd5uy; 0x5fuy; 0x1buy; 0xdduy; 0x7fuy; 0x81uy; 0x6duy; 0x5cuy; 0xe9uy; 0xa3uy; 0x1auy; 0x6auy; 0x87uy; 0x93uy; 0xaduy; 0x1duy; 0x73uy; 0x44uy; 0xbcuy; 0xe4uy; 0x42uy; 0x78uy; 0x6auy; 0x71uy; 0x58uy; 0x9buy; 0x73uy; 0x55uy; 0x63uy; 0xa5uy; 0x32uy; 0xf6uy; 0x55uy; 0x68uy; 0x05uy; 0xcfuy; 0xeduy; 0x5fuy; 0x86uy; 0xe2uy; 0x65uy; 0xefuy; 0xf1uy; 0xb9uy; 0x69uy; 0xbbuy; 0x79uy; 0xb1uy; 0xf4uy; 0x7fuy; 0xa5uy; 0xfauy; 0x62uy; 0xbcuy; 0x68uy; 0xe7uy; 0xf6uy; 0xf8uy; 0xf0uy; 0x55uy; 0xf4uy; 0x93uy; 0x47uy; 0x06uy; 0xf0uy; 0x3euy; 0x94uy; 0x4auy; 0x95uy; 0xc8uy; 0x0cuy; 0xb0uy; 0x04uy; 0x4euy; 0x3fuy; 0x67uy; 0x14uy; 0xeduy; 0xbbuy; 0xbeuy; 0xf0uy; 0xabuy; 0xdduy; 0x6cuy; 0x23uy; 0x4euy; 0x07uy; 0x66uy; 0x41uy; 0x55uy; 0xbeuy; 0x22uy; 0x59uy; 0xd5uy; 0xdauy; 0xd4uy; 0xd8uy; 0x3duy; 0xb0uy; 0x74uy; 0xc4uy; 0x4fuy; 0x9buy; 0x43uy; 0xe5uy; 0x75uy; 0xfbuy; 0x33uy; 0x0euy; 0xdfuy; 0xe1uy; 0xe3uy; 0x7duy; 0x2euy; 0x80uy; 0x10uy; 0x79uy; 0x17uy; 0xeauy; 0xd3uy; 0x18uy; 0x98uy; 0x08uy; 0xeduy; 0x79uy; 0x4cuy; 0xb9uy; 0x66uy; 0x03uy; 0x04uy; 0x50uy; 0xfeuy; 0x62uy; 0x0duy; 0x48uy; 0x1auy; 0x6cuy; 0xeeuy; 0xb7uy; 0x03uy; 0x15uy; 0x92uy; 0x41uy; 0x1euy; 0xa1uy; 0x88uy; 0x46uy; 0x1auy; 0x43uy; 0x49uy; 0xf5uy; 0x93uy; 0x33uy; 0x00uy; 0x65uy; 0x69uy; 0xa8uy; 0x82uy; 0xbduy; 0xbeuy; 0x5cuy; 0x56uy; 0xa3uy; 0x06uy; 0x00uy; 0x8buy; 0x2fuy; 0x7duy; 0xecuy; 0xa4uy; 0x9auy; 0x2auy; 0xaeuy; 0x66uy; 0x07uy; 0x46uy; 0xb3uy; 0xbeuy; 0xf8uy; 0x07uy; 0x08uy; 0x10uy; 0x87uy; 0xd5uy; 0x6cuy; 0x6auy; 0xa5uy; 0xa6uy; 0x07uy; 0x4buy; 0x00uy; 0xc1uy; 0x5auy; 0xeduy; 0x7fuy; 0x14uy; 0x4buy; 0x60uy; 0x02uy; 0xc2uy; 0x67uy; 0x0cuy; 0xa4uy; 0x64uy; 0x54uy; 0x3euy; 0x22uy; 0xfeuy; 0x21uy; 0xcduy; 0x0duy; 0xcbuy; 0x60uy; 0x3buy; 0x13uy; 0xb0uy; 0x8euy; 0x36uy; 0xcauy; 0xcduy; 0x78uy; 0x8duy; 0x08uy; 0x2auy; 0xf1uy; 0x9cuy; 0x17uy; 0x11uy; 0x14uy; 0x57uy; 0x57uy; 0xe8uy; 0x3buy; 0x84uy; 0xe8uy; 0x59uy; 0xdbuy; 0x5buy; 0x77uy; 0x2euy; 0x54uy; 0x3buy; 0x6euy; 0x9cuy; 0x5euy; 0x7fuy; 0x52uy; 0xe5uy; 0x06uy; 0x8auy; 0x2duy; 0xc3uy; 0xbfuy; 0x30uy; 0x34uy; 0x8cuy; 0xaauy; 0x3buy; 0x23uy; 0x59uy; 0x32uy; 0x5fuy; 0xf7uy; 0xc9uy; 0xb2uy; 0xeeuy; 0xb2uy; 0x72uy; 0x75uy; 0x33uy; 0x8euy; 0xa9uy; 0x68uy; 0x6euy; 0xf5uy; 0x61uy; 0x7auy; 0x20uy; 0x01uy; 0xecuy; 0xabuy; 0x19uy; 0x26uy; 0xbeuy; 0x38uy; 0x49uy; 0xe2uy; 0x16uy; 0xceuy; 0x17uy; 0xafuy; 0xcauy; 0xe3uy; 0x06uy; 0xeauy; 0x37uy; 0x98uy; 0xf2uy; 0x8fuy; 0x04uy; 0x9buy; 0xabuy; 0xd8uy; 0xbduy; 0x78uy; 0x68uy; 0xacuy; 0xefuy; 0xb9uy; 0x28uy; 0x6fuy; 0x0buy; 0x37uy; 0x90uy; 0xb3uy; 0x74uy; 0x0cuy; 0x38uy; 0x12uy; 0x70uy; 0xa2uy; 0xbeuy; 0xdcuy; 0xa7uy; 0x18uy; 0xdfuy; 0x5euy; 0xd2uy; 0x62uy; 0xccuy; 0x43uy; 0x24uy; 0x32uy; 0x58uy; 0x45uy; 0x18uy; 0x0auy; 0xe1uy; 0x0duy; 0x82uy; 0xbcuy; 0x08uy; 0xb1uy; 0xa9uy; 0x7euy; 0x63uy; 0x09uy; 0xc6uy; 0x83uy; 0xa1uy; 0xe6uy; 0x5cuy; 0x9cuy; 0xefuy; 0x57uy; 0xecuy; 0xc7uy; 0x73uy; 0x19uy; 0xfbuy; 0x5cuy; 0x20uy; 0xe1uy; 0xdfuy; 0x85uy; 0x76uy; 0xabuy; 0x89uy; 0xb7uy; 0x96uy; 0x8duy; 0xd9uy; 0x8euy; 0xb7uy; 0x00uy; 0xa8uy; 0xc6uy; 0x98uy; 0x47uy; 0x03uy; 0xafuy; 0x56uy; 0x1fuy; 0x35uy; 0x49uy; 0x75uy; 0x4cuy; 0xa2uy; 0xa2uy; 0xdcuy; 0x98uy; 0xbfuy; 0x87uy; 0xeduy; 0x73uy; 0x5fuy; 0x9buy; 0xabuy; 0x3euy; 0x02uy; 0xdcuy; 0xa1uy; 0x4buy; 0x6cuy; 0xacuy; 0x10uy; 0xb2uy; 0x0buy; 0x99uy; 0xeeuy; 0xc8uy; 0xc2uy; 0x82uy; 0xa9uy; 0xf9uy; 0xa9uy; 0xa5uy; 0x4duy; 0xc9uy; 0x39uy; 0x41uy; 0x89uy; 0x0cuy; 0xc6uy; 0xe3uy; 0xaauy; 0x76uy; 0xe7uy; 0x11uy; 0x16uy; 0x8auy; 0x28uy; 0x6buy; 0x22uy; 0x3auy; 0x1euy; 0x7duy; 0xe6uy; 0xf7uy; 0x55uy; 0x85uy; 0x8cuy; 0x36uy; 0x57uy; 0x0buy; 0xdbuy; 0xe6uy; 0xefuy; 0xd9uy; 0xf6uy; 0x94uy; 0x48uy; 0x31uy; 0x7euy; 0xaauy; 0x13uy; 0xd4uy; 0x58uy; 0x9buy; 0xebuy; 0x7cuy; 0x2auy; 0x39uy; 0xdduy; 0xa3uy; 0x3fuy; 0x70uy; 0xfduy; 0x7fuy; 0x30uy; 0xa3uy; 0x34uy; 0xe6uy; 0xacuy; 0x64uy; 0x9buy; 0xf8uy; 0xbbuy; 0x1euy; 0x51uy; 0xe1uy; 0xaduy; 0x61uy; 0xf6uy; 0xffuy; 0xd4uy; 0x4auy; 0x5euy; 0x12uy; 0x40uy; 0xdcuy; 0x07uy; 0x8buy; 0xb2uy; 0xe0uy; 0xb9uy; 0x29uy; 0xaauy; 0x4euy; 0x85uy; 0xf5uy; 0xbduy; 0x5buy; 0x43uy; 0x77uy; 0xc7uy; 0x0buy; 0xfeuy; 0x66uy; 0x49uy; 0xccuy; 0xb5uy; 0x92uy; 0x4auy; 0x14uy; 0x1euy; 0xe2uy; 0xe5uy; 0x20uy; 0xfauy; 0xecuy; 0x0fuy; 0xc9uy ]
false
Vale.Stdcalls.X64.GCM_IV.fst
Vale.Stdcalls.X64.GCM_IV.code_compute_iv
val code_compute_iv : Vale.X64.Decls.va_code
let code_compute_iv = GC.va_code_Compute_iv_stdcall IA.win
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCM_IV.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 58, "end_line": 127, "start_col": 0, "start_line": 127 }
module Vale.Stdcalls.X64.GCM_IV open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module GC = Vale.AES.X64.GCMencryptOpt open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b128 = buf_t TUInt8 TUInt128 [@__reduce__] noextract let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq [@__reduce__] noextract let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let (dom: list td{List.length dom <= 20}) = let y = [t128_no_mod; tuint64; tuint64; t128_mod; t128_no_mod; t128_no_mod] in assert_norm (List.length y = 6); y [@__reduce__] noextract let compute_iv_pre : (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom = fun (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (iv_b:b128) (num_bytes:uint64) (len:uint64) (j0_b:b128) (iv_extra_b:b128) (hkeys_b:b128) (va_s0:V.va_state) -> GC.va_req_Compute_iv_stdcall c va_s0 IA.win (Ghost.reveal iv) (as_vale_buffer iv_b) (UInt64.v num_bytes) (UInt64.v len) (as_vale_buffer j0_b) (as_vale_buffer iv_extra_b) (as_vale_buffer hkeys_b) [@__reduce__] noextract let compute_iv_post : (Ghost.erased supported_iv_LE) -> VSig.vale_post dom = fun (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (iv_b:b128) (num_bytes:uint64) (len:uint64) (j0_b:b128) (iv_extra_b:b128) (hkeys_b:b128) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> GC.va_ens_Compute_iv_stdcall c va_s0 IA.win (Ghost.reveal iv) (as_vale_buffer iv_b) (UInt64.v num_bytes) (UInt64.v len) (as_vale_buffer j0_b) (as_vale_buffer iv_extra_b) (as_vale_buffer hkeys_b) va_s1 f #set-options "--z3rlimit 50" [@__reduce__] noextract let compute_iv_lemma' (iv:Ghost.erased supported_iv_LE) (code:V.va_code) (_win:bool) (iv_b:b128) (num_bytes:uint64) (len:uint64) (j0_b:b128) (iv_extra_b:b128) (hkeys_b:b128) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires compute_iv_pre iv code iv_b num_bytes len j0_b iv_extra_b hkeys_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ compute_iv_post iv code iv_b num_bytes len j0_b iv_extra_b hkeys_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer iv_extra_b) /\ ME.buffer_writeable (as_vale_buffer j0_b)) ) = let va_s1, f = GC.va_lemma_Compute_iv_stdcall code va_s0 IA.win (Ghost.reveal iv) (as_vale_buffer iv_b) (UInt64.v num_bytes) (UInt64.v len) (as_vale_buffer j0_b) (as_vale_buffer iv_extra_b) (as_vale_buffer hkeys_b) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_extra_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 j0_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b; va_s1, f (* Prove that compute1_iv_lemma' has the required type *) noextract let compute_iv_lemma (iv:Ghost.erased supported_iv_LE) = as_t #(VSig.vale_sig_stdcall (compute_iv_pre iv) (compute_iv_post iv)) (compute_iv_lemma' iv)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMencryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCM_IV.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMencryptOpt", "short_module": "GC" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.X64.Decls.va_code
Prims.Tot
[ "total" ]
[]
[ "Vale.AES.X64.GCMencryptOpt.va_code_Compute_iv_stdcall", "Vale.Interop.Assumptions.win" ]
[]
false
false
false
true
false
let code_compute_iv =
GC.va_code_Compute_iv_stdcall IA.win
false
RecordOfArrays.fst
RecordOfArrays.rec_array_repr_with_v2
val rec_array_repr_with_v2 : r: RecordOfArrays.rec_array_repr -> v2: FStar.Seq.Base.seq FStar.UInt8.t -> RecordOfArrays.rec_array_repr
let rec_array_repr_with_v2 (r:rec_array_repr) v2 = {r with v2}
{ "file_name": "share/steel/examples/pulse/bug-reports/RecordOfArrays.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 62, "end_line": 86, "start_col": 0, "start_line": 86 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module RecordOfArrays open Pulse.Lib.Pervasives module R = Pulse.Lib.Reference module A = Pulse.Lib.Array module U8 = FStar.UInt8 module US = FStar.SizeT // Similar to Records, but with arrays noeq type rec_array = { r1: A.array U8.t; r2: A.array U8.t; } type rec_array_repr = { v1: Seq.seq U8.t; v2: Seq.seq U8.t; } let rec_array_perm (r:rec_array) (v:rec_array_repr) : vprop = A.pts_to r.r1 v.v1 ** A.pts_to r.r2 v.v2 //Using record syntax directly in Pulse vprops //leads to strange type inference errors let mk_rec_array_repr (v1 v2:Seq.seq U8.t) = { v1=v1; v2=v2 } ```pulse ghost fn fold_rec_array_perm (r:rec_array) (#v1 #v2:erased (Seq.seq U8.t)) requires A.pts_to r.r1 v1 ** A.pts_to r.r2 v2 ensures rec_array_perm r (mk_rec_array_repr v1 v2) { fold (rec_array_perm r (mk_rec_array_repr v1 v2)) } ``` // Then, mutating a one of the arrays of the record involves: ```pulse fn mutate_r2 (r:rec_array) (#v:(v:Ghost.erased rec_array_repr { Seq.length v.v2 > 0 })) requires rec_array_perm r v ensures exists* (v_:rec_array_repr) . rec_array_perm r v_ ** pure (v_.v2 `Seq.equal` Seq.upd v.v2 0 0uy /\ v_.v1 == v.v1) { unfold (rec_array_perm r v); //1. unfolding the predicate ((r.r2).(0sz) <- 0uy); //2. working with the fields fold_rec_array_perm r; //3. folding it back up () } ``` // Some alternate more explicit ways ```pulse fn get_witness_array (x:A.array U8.t) (#y:Ghost.erased (Seq.seq U8.t)) requires A.pts_to x y returns z:Ghost.erased (Seq.seq U8.t) ensures A.pts_to x y ** pure (y==z) { y } ```
{ "checked_file": "/", "dependencies": [ "Pulse.Lib.Reference.fsti.checked", "Pulse.Lib.Pervasives.fst.checked", "Pulse.Lib.Array.fsti.checked", "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "RecordOfArrays.fst" }
[ { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "Pulse.Lib.Array", "short_module": "A" }, { "abbrev": true, "full_module": "Pulse.Lib.Reference", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Lib.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: RecordOfArrays.rec_array_repr -> v2: FStar.Seq.Base.seq FStar.UInt8.t -> RecordOfArrays.rec_array_repr
Prims.Tot
[ "total" ]
[]
[ "RecordOfArrays.rec_array_repr", "FStar.Seq.Base.seq", "FStar.UInt8.t", "RecordOfArrays.Mkrec_array_repr", "RecordOfArrays.__proj__Mkrec_array_repr__item__v1" ]
[]
false
false
false
true
false
let rec_array_repr_with_v2 (r: rec_array_repr) v2 =
{ r with v2 = v2 }
false
Steel.ST.GenArraySwap.fst
Steel.ST.GenArraySwap.gcd_inv0
val gcd_inv0 (n0 l0: SZ.t) (pn pl: R.ref SZ.t) (b: bool) : Tot vprop
val gcd_inv0 (n0 l0: SZ.t) (pn pl: R.ref SZ.t) (b: bool) : Tot vprop
let gcd_inv0 (n0: SZ.t) (l0: SZ.t) (pn: R.ref SZ.t) (pl: R.ref SZ.t) (b: bool) : Tot vprop = exists_ (fun n -> exists_ (fun l -> R.pts_to pn full_perm n `star` R.pts_to pl full_perm l `star` pure (gcd_inv_prop (SZ.v n0) (SZ.v l0) (SZ.v n) (SZ.v l) b) ))
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 4, "end_line": 31, "start_col": 0, "start_line": 20 }
module Steel.ST.GenArraySwap open Steel.ST.GenElim module Prf = Steel.ST.GenArraySwap.Proof module R = Steel.ST.Reference let gcd_inv_prop (n0: nat) (l0: nat) (n: nat) (l: nat) (b: bool) : Tot prop = l0 < n0 /\ l < n /\ (Prf.mk_bezout n0 l0).d == (Prf.mk_bezout n l).d /\ b == (l > 0)
{ "checked_file": "/", "dependencies": [ "Steel.ST.Reference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.ST.GenElim.fsti.checked", "Steel.ST.GenArraySwap.Proof.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.GenArraySwap.fst" }
[ { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "Steel.ST.GenArraySwap.Proof", "short_module": "Prf" }, { "abbrev": false, "full_module": "Steel.ST.GenElim", "short_module": null }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "SZ" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n0: FStar.SizeT.t -> l0: FStar.SizeT.t -> pn: Steel.ST.Reference.ref FStar.SizeT.t -> pl: Steel.ST.Reference.ref FStar.SizeT.t -> b: Prims.bool -> Steel.Effect.Common.vprop
Prims.Tot
[ "total" ]
[]
[ "FStar.SizeT.t", "Steel.ST.Reference.ref", "Prims.bool", "Steel.ST.Util.exists_", "Steel.Effect.Common.star", "Steel.ST.Reference.pts_to", "Steel.FractionalPermission.full_perm", "Steel.ST.Util.pure", "Steel.ST.GenArraySwap.gcd_inv_prop", "FStar.SizeT.v", "Steel.Effect.Common.vprop" ]
[]
false
false
false
true
false
let gcd_inv0 (n0 l0: SZ.t) (pn pl: R.ref SZ.t) (b: bool) : Tot vprop =
exists_ (fun n -> exists_ (fun l -> ((R.pts_to pn full_perm n) `star` (R.pts_to pl full_perm l)) `star` (pure (gcd_inv_prop (SZ.v n0) (SZ.v l0) (SZ.v n) (SZ.v l) b))))
false
Steel.ST.GenArraySwap.fst
Steel.ST.GenArraySwap.gcd_inv
val gcd_inv (n0 l0: SZ.t) (pn pl: R.ref SZ.t) (b: bool) : Tot vprop
val gcd_inv (n0 l0: SZ.t) (pn pl: R.ref SZ.t) (b: bool) : Tot vprop
let gcd_inv (n0: SZ.t) (l0: SZ.t) (pn: R.ref SZ.t) (pl: R.ref SZ.t) (b: bool) : Tot vprop = gcd_inv0 n0 l0 pn pl b
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 24, "end_line": 40, "start_col": 0, "start_line": 33 }
module Steel.ST.GenArraySwap open Steel.ST.GenElim module Prf = Steel.ST.GenArraySwap.Proof module R = Steel.ST.Reference let gcd_inv_prop (n0: nat) (l0: nat) (n: nat) (l: nat) (b: bool) : Tot prop = l0 < n0 /\ l < n /\ (Prf.mk_bezout n0 l0).d == (Prf.mk_bezout n l).d /\ b == (l > 0) [@@__reduce__] let gcd_inv0 (n0: SZ.t) (l0: SZ.t) (pn: R.ref SZ.t) (pl: R.ref SZ.t) (b: bool) : Tot vprop = exists_ (fun n -> exists_ (fun l -> R.pts_to pn full_perm n `star` R.pts_to pl full_perm l `star` pure (gcd_inv_prop (SZ.v n0) (SZ.v l0) (SZ.v n) (SZ.v l) b) ))
{ "checked_file": "/", "dependencies": [ "Steel.ST.Reference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.ST.GenElim.fsti.checked", "Steel.ST.GenArraySwap.Proof.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.GenArraySwap.fst" }
[ { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "Steel.ST.GenArraySwap.Proof", "short_module": "Prf" }, { "abbrev": false, "full_module": "Steel.ST.GenElim", "short_module": null }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "SZ" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n0: FStar.SizeT.t -> l0: FStar.SizeT.t -> pn: Steel.ST.Reference.ref FStar.SizeT.t -> pl: Steel.ST.Reference.ref FStar.SizeT.t -> b: Prims.bool -> Steel.Effect.Common.vprop
Prims.Tot
[ "total" ]
[]
[ "FStar.SizeT.t", "Steel.ST.Reference.ref", "Prims.bool", "Steel.ST.GenArraySwap.gcd_inv0", "Steel.Effect.Common.vprop" ]
[]
false
false
false
true
false
let gcd_inv (n0 l0: SZ.t) (pn pl: R.ref SZ.t) (b: bool) : Tot vprop =
gcd_inv0 n0 l0 pn pl b
false
Hacl.Impl.Curve25519.Generic.fst
Hacl.Impl.Curve25519.Generic.scalar
val scalar : Type0
let scalar = lbuffer uint8 32ul
{ "file_name": "code/curve25519/Hacl.Impl.Curve25519.Generic.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 31, "end_line": 32, "start_col": 0, "start_line": 32 }
module Hacl.Impl.Curve25519.Generic open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Impl.Curve25519.Fields include Hacl.Impl.Curve25519.Finv include Hacl.Impl.Curve25519.AddAndDouble module ST = FStar.HyperStack.ST module BSeq = Lib.ByteSequence module LSeq = Lib.Sequence module C = Hacl.Impl.Curve25519.Fields.Core module S = Spec.Curve25519 module M = Hacl.Spec.Curve25519.AddAndDouble module Lemmas = Hacl.Spec.Curve25519.Field64.Lemmas friend Lib.LoopCombinators #set-options "--z3rlimit 30 --fuel 0 --ifuel 1 --using_facts_from '* -FStar.Seq -Hacl.Spec.*' --record_options" //#set-options "--debug Hacl.Impl.Curve25519.Generic --debug_level ExtractNorm"
{ "checked_file": "/", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Meta.Attribute.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.Loops.fsti.checked", "Lib.LoopCombinators.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Curve25519.Field64.Lemmas.fst.checked", "Hacl.Spec.Curve25519.AddAndDouble.fst.checked", "Hacl.Impl.Curve25519.Finv.fst.checked", "Hacl.Impl.Curve25519.Fields.Core.fsti.checked", "Hacl.Impl.Curve25519.Fields.fst.checked", "Hacl.Impl.Curve25519.AddAndDouble.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.Curve25519.Generic.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Curve25519.Field64.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Hacl.Spec.Curve25519.AddAndDouble", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Curve25519.Fields.Core", "short_module": "C" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519.AddAndDouble", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519.Finv", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519.Fields", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519.Fields", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t" ]
[]
false
false
false
true
true
let scalar =
lbuffer uint8 32ul
false
Vale.Stdcalls.X64.GCM_IV.fst
Vale.Stdcalls.X64.GCM_IV.compute_iv_stdcall
val compute_iv_stdcall : Vale.Interop.Base.normal (iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE -> Vale.Stdcalls.X64.GCM_IV.lowstar_compute_iv_t iv)
let compute_iv_stdcall = as_normal_t #((iv:Ghost.erased supported_iv_LE) -> lowstar_compute_iv_t iv) (fun (iv:Ghost.erased supported_iv_LE) -> lowstar_compute_iv iv)
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCM_IV.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 70, "end_line": 154, "start_col": 0, "start_line": 152 }
module Vale.Stdcalls.X64.GCM_IV open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module GC = Vale.AES.X64.GCMencryptOpt open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b128 = buf_t TUInt8 TUInt128 [@__reduce__] noextract let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq [@__reduce__] noextract let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let (dom: list td{List.length dom <= 20}) = let y = [t128_no_mod; tuint64; tuint64; t128_mod; t128_no_mod; t128_no_mod] in assert_norm (List.length y = 6); y [@__reduce__] noextract let compute_iv_pre : (Ghost.erased supported_iv_LE) -> VSig.vale_pre dom = fun (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (iv_b:b128) (num_bytes:uint64) (len:uint64) (j0_b:b128) (iv_extra_b:b128) (hkeys_b:b128) (va_s0:V.va_state) -> GC.va_req_Compute_iv_stdcall c va_s0 IA.win (Ghost.reveal iv) (as_vale_buffer iv_b) (UInt64.v num_bytes) (UInt64.v len) (as_vale_buffer j0_b) (as_vale_buffer iv_extra_b) (as_vale_buffer hkeys_b) [@__reduce__] noextract let compute_iv_post : (Ghost.erased supported_iv_LE) -> VSig.vale_post dom = fun (iv:Ghost.erased supported_iv_LE) (c:V.va_code) (iv_b:b128) (num_bytes:uint64) (len:uint64) (j0_b:b128) (iv_extra_b:b128) (hkeys_b:b128) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> GC.va_ens_Compute_iv_stdcall c va_s0 IA.win (Ghost.reveal iv) (as_vale_buffer iv_b) (UInt64.v num_bytes) (UInt64.v len) (as_vale_buffer j0_b) (as_vale_buffer iv_extra_b) (as_vale_buffer hkeys_b) va_s1 f #set-options "--z3rlimit 50" [@__reduce__] noextract let compute_iv_lemma' (iv:Ghost.erased supported_iv_LE) (code:V.va_code) (_win:bool) (iv_b:b128) (num_bytes:uint64) (len:uint64) (j0_b:b128) (iv_extra_b:b128) (hkeys_b:b128) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires compute_iv_pre iv code iv_b num_bytes len j0_b iv_extra_b hkeys_b va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ compute_iv_post iv code iv_b num_bytes len j0_b iv_extra_b hkeys_b va_s0 va_s1 f /\ ME.buffer_writeable (as_vale_buffer iv_b) /\ ME.buffer_writeable (as_vale_buffer hkeys_b) /\ ME.buffer_writeable (as_vale_buffer iv_extra_b) /\ ME.buffer_writeable (as_vale_buffer j0_b)) ) = let va_s1, f = GC.va_lemma_Compute_iv_stdcall code va_s0 IA.win (Ghost.reveal iv) (as_vale_buffer iv_b) (UInt64.v num_bytes) (UInt64.v len) (as_vale_buffer j0_b) (as_vale_buffer iv_extra_b) (as_vale_buffer hkeys_b) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 iv_extra_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 j0_b; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 hkeys_b; va_s1, f (* Prove that compute1_iv_lemma' has the required type *) noextract let compute_iv_lemma (iv:Ghost.erased supported_iv_LE) = as_t #(VSig.vale_sig_stdcall (compute_iv_pre iv) (compute_iv_post iv)) (compute_iv_lemma' iv) noextract let code_compute_iv = GC.va_code_Compute_iv_stdcall IA.win (* Here's the type expected for the compute_iv wrapper *) [@__reduce__] noextract let lowstar_compute_iv_t (iv:Ghost.erased supported_iv_LE) = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.as_lowstar_sig_t_weak_stdcall code_compute_iv dom [] _ _ (W.mk_prediction code_compute_iv dom [] ((compute_iv_lemma iv) code_compute_iv IA.win)) (* And here's the gcm wrapper itself *) noextract let lowstar_compute_iv (iv:Ghost.erased supported_iv_LE) : lowstar_compute_iv_t iv = assert_norm (List.length dom + List.length ([]<:list arg) <= 20); IX64.wrap_weak_stdcall code_compute_iv dom (W.mk_prediction code_compute_iv dom [] ((compute_iv_lemma iv) code_compute_iv IA.win))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMencryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCM_IV.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMencryptOpt", "short_module": "GC" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.Interop.Base.normal (iv: FStar.Ghost.erased Vale.AES.GCM_s.supported_iv_LE -> Vale.Stdcalls.X64.GCM_IV.lowstar_compute_iv_t iv)
Prims.Tot
[ "total" ]
[]
[ "Vale.Stdcalls.X64.GCM_IV.as_normal_t", "FStar.Ghost.erased", "Vale.AES.GCM_s.supported_iv_LE", "Vale.Stdcalls.X64.GCM_IV.lowstar_compute_iv_t", "Vale.Stdcalls.X64.GCM_IV.lowstar_compute_iv" ]
[]
false
false
false
false
false
let compute_iv_stdcall =
as_normal_t #(iv: Ghost.erased supported_iv_LE -> lowstar_compute_iv_t iv) (fun (iv: Ghost.erased supported_iv_LE) -> lowstar_compute_iv iv)
false
Steel.ST.GenArraySwap.fst
Steel.ST.GenArraySwap.array_swap_outer_invariant_body0
val array_swap_outer_invariant_body0 (#t: Type) (pts_to: array_pts_to_t t) (pi: R.ref SZ.t) (i: SZ.t) (s: Ghost.erased (Seq.seq t)) : Tot vprop
val array_swap_outer_invariant_body0 (#t: Type) (pts_to: array_pts_to_t t) (pi: R.ref SZ.t) (i: SZ.t) (s: Ghost.erased (Seq.seq t)) : Tot vprop
let array_swap_outer_invariant_body0 (#t: Type) (pts_to: array_pts_to_t t) (pi: R.ref SZ.t) (i: SZ.t) (s: Ghost.erased (Seq.seq t)) : Tot vprop = R.pts_to pi full_perm i `star` pts_to s
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 12, "end_line": 168, "start_col": 0, "start_line": 159 }
module Steel.ST.GenArraySwap open Steel.ST.GenElim module Prf = Steel.ST.GenArraySwap.Proof module R = Steel.ST.Reference let gcd_inv_prop (n0: nat) (l0: nat) (n: nat) (l: nat) (b: bool) : Tot prop = l0 < n0 /\ l < n /\ (Prf.mk_bezout n0 l0).d == (Prf.mk_bezout n l).d /\ b == (l > 0) [@@__reduce__] let gcd_inv0 (n0: SZ.t) (l0: SZ.t) (pn: R.ref SZ.t) (pl: R.ref SZ.t) (b: bool) : Tot vprop = exists_ (fun n -> exists_ (fun l -> R.pts_to pn full_perm n `star` R.pts_to pl full_perm l `star` pure (gcd_inv_prop (SZ.v n0) (SZ.v l0) (SZ.v n) (SZ.v l) b) )) let gcd_inv (n0: SZ.t) (l0: SZ.t) (pn: R.ref SZ.t) (pl: R.ref SZ.t) (b: bool) : Tot vprop = gcd_inv0 n0 l0 pn pl b let gcd_post (n0: SZ.t) (l0: SZ.t) (res: SZ.t) : Tot prop = SZ.v l0 < SZ.v n0 /\ SZ.v res == (Prf.mk_bezout (SZ.v n0) (SZ.v l0)).d #push-options "--z3rlimit 16" #restart-solver let gcd (n0: SZ.t) (l0: SZ.t) : ST SZ.t emp (fun _ -> emp) (SZ.v l0 < SZ.v n0) (fun res -> gcd_post n0 l0 res) = let res = R.with_local n0 (fun pn -> R.with_local l0 (fun pl -> noop (); rewrite (gcd_inv0 n0 l0 pn pl (l0 `SZ.gt` 0sz)) (gcd_inv n0 l0 pn pl (l0 `SZ.gt` 0sz)); Steel.ST.Loops.while_loop (gcd_inv n0 l0 pn pl) (fun _ -> let gb = elim_exists () in rewrite (gcd_inv n0 l0 pn pl gb) (gcd_inv0 n0 l0 pn pl gb); let _ = gen_elim () in let l = R.read pl in [@@inline_let] let b = l `SZ.gt` 0sz in noop (); rewrite (gcd_inv0 n0 l0 pn pl b) (gcd_inv n0 l0 pn pl b); return b ) (fun _ -> rewrite (gcd_inv n0 l0 pn pl true) (gcd_inv0 n0 l0 pn pl true); let _ = gen_elim () in let n = R.read pn in let l = R.read pl in [@@inline_let] let l' = SZ.rem n l in R.write pn l; R.write pl l'; rewrite (gcd_inv0 n0 l0 pn pl (l' `SZ.gt` 0sz)) (gcd_inv n0 l0 pn pl (l' `SZ.gt` 0sz)); noop () ); rewrite (gcd_inv n0 l0 pn pl false) (gcd_inv0 n0 l0 pn pl false); let _ = gen_elim () in let res = R.read pn in return res ) ) in elim_pure (gcd_post n0 l0 res); return res #pop-options let array_swap_partial_invariant (#t: Type) (n: nat) (l: nat) (bz: Prf.bezout n l) (s0: Ghost.erased (Seq.seq t)) (s: Ghost.erased (Seq.seq t)) (i: nat) : GTot prop = n == Seq.length s0 /\ n == Seq.length s /\ 0 < l /\ l < n /\ i <= bz.d /\ (forall (i': Prf.nat_up_to bz.d) . (forall (j: Prf.nat_up_to bz.q_n) . (i' < i) ==> ( let idx = Prf.iter_fun #(Prf.nat_up_to n) (Prf.jump n l) j i' in Seq.index s idx == Seq.index s0 (Prf.jump n l idx) ))) /\ (forall (i': Prf.nat_up_to bz.d) . (forall (j: Prf.nat_up_to bz.q_n) . (i' > i) ==> ( let idx = Prf.iter_fun #(Prf.nat_up_to n) (Prf.jump n l) j i' in Seq.index s idx == Seq.index s0 idx ))) let array_swap_inner_invariant_prop (#t: Type) (n: nat) (l: nat) (bz: Prf.bezout n l) (s0: Ghost.erased (Seq.seq t)) (s: Ghost.erased (Seq.seq t)) (i: nat) (j: nat) (idx: nat) (b: bool) : GTot prop = Prf.array_swap_inner_invariant s0 n l bz s i j idx /\ (b == (j < bz.q_n - 1)) let array_swap_outer_invariant_prop (#t: Type) (n: nat) (l: nat) (bz: Prf.bezout n l) (s0: Ghost.erased (Seq.seq t)) (s: Ghost.erased (Seq.seq t)) (i: nat) (b: bool) : GTot prop = Prf.array_swap_outer_invariant s0 n l bz s i /\ (b == (i < bz.d))
{ "checked_file": "/", "dependencies": [ "Steel.ST.Reference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.ST.GenElim.fsti.checked", "Steel.ST.GenArraySwap.Proof.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.GenArraySwap.fst" }
[ { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "Steel.ST.GenArraySwap.Proof", "short_module": "Prf" }, { "abbrev": false, "full_module": "Steel.ST.GenElim", "short_module": null }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "SZ" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
pts_to: Steel.ST.GenArraySwap.array_pts_to_t t -> pi: Steel.ST.Reference.ref FStar.SizeT.t -> i: FStar.SizeT.t -> s: FStar.Ghost.erased (FStar.Seq.Base.seq t) -> Steel.Effect.Common.vprop
Prims.Tot
[ "total" ]
[]
[ "Steel.ST.GenArraySwap.array_pts_to_t", "Steel.ST.Reference.ref", "FStar.SizeT.t", "FStar.Ghost.erased", "FStar.Seq.Base.seq", "Steel.Effect.Common.star", "Steel.ST.Reference.pts_to", "Steel.FractionalPermission.full_perm", "Steel.Effect.Common.vprop" ]
[]
false
false
false
true
false
let array_swap_outer_invariant_body0 (#t: Type) (pts_to: array_pts_to_t t) (pi: R.ref SZ.t) (i: SZ.t) (s: Ghost.erased (Seq.seq t)) : Tot vprop =
(R.pts_to pi full_perm i) `star` (pts_to s)
false
Demo.MultiplyByRepeatedAddition.fst
Demo.MultiplyByRepeatedAddition.multiply
val multiply (x y: nat) : z: nat{z == x * y}
val multiply (x y: nat) : z: nat{z == x * y}
let rec multiply (x y:nat) : z:nat { z == x * y} = if x = 0 then 0 else multiply (x - 1) y + y
{ "file_name": "share/steel/examples/pulse/Demo.MultiplyByRepeatedAddition.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 31, "end_line": 28, "start_col": 0, "start_line": 26 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Demo.MultiplyByRepeatedAddition open Pulse.Lib.Pervasives open FStar.UInt32 #push-options "--using_facts_from '* -FStar.Tactics -FStar.Reflection'" #set-options "--ext 'pulse:rvalues' --split_queries always" #set-options "--z3rlimit 40" module U32 = FStar.UInt32
{ "checked_file": "/", "dependencies": [ "Pulse.Lib.Pervasives.fst.checked", "Pulse.Lib.BoundedIntegers.fst.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Demo.MultiplyByRepeatedAddition.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Lib.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Demo", "short_module": null }, { "abbrev": false, "full_module": "Demo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Prims.nat -> y: Prims.nat -> z: Prims.nat{z == x * y}
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.op_Equality", "Prims.int", "Prims.bool", "Prims.op_Addition", "Demo.MultiplyByRepeatedAddition.multiply", "Prims.op_Subtraction", "Prims.eq2", "FStar.Mul.op_Star" ]
[ "recursion" ]
false
false
false
false
false
let rec multiply (x y: nat) : z: nat{z == x * y} =
if x = 0 then 0 else multiply (x - 1) y + y
false
Steel.ST.GenArraySwap.fst
Steel.ST.GenArraySwap.array_swap_inner_invariant_body0
val array_swap_inner_invariant_body0 (#t: Type) (pts_to: array_pts_to_t t) (n l: SZ.t) (bz: Prf.bezout (SZ.v n) (SZ.v l)) (s0: Ghost.erased (Seq.seq t)) (pi: R.ref SZ.t) (i: SZ.t) (pj pidx: R.ref SZ.t) (b: bool) (j idx: SZ.t) (s: Ghost.erased (Seq.seq t)) : Tot vprop
val array_swap_inner_invariant_body0 (#t: Type) (pts_to: array_pts_to_t t) (n l: SZ.t) (bz: Prf.bezout (SZ.v n) (SZ.v l)) (s0: Ghost.erased (Seq.seq t)) (pi: R.ref SZ.t) (i: SZ.t) (pj pidx: R.ref SZ.t) (b: bool) (j idx: SZ.t) (s: Ghost.erased (Seq.seq t)) : Tot vprop
let array_swap_inner_invariant_body0 (#t: Type) (pts_to: array_pts_to_t t) (n: SZ.t) (l: SZ.t) (bz: Prf.bezout (SZ.v n) (SZ.v l)) (s0: Ghost.erased (Seq.seq t)) (pi: R.ref SZ.t) (i: SZ.t) (pj: R.ref SZ.t) (pidx: R.ref SZ.t) (b: bool) (j: SZ.t) (idx: SZ.t) (s: Ghost.erased (Seq.seq t)) : Tot vprop = R.pts_to pi full_perm i `star` R.pts_to pj full_perm j `star` R.pts_to pidx full_perm idx `star` pts_to s
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 12, "end_line": 284, "start_col": 0, "start_line": 265 }
module Steel.ST.GenArraySwap open Steel.ST.GenElim module Prf = Steel.ST.GenArraySwap.Proof module R = Steel.ST.Reference let gcd_inv_prop (n0: nat) (l0: nat) (n: nat) (l: nat) (b: bool) : Tot prop = l0 < n0 /\ l < n /\ (Prf.mk_bezout n0 l0).d == (Prf.mk_bezout n l).d /\ b == (l > 0) [@@__reduce__] let gcd_inv0 (n0: SZ.t) (l0: SZ.t) (pn: R.ref SZ.t) (pl: R.ref SZ.t) (b: bool) : Tot vprop = exists_ (fun n -> exists_ (fun l -> R.pts_to pn full_perm n `star` R.pts_to pl full_perm l `star` pure (gcd_inv_prop (SZ.v n0) (SZ.v l0) (SZ.v n) (SZ.v l) b) )) let gcd_inv (n0: SZ.t) (l0: SZ.t) (pn: R.ref SZ.t) (pl: R.ref SZ.t) (b: bool) : Tot vprop = gcd_inv0 n0 l0 pn pl b let gcd_post (n0: SZ.t) (l0: SZ.t) (res: SZ.t) : Tot prop = SZ.v l0 < SZ.v n0 /\ SZ.v res == (Prf.mk_bezout (SZ.v n0) (SZ.v l0)).d #push-options "--z3rlimit 16" #restart-solver let gcd (n0: SZ.t) (l0: SZ.t) : ST SZ.t emp (fun _ -> emp) (SZ.v l0 < SZ.v n0) (fun res -> gcd_post n0 l0 res) = let res = R.with_local n0 (fun pn -> R.with_local l0 (fun pl -> noop (); rewrite (gcd_inv0 n0 l0 pn pl (l0 `SZ.gt` 0sz)) (gcd_inv n0 l0 pn pl (l0 `SZ.gt` 0sz)); Steel.ST.Loops.while_loop (gcd_inv n0 l0 pn pl) (fun _ -> let gb = elim_exists () in rewrite (gcd_inv n0 l0 pn pl gb) (gcd_inv0 n0 l0 pn pl gb); let _ = gen_elim () in let l = R.read pl in [@@inline_let] let b = l `SZ.gt` 0sz in noop (); rewrite (gcd_inv0 n0 l0 pn pl b) (gcd_inv n0 l0 pn pl b); return b ) (fun _ -> rewrite (gcd_inv n0 l0 pn pl true) (gcd_inv0 n0 l0 pn pl true); let _ = gen_elim () in let n = R.read pn in let l = R.read pl in [@@inline_let] let l' = SZ.rem n l in R.write pn l; R.write pl l'; rewrite (gcd_inv0 n0 l0 pn pl (l' `SZ.gt` 0sz)) (gcd_inv n0 l0 pn pl (l' `SZ.gt` 0sz)); noop () ); rewrite (gcd_inv n0 l0 pn pl false) (gcd_inv0 n0 l0 pn pl false); let _ = gen_elim () in let res = R.read pn in return res ) ) in elim_pure (gcd_post n0 l0 res); return res #pop-options let array_swap_partial_invariant (#t: Type) (n: nat) (l: nat) (bz: Prf.bezout n l) (s0: Ghost.erased (Seq.seq t)) (s: Ghost.erased (Seq.seq t)) (i: nat) : GTot prop = n == Seq.length s0 /\ n == Seq.length s /\ 0 < l /\ l < n /\ i <= bz.d /\ (forall (i': Prf.nat_up_to bz.d) . (forall (j: Prf.nat_up_to bz.q_n) . (i' < i) ==> ( let idx = Prf.iter_fun #(Prf.nat_up_to n) (Prf.jump n l) j i' in Seq.index s idx == Seq.index s0 (Prf.jump n l idx) ))) /\ (forall (i': Prf.nat_up_to bz.d) . (forall (j: Prf.nat_up_to bz.q_n) . (i' > i) ==> ( let idx = Prf.iter_fun #(Prf.nat_up_to n) (Prf.jump n l) j i' in Seq.index s idx == Seq.index s0 idx ))) let array_swap_inner_invariant_prop (#t: Type) (n: nat) (l: nat) (bz: Prf.bezout n l) (s0: Ghost.erased (Seq.seq t)) (s: Ghost.erased (Seq.seq t)) (i: nat) (j: nat) (idx: nat) (b: bool) : GTot prop = Prf.array_swap_inner_invariant s0 n l bz s i j idx /\ (b == (j < bz.q_n - 1)) let array_swap_outer_invariant_prop (#t: Type) (n: nat) (l: nat) (bz: Prf.bezout n l) (s0: Ghost.erased (Seq.seq t)) (s: Ghost.erased (Seq.seq t)) (i: nat) (b: bool) : GTot prop = Prf.array_swap_outer_invariant s0 n l bz s i /\ (b == (i < bz.d)) [@@__reduce__] let array_swap_outer_invariant_body0 (#t: Type) (pts_to: array_pts_to_t t) (pi: R.ref SZ.t) (i: SZ.t) (s: Ghost.erased (Seq.seq t)) : Tot vprop = R.pts_to pi full_perm i `star` pts_to s [@@erasable] noeq type array_swap_outer_invariant_t (t: Type) = { i: SZ.t; s: Ghost.erased (Seq.seq t); } [@@__reduce__] let array_swap_outer_invariant0 (#t: Type) (pts_to: array_pts_to_t t) (n: SZ.t) (l: SZ.t) (bz: Prf.bezout (SZ.v n) (SZ.v l)) (s0: Ghost.erased (Seq.seq t)) (pi: R.ref SZ.t) (b: bool) : Tot vprop = exists_ (fun w -> array_swap_outer_invariant_body0 pts_to pi w.i w.s `star` pure (array_swap_outer_invariant_prop (SZ.v n) (SZ.v l) bz s0 w.s (SZ.v w.i) b) ) let array_swap_outer_invariant (#t: Type) (pts_to: array_pts_to_t t) (n: SZ.t) (l: SZ.t) (bz: Prf.bezout (SZ.v n) (SZ.v l)) (s0: Ghost.erased (Seq.seq t)) (pi: R.ref SZ.t) (b: bool) : Tot vprop = array_swap_outer_invariant0 pts_to n l bz s0 pi b let intro_array_swap_outer_invariant (#opened: _) (#t: Type) (pts_to: array_pts_to_t t) (n: SZ.t) (l: SZ.t) (bz: Prf.bezout (SZ.v n) (SZ.v l)) (s0: Ghost.erased (Seq.seq t)) (pi: R.ref SZ.t) (b: bool) (i: SZ.t) (s: Ghost.erased (Seq.seq t)) : STGhost unit opened (array_swap_outer_invariant_body0 pts_to pi i s) (fun _ -> array_swap_outer_invariant pts_to n l bz s0 pi b) (array_swap_outer_invariant_prop (SZ.v n) (SZ.v l) bz s0 s (SZ.v i) b) (fun _ -> True) = let w = { i = i; s = s; } in rewrite (array_swap_outer_invariant_body0 pts_to pi i s) (array_swap_outer_invariant_body0 pts_to pi w.i w.s); rewrite (array_swap_outer_invariant0 pts_to n l bz s0 pi b) (array_swap_outer_invariant pts_to n l bz s0 pi b) let elim_array_swap_outer_invariant (#opened: _) (#t: Type) (pts_to: array_pts_to_t t) (n: SZ.t) (l: SZ.t) (bz: Prf.bezout (SZ.v n) (SZ.v l)) (s0: Ghost.erased (Seq.seq t)) (pi: R.ref SZ.t) (b: bool) : STGhost (array_swap_outer_invariant_t t) opened (array_swap_outer_invariant pts_to n l bz s0 pi b) (fun w -> array_swap_outer_invariant_body0 pts_to pi w.i w.s) True (fun w -> array_swap_outer_invariant_prop (SZ.v n) (SZ.v l) bz s0 w.s (SZ.v w.i) b /\ True // (b == false ==> Ghost.reveal w.s `Seq.equal` (Seq.slice s0 (SZ.v l) (SZ.v n) `Seq.append` Seq.slice s0 0 (SZ.v l))) ) = let w = elim_exists () in let _ = gen_elim () in // Classical.move_requires (array_swap_outer_invariant_prop_end (SZ.v n) (SZ.v l) bz s0 w.s (SZ.v w.i)) b; noop (); w [@@erasable] noeq type array_swap_inner_invariant_t (t: Type) = { j: SZ.t; idx: SZ.t; s: Ghost.erased (Seq.seq t) }
{ "checked_file": "/", "dependencies": [ "Steel.ST.Reference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.ST.GenElim.fsti.checked", "Steel.ST.GenArraySwap.Proof.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.GenArraySwap.fst" }
[ { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "Steel.ST.GenArraySwap.Proof", "short_module": "Prf" }, { "abbrev": false, "full_module": "Steel.ST.GenElim", "short_module": null }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "SZ" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
pts_to: Steel.ST.GenArraySwap.array_pts_to_t t -> n: FStar.SizeT.t -> l: FStar.SizeT.t -> bz: Steel.ST.GenArraySwap.Proof.bezout (FStar.SizeT.v n) (FStar.SizeT.v l) -> s0: FStar.Ghost.erased (FStar.Seq.Base.seq t) -> pi: Steel.ST.Reference.ref FStar.SizeT.t -> i: FStar.SizeT.t -> pj: Steel.ST.Reference.ref FStar.SizeT.t -> pidx: Steel.ST.Reference.ref FStar.SizeT.t -> b: Prims.bool -> j: FStar.SizeT.t -> idx: FStar.SizeT.t -> s: FStar.Ghost.erased (FStar.Seq.Base.seq t) -> Steel.Effect.Common.vprop
Prims.Tot
[ "total" ]
[]
[ "Steel.ST.GenArraySwap.array_pts_to_t", "FStar.SizeT.t", "Steel.ST.GenArraySwap.Proof.bezout", "FStar.SizeT.v", "FStar.Ghost.erased", "FStar.Seq.Base.seq", "Steel.ST.Reference.ref", "Prims.bool", "Steel.Effect.Common.star", "Steel.ST.Reference.pts_to", "Steel.FractionalPermission.full_perm", "Steel.Effect.Common.vprop" ]
[]
false
false
false
false
false
let array_swap_inner_invariant_body0 (#t: Type) (pts_to: array_pts_to_t t) (n l: SZ.t) (bz: Prf.bezout (SZ.v n) (SZ.v l)) (s0: Ghost.erased (Seq.seq t)) (pi: R.ref SZ.t) (i: SZ.t) (pj pidx: R.ref SZ.t) (b: bool) (j idx: SZ.t) (s: Ghost.erased (Seq.seq t)) : Tot vprop =
(((R.pts_to pi full_perm i) `star` (R.pts_to pj full_perm j)) `star` (R.pts_to pidx full_perm idx)) `star` (pts_to s)
false
Steel.ST.GenArraySwap.fst
Steel.ST.GenArraySwap.gcd_inv_prop
val gcd_inv_prop (n0 l0 n l: nat) (b: bool) : Tot prop
val gcd_inv_prop (n0 l0 n l: nat) (b: bool) : Tot prop
let gcd_inv_prop (n0: nat) (l0: nat) (n: nat) (l: nat) (b: bool) : Tot prop = l0 < n0 /\ l < n /\ (Prf.mk_bezout n0 l0).d == (Prf.mk_bezout n l).d /\ b == (l > 0)
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 14, "end_line": 17, "start_col": 0, "start_line": 7 }
module Steel.ST.GenArraySwap open Steel.ST.GenElim module Prf = Steel.ST.GenArraySwap.Proof module R = Steel.ST.Reference
{ "checked_file": "/", "dependencies": [ "Steel.ST.Reference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.ST.GenElim.fsti.checked", "Steel.ST.GenArraySwap.Proof.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.GenArraySwap.fst" }
[ { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "Steel.ST.GenArraySwap.Proof", "short_module": "Prf" }, { "abbrev": false, "full_module": "Steel.ST.GenElim", "short_module": null }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "SZ" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n0: Prims.nat -> l0: Prims.nat -> n: Prims.nat -> l: Prims.nat -> b: Prims.bool -> Prims.prop
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.bool", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Prims.eq2", "Prims.pos", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__d", "Steel.ST.GenArraySwap.Proof.mk_bezout", "Prims.op_GreaterThan", "Prims.prop" ]
[]
false
false
false
true
true
let gcd_inv_prop (n0 l0 n l: nat) (b: bool) : Tot prop =
l0 < n0 /\ l < n /\ (Prf.mk_bezout n0 l0).d == (Prf.mk_bezout n l).d /\ b == (l > 0)
false
Vale.Stdcalls.X64.GCM_IV.fst
Vale.Stdcalls.X64.GCM_IV.as_normal_t
val as_normal_t (#a: Type) (x: a) : normal a
val as_normal_t (#a: Type) (x: a) : normal a
let as_normal_t (#a:Type) (x:a) : normal a = x
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCM_IV.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 46, "end_line": 33, "start_col": 0, "start_line": 33 }
module Vale.Stdcalls.X64.GCM_IV open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module GC = Vale.AES.X64.GCMencryptOpt open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMencryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCM_IV.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMencryptOpt", "short_module": "GC" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: a -> Vale.Interop.Base.normal a
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.Base.normal" ]
[]
false
false
false
true
false
let as_normal_t (#a: Type) (x: a) : normal a =
x
false
Vale.Stdcalls.X64.GCM_IV.fst
Vale.Stdcalls.X64.GCM_IV.as_t
val as_t (#a: Type) (x: normal a) : a
val as_t (#a: Type) (x: normal a) : a
let as_t (#a:Type) (x:normal a) : a = x
{ "file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCM_IV.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 39, "end_line": 31, "start_col": 0, "start_line": 31 }
module Vale.Stdcalls.X64.GCM_IV open FStar.HyperStack.ST module B = LowStar.Buffer module HS = FStar.HyperStack open FStar.Mul module DV = LowStar.BufferView.Down module UV = LowStar.BufferView.Up open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s module GC = Vale.AES.X64.GCMencryptOpt open Vale.AES.GCM_s let uint64 = UInt64.t (* A little utility to trigger normalization in types *)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "Vale.AES.X64.GCMencryptOpt.fsti.checked", "Vale.AES.GCM_s.fst.checked", "prims.fst.checked", "LowStar.BufferView.Up.fsti.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Vale.Stdcalls.X64.GCM_IV.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.AES.X64.GCMencryptOpt", "short_module": "GC" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Up", "short_module": "UV" }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Stdcalls.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Vale.Interop.Base.normal a -> a
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.Base.normal" ]
[]
false
false
false
true
false
let as_t (#a: Type) (x: normal a) : a =
x
false
Steel.ST.GenArraySwap.fst
Steel.ST.GenArraySwap.gcd_post
val gcd_post (n0 l0 res: SZ.t) : Tot prop
val gcd_post (n0 l0 res: SZ.t) : Tot prop
let gcd_post (n0: SZ.t) (l0: SZ.t) (res: SZ.t) : Tot prop = SZ.v l0 < SZ.v n0 /\ SZ.v res == (Prf.mk_bezout (SZ.v n0) (SZ.v l0)).d
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 51, "end_line": 48, "start_col": 0, "start_line": 42 }
module Steel.ST.GenArraySwap open Steel.ST.GenElim module Prf = Steel.ST.GenArraySwap.Proof module R = Steel.ST.Reference let gcd_inv_prop (n0: nat) (l0: nat) (n: nat) (l: nat) (b: bool) : Tot prop = l0 < n0 /\ l < n /\ (Prf.mk_bezout n0 l0).d == (Prf.mk_bezout n l).d /\ b == (l > 0) [@@__reduce__] let gcd_inv0 (n0: SZ.t) (l0: SZ.t) (pn: R.ref SZ.t) (pl: R.ref SZ.t) (b: bool) : Tot vprop = exists_ (fun n -> exists_ (fun l -> R.pts_to pn full_perm n `star` R.pts_to pl full_perm l `star` pure (gcd_inv_prop (SZ.v n0) (SZ.v l0) (SZ.v n) (SZ.v l) b) )) let gcd_inv (n0: SZ.t) (l0: SZ.t) (pn: R.ref SZ.t) (pl: R.ref SZ.t) (b: bool) : Tot vprop = gcd_inv0 n0 l0 pn pl b
{ "checked_file": "/", "dependencies": [ "Steel.ST.Reference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.ST.GenElim.fsti.checked", "Steel.ST.GenArraySwap.Proof.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.GenArraySwap.fst" }
[ { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "Steel.ST.GenArraySwap.Proof", "short_module": "Prf" }, { "abbrev": false, "full_module": "Steel.ST.GenElim", "short_module": null }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "SZ" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n0: FStar.SizeT.t -> l0: FStar.SizeT.t -> res: FStar.SizeT.t -> Prims.prop
Prims.Tot
[ "total" ]
[]
[ "FStar.SizeT.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.SizeT.v", "Prims.eq2", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "Prims.op_GreaterThan", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__d", "Steel.ST.GenArraySwap.Proof.mk_bezout", "Prims.prop" ]
[]
false
false
false
true
true
let gcd_post (n0 l0 res: SZ.t) : Tot prop =
SZ.v l0 < SZ.v n0 /\ SZ.v res == (Prf.mk_bezout (SZ.v n0) (SZ.v l0)).d
false
Steel.ST.GenArraySwap.fst
Steel.ST.GenArraySwap.array_swap_partial_invariant
val array_swap_partial_invariant (#t: Type) (n l: nat) (bz: Prf.bezout n l) (s0 s: Ghost.erased (Seq.seq t)) (i: nat) : GTot prop
val array_swap_partial_invariant (#t: Type) (n l: nat) (bz: Prf.bezout n l) (s0 s: Ghost.erased (Seq.seq t)) (i: nat) : GTot prop
let array_swap_partial_invariant (#t: Type) (n: nat) (l: nat) (bz: Prf.bezout n l) (s0: Ghost.erased (Seq.seq t)) (s: Ghost.erased (Seq.seq t)) (i: nat) : GTot prop = n == Seq.length s0 /\ n == Seq.length s /\ 0 < l /\ l < n /\ i <= bz.d /\ (forall (i': Prf.nat_up_to bz.d) . (forall (j: Prf.nat_up_to bz.q_n) . (i' < i) ==> ( let idx = Prf.iter_fun #(Prf.nat_up_to n) (Prf.jump n l) j i' in Seq.index s idx == Seq.index s0 (Prf.jump n l idx) ))) /\ (forall (i': Prf.nat_up_to bz.d) . (forall (j: Prf.nat_up_to bz.q_n) . (i' > i) ==> ( let idx = Prf.iter_fun #(Prf.nat_up_to n) (Prf.jump n l) j i' in Seq.index s idx == Seq.index s0 idx )))
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 5, "end_line": 128, "start_col": 0, "start_line": 103 }
module Steel.ST.GenArraySwap open Steel.ST.GenElim module Prf = Steel.ST.GenArraySwap.Proof module R = Steel.ST.Reference let gcd_inv_prop (n0: nat) (l0: nat) (n: nat) (l: nat) (b: bool) : Tot prop = l0 < n0 /\ l < n /\ (Prf.mk_bezout n0 l0).d == (Prf.mk_bezout n l).d /\ b == (l > 0) [@@__reduce__] let gcd_inv0 (n0: SZ.t) (l0: SZ.t) (pn: R.ref SZ.t) (pl: R.ref SZ.t) (b: bool) : Tot vprop = exists_ (fun n -> exists_ (fun l -> R.pts_to pn full_perm n `star` R.pts_to pl full_perm l `star` pure (gcd_inv_prop (SZ.v n0) (SZ.v l0) (SZ.v n) (SZ.v l) b) )) let gcd_inv (n0: SZ.t) (l0: SZ.t) (pn: R.ref SZ.t) (pl: R.ref SZ.t) (b: bool) : Tot vprop = gcd_inv0 n0 l0 pn pl b let gcd_post (n0: SZ.t) (l0: SZ.t) (res: SZ.t) : Tot prop = SZ.v l0 < SZ.v n0 /\ SZ.v res == (Prf.mk_bezout (SZ.v n0) (SZ.v l0)).d #push-options "--z3rlimit 16" #restart-solver let gcd (n0: SZ.t) (l0: SZ.t) : ST SZ.t emp (fun _ -> emp) (SZ.v l0 < SZ.v n0) (fun res -> gcd_post n0 l0 res) = let res = R.with_local n0 (fun pn -> R.with_local l0 (fun pl -> noop (); rewrite (gcd_inv0 n0 l0 pn pl (l0 `SZ.gt` 0sz)) (gcd_inv n0 l0 pn pl (l0 `SZ.gt` 0sz)); Steel.ST.Loops.while_loop (gcd_inv n0 l0 pn pl) (fun _ -> let gb = elim_exists () in rewrite (gcd_inv n0 l0 pn pl gb) (gcd_inv0 n0 l0 pn pl gb); let _ = gen_elim () in let l = R.read pl in [@@inline_let] let b = l `SZ.gt` 0sz in noop (); rewrite (gcd_inv0 n0 l0 pn pl b) (gcd_inv n0 l0 pn pl b); return b ) (fun _ -> rewrite (gcd_inv n0 l0 pn pl true) (gcd_inv0 n0 l0 pn pl true); let _ = gen_elim () in let n = R.read pn in let l = R.read pl in [@@inline_let] let l' = SZ.rem n l in R.write pn l; R.write pl l'; rewrite (gcd_inv0 n0 l0 pn pl (l' `SZ.gt` 0sz)) (gcd_inv n0 l0 pn pl (l' `SZ.gt` 0sz)); noop () ); rewrite (gcd_inv n0 l0 pn pl false) (gcd_inv0 n0 l0 pn pl false); let _ = gen_elim () in let res = R.read pn in return res ) ) in elim_pure (gcd_post n0 l0 res); return res #pop-options
{ "checked_file": "/", "dependencies": [ "Steel.ST.Reference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.ST.GenElim.fsti.checked", "Steel.ST.GenArraySwap.Proof.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.GenArraySwap.fst" }
[ { "abbrev": true, "full_module": "Steel.ST.Reference", "short_module": "R" }, { "abbrev": true, "full_module": "Steel.ST.GenArraySwap.Proof", "short_module": "Prf" }, { "abbrev": false, "full_module": "Steel.ST.GenElim", "short_module": null }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "SZ" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat -> l: Prims.nat -> bz: Steel.ST.GenArraySwap.Proof.bezout n l -> s0: FStar.Ghost.erased (FStar.Seq.Base.seq t) -> s: FStar.Ghost.erased (FStar.Seq.Base.seq t) -> i: Prims.nat -> Prims.GTot Prims.prop
Prims.GTot
[ "sometrivial" ]
[]
[ "Prims.nat", "Steel.ST.GenArraySwap.Proof.bezout", "FStar.Ghost.erased", "FStar.Seq.Base.seq", "Prims.l_and", "Prims.eq2", "FStar.Seq.Base.length", "FStar.Ghost.reveal", "Prims.b2t", "Prims.op_LessThan", "Prims.op_LessThanOrEqual", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__d", "Prims.l_Forall", "Steel.ST.GenArraySwap.Proof.nat_up_to", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__q_n", "Prims.l_imp", "FStar.Seq.Base.index", "Steel.ST.GenArraySwap.Proof.jump", "Steel.ST.GenArraySwap.Proof.iter_fun", "Prims.op_GreaterThan", "Prims.prop" ]
[]
false
false
false
false
true
let array_swap_partial_invariant (#t: Type) (n l: nat) (bz: Prf.bezout n l) (s0 s: Ghost.erased (Seq.seq t)) (i: nat) : GTot prop =
n == Seq.length s0 /\ n == Seq.length s /\ 0 < l /\ l < n /\ i <= bz.d /\ (forall (i': Prf.nat_up_to bz.d). (forall (j: Prf.nat_up_to bz.q_n). (i' < i) ==> (let idx = Prf.iter_fun #(Prf.nat_up_to n) (Prf.jump n l) j i' in Seq.index s idx == Seq.index s0 (Prf.jump n l idx)))) /\ (forall (i': Prf.nat_up_to bz.d). (forall (j: Prf.nat_up_to bz.q_n). (i' > i) ==> (let idx = Prf.iter_fun #(Prf.nat_up_to n) (Prf.jump n l) j i' in Seq.index s idx == Seq.index s0 idx)))
false