effect
stringclasses
48 values
original_source_type
stringlengths
0
23k
opens_and_abbrevs
listlengths
2
92
isa_cross_project_example
bool
1 class
source_definition
stringlengths
9
57.9k
partial_definition
stringlengths
7
23.3k
is_div
bool
2 classes
is_type
null
is_proof
bool
2 classes
completed_definiton
stringlengths
1
250k
dependencies
dict
effect_flags
sequencelengths
0
2
ideal_premises
sequencelengths
0
236
mutual_with
sequencelengths
0
11
file_context
stringlengths
0
407k
interleaved
bool
1 class
is_simply_typed
bool
2 classes
file_name
stringlengths
5
48
vconfig
dict
is_simple_lemma
null
source_type
stringlengths
10
23k
proof_features
sequencelengths
0
1
name
stringlengths
8
95
source
dict
verbose_type
stringlengths
1
7.42k
source_range
dict
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let add_comm = assert (forall x y. x +. y = y +.x)
let add_comm =
false
null
false
assert (forall x y. x +. y = y +. x)
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "Prims._assert", "Prims.l_Forall", "FStar.Real.real", "Prims.b2t", "Prims.op_Equality", "FStar.Real.op_Plus_Dot" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two} let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n) let test = assert (two >. one) let test1 = assert (one = 1.0R) let test_lt1 = assert (1.0R <. 2.0R) let test_lt2 = assert (~ (1.0R <. 1.0R)) let test_lt3 = assert (~ (2.0R <. 1.0R)) let test_le1 = assert (1.0R <=. 2.0R) let test_le2 = assert (1.0R <=. 1.0R) let test_le3 = assert (~ (2.0R <=. 1.0R)) let test_gt1 = assert (~ (1.0R >. 2.0R)) let test_gt2 = assert (~ (1.0R >. 1.0R)) let test_gt3 = assert (2.0R >. 1.0R) let test_ge1 = assert (~ (1.0R >=. 2.0R)) let test_ge2 = assert (1.0R >=. 1.0R) let test_ge3 = assert (2.0R >=. 1.0R) let test_add_eq = assert (1.0R +. 1.0R = 2.0R) let test_add_eq' = assert (1.0R +. 3.0R = 4.0R) let test_add_lt = assert (1.0R +. 1.0R <. 3.0R) let test_mul_eq = assert (2.0R *. 2.0R = 4.0R) let test_mul_lt = assert (2.0R *. 2.0R <. 5.0R) let test_div_eq = assert (8.0R /. 2.0R = 4.0R) let test_div_lt = assert (8.0R /. 2.0R <. 5.0R) let test_sqrt_2_mul = assert (sqrt_2 *. sqrt_2 = 2.0R) //let test_sqrt_2_add = assert (sqrt_2 +. sqrt_2 >. 2.0R) // Fails let test_sqrt_2_scale = assert (1.0R /. sqrt_2 = sqrt_2 /. 2.0R) // Common identities let add_id_l = assert (forall n. 0.0R +. n = n) let add_id_r = assert (forall n. n +. 0.0R = n) let mul_nil_l = assert (forall n. 0.0R *. n = 0.0R) let mul_nil_r = assert (forall n. n *. 0.0R = 0.0R) let mul_id_l = assert (forall n. 1.0R *. n = n) let mul_id_r = assert (forall n. n *. 1.0R = n)
false
true
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val add_comm : Prims.unit
[]
FStar.Real.add_comm
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.unit
{ "end_col": 50, "end_line": 102, "start_col": 15, "start_line": 102 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test_mul_lt = assert (2.0R *. 2.0R <. 5.0R)
let test_mul_lt =
false
null
false
assert (2.0R *. 2.0R <. 5.0R)
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "Prims._assert", "Prims.b2t", "FStar.Real.op_Less_Dot", "FStar.Real.op_Star_Dot" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two} let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n) let test = assert (two >. one) let test1 = assert (one = 1.0R) let test_lt1 = assert (1.0R <. 2.0R) let test_lt2 = assert (~ (1.0R <. 1.0R)) let test_lt3 = assert (~ (2.0R <. 1.0R)) let test_le1 = assert (1.0R <=. 2.0R) let test_le2 = assert (1.0R <=. 1.0R) let test_le3 = assert (~ (2.0R <=. 1.0R)) let test_gt1 = assert (~ (1.0R >. 2.0R)) let test_gt2 = assert (~ (1.0R >. 1.0R)) let test_gt3 = assert (2.0R >. 1.0R) let test_ge1 = assert (~ (1.0R >=. 2.0R)) let test_ge2 = assert (1.0R >=. 1.0R) let test_ge3 = assert (2.0R >=. 1.0R) let test_add_eq = assert (1.0R +. 1.0R = 2.0R) let test_add_eq' = assert (1.0R +. 3.0R = 4.0R) let test_add_lt = assert (1.0R +. 1.0R <. 3.0R)
false
true
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test_mul_lt : Prims.unit
[]
FStar.Real.test_mul_lt
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.unit
{ "end_col": 47, "end_line": 83, "start_col": 18, "start_line": 83 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test_div_lt = assert (8.0R /. 2.0R <. 5.0R)
let test_div_lt =
false
null
false
assert (8.0R /. 2.0R <. 5.0R)
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "Prims._assert", "Prims.b2t", "FStar.Real.op_Less_Dot", "FStar.Real.op_Slash_Dot" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two} let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n) let test = assert (two >. one) let test1 = assert (one = 1.0R) let test_lt1 = assert (1.0R <. 2.0R) let test_lt2 = assert (~ (1.0R <. 1.0R)) let test_lt3 = assert (~ (2.0R <. 1.0R)) let test_le1 = assert (1.0R <=. 2.0R) let test_le2 = assert (1.0R <=. 1.0R) let test_le3 = assert (~ (2.0R <=. 1.0R)) let test_gt1 = assert (~ (1.0R >. 2.0R)) let test_gt2 = assert (~ (1.0R >. 1.0R)) let test_gt3 = assert (2.0R >. 1.0R) let test_ge1 = assert (~ (1.0R >=. 2.0R)) let test_ge2 = assert (1.0R >=. 1.0R) let test_ge3 = assert (2.0R >=. 1.0R) let test_add_eq = assert (1.0R +. 1.0R = 2.0R) let test_add_eq' = assert (1.0R +. 3.0R = 4.0R) let test_add_lt = assert (1.0R +. 1.0R <. 3.0R) let test_mul_eq = assert (2.0R *. 2.0R = 4.0R) let test_mul_lt = assert (2.0R *. 2.0R <. 5.0R)
false
true
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test_div_lt : Prims.unit
[]
FStar.Real.test_div_lt
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.unit
{ "end_col": 47, "end_line": 86, "start_col": 18, "start_line": 86 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test_lt1 = assert (1.0R <. 2.0R)
let test_lt1 =
false
null
false
assert (1.0R <. 2.0R)
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "Prims._assert", "Prims.b2t", "FStar.Real.op_Less_Dot" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two} let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n) let test = assert (two >. one) let test1 = assert (one = 1.0R)
false
true
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test_lt1 : Prims.unit
[]
FStar.Real.test_lt1
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.unit
{ "end_col": 36, "end_line": 62, "start_col": 15, "start_line": 62 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mul_comm = assert (forall x y. x *. y = y *.x)
let mul_comm =
false
null
false
assert (forall x y. x *. y = y *. x)
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "Prims._assert", "Prims.l_Forall", "FStar.Real.real", "Prims.b2t", "Prims.op_Equality", "FStar.Real.op_Star_Dot" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two} let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n) let test = assert (two >. one) let test1 = assert (one = 1.0R) let test_lt1 = assert (1.0R <. 2.0R) let test_lt2 = assert (~ (1.0R <. 1.0R)) let test_lt3 = assert (~ (2.0R <. 1.0R)) let test_le1 = assert (1.0R <=. 2.0R) let test_le2 = assert (1.0R <=. 1.0R) let test_le3 = assert (~ (2.0R <=. 1.0R)) let test_gt1 = assert (~ (1.0R >. 2.0R)) let test_gt2 = assert (~ (1.0R >. 1.0R)) let test_gt3 = assert (2.0R >. 1.0R) let test_ge1 = assert (~ (1.0R >=. 2.0R)) let test_ge2 = assert (1.0R >=. 1.0R) let test_ge3 = assert (2.0R >=. 1.0R) let test_add_eq = assert (1.0R +. 1.0R = 2.0R) let test_add_eq' = assert (1.0R +. 3.0R = 4.0R) let test_add_lt = assert (1.0R +. 1.0R <. 3.0R) let test_mul_eq = assert (2.0R *. 2.0R = 4.0R) let test_mul_lt = assert (2.0R *. 2.0R <. 5.0R) let test_div_eq = assert (8.0R /. 2.0R = 4.0R) let test_div_lt = assert (8.0R /. 2.0R <. 5.0R) let test_sqrt_2_mul = assert (sqrt_2 *. sqrt_2 = 2.0R) //let test_sqrt_2_add = assert (sqrt_2 +. sqrt_2 >. 2.0R) // Fails let test_sqrt_2_scale = assert (1.0R /. sqrt_2 = sqrt_2 /. 2.0R) // Common identities let add_id_l = assert (forall n. 0.0R +. n = n) let add_id_r = assert (forall n. n +. 0.0R = n) let mul_nil_l = assert (forall n. 0.0R *. n = 0.0R) let mul_nil_r = assert (forall n. n *. 0.0R = 0.0R) let mul_id_l = assert (forall n. 1.0R *. n = n) let mul_id_r = assert (forall n. n *. 1.0R = n) let add_comm = assert (forall x y. x +. y = y +.x) let add_assoc = assert (forall x y z. ((x +. y) +.z) = (x +. (y +. z)))
false
true
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mul_comm : Prims.unit
[]
FStar.Real.mul_comm
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.unit
{ "end_col": 50, "end_line": 105, "start_col": 15, "start_line": 105 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mul_nil_l = assert (forall n. 0.0R *. n = 0.0R)
let mul_nil_l =
false
null
false
assert (forall n. 0.0R *. n = 0.0R)
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "Prims._assert", "Prims.l_Forall", "FStar.Real.real", "Prims.b2t", "Prims.op_Equality", "FStar.Real.op_Star_Dot" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two} let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n) let test = assert (two >. one) let test1 = assert (one = 1.0R) let test_lt1 = assert (1.0R <. 2.0R) let test_lt2 = assert (~ (1.0R <. 1.0R)) let test_lt3 = assert (~ (2.0R <. 1.0R)) let test_le1 = assert (1.0R <=. 2.0R) let test_le2 = assert (1.0R <=. 1.0R) let test_le3 = assert (~ (2.0R <=. 1.0R)) let test_gt1 = assert (~ (1.0R >. 2.0R)) let test_gt2 = assert (~ (1.0R >. 1.0R)) let test_gt3 = assert (2.0R >. 1.0R) let test_ge1 = assert (~ (1.0R >=. 2.0R)) let test_ge2 = assert (1.0R >=. 1.0R) let test_ge3 = assert (2.0R >=. 1.0R) let test_add_eq = assert (1.0R +. 1.0R = 2.0R) let test_add_eq' = assert (1.0R +. 3.0R = 4.0R) let test_add_lt = assert (1.0R +. 1.0R <. 3.0R) let test_mul_eq = assert (2.0R *. 2.0R = 4.0R) let test_mul_lt = assert (2.0R *. 2.0R <. 5.0R) let test_div_eq = assert (8.0R /. 2.0R = 4.0R) let test_div_lt = assert (8.0R /. 2.0R <. 5.0R) let test_sqrt_2_mul = assert (sqrt_2 *. sqrt_2 = 2.0R) //let test_sqrt_2_add = assert (sqrt_2 +. sqrt_2 >. 2.0R) // Fails let test_sqrt_2_scale = assert (1.0R /. sqrt_2 = sqrt_2 /. 2.0R) // Common identities let add_id_l = assert (forall n. 0.0R +. n = n) let add_id_r = assert (forall n. n +. 0.0R = n)
false
true
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mul_nil_l : Prims.unit
[]
FStar.Real.mul_nil_l
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.unit
{ "end_col": 51, "end_line": 96, "start_col": 16, "start_line": 96 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test_gt1 = assert (~ (1.0R >. 2.0R))
let test_gt1 =
false
null
false
assert (~(1.0R >. 2.0R))
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "Prims._assert", "Prims.l_not", "Prims.b2t", "FStar.Real.op_Greater_Dot" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two} let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n) let test = assert (two >. one) let test1 = assert (one = 1.0R) let test_lt1 = assert (1.0R <. 2.0R) let test_lt2 = assert (~ (1.0R <. 1.0R)) let test_lt3 = assert (~ (2.0R <. 1.0R)) let test_le1 = assert (1.0R <=. 2.0R) let test_le2 = assert (1.0R <=. 1.0R) let test_le3 = assert (~ (2.0R <=. 1.0R))
false
true
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test_gt1 : Prims.unit
[]
FStar.Real.test_gt1
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.unit
{ "end_col": 40, "end_line": 70, "start_col": 15, "start_line": 70 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test_add_eq = assert (1.0R +. 1.0R = 2.0R)
let test_add_eq =
false
null
false
assert (1.0R +. 1.0R = 2.0R)
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "Prims._assert", "Prims.b2t", "Prims.op_Equality", "FStar.Real.real", "FStar.Real.op_Plus_Dot" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two} let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n) let test = assert (two >. one) let test1 = assert (one = 1.0R) let test_lt1 = assert (1.0R <. 2.0R) let test_lt2 = assert (~ (1.0R <. 1.0R)) let test_lt3 = assert (~ (2.0R <. 1.0R)) let test_le1 = assert (1.0R <=. 2.0R) let test_le2 = assert (1.0R <=. 1.0R) let test_le3 = assert (~ (2.0R <=. 1.0R)) let test_gt1 = assert (~ (1.0R >. 2.0R)) let test_gt2 = assert (~ (1.0R >. 1.0R)) let test_gt3 = assert (2.0R >. 1.0R) let test_ge1 = assert (~ (1.0R >=. 2.0R)) let test_ge2 = assert (1.0R >=. 1.0R) let test_ge3 = assert (2.0R >=. 1.0R)
false
true
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test_add_eq : Prims.unit
[]
FStar.Real.test_add_eq
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.unit
{ "end_col": 46, "end_line": 78, "start_col": 18, "start_line": 78 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test_ge1 = assert (~ (1.0R >=. 2.0R))
let test_ge1 =
false
null
false
assert (~(1.0R >=. 2.0R))
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "Prims._assert", "Prims.l_not", "Prims.b2t", "FStar.Real.op_Greater_Equals_Dot" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two} let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n) let test = assert (two >. one) let test1 = assert (one = 1.0R) let test_lt1 = assert (1.0R <. 2.0R) let test_lt2 = assert (~ (1.0R <. 1.0R)) let test_lt3 = assert (~ (2.0R <. 1.0R)) let test_le1 = assert (1.0R <=. 2.0R) let test_le2 = assert (1.0R <=. 1.0R) let test_le3 = assert (~ (2.0R <=. 1.0R)) let test_gt1 = assert (~ (1.0R >. 2.0R)) let test_gt2 = assert (~ (1.0R >. 1.0R)) let test_gt3 = assert (2.0R >. 1.0R)
false
true
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test_ge1 : Prims.unit
[]
FStar.Real.test_ge1
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.unit
{ "end_col": 41, "end_line": 74, "start_col": 15, "start_line": 74 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test_lt3 = assert (~ (2.0R <. 1.0R))
let test_lt3 =
false
null
false
assert (~(2.0R <. 1.0R))
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "Prims._assert", "Prims.l_not", "Prims.b2t", "FStar.Real.op_Less_Dot" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two} let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n) let test = assert (two >. one) let test1 = assert (one = 1.0R) let test_lt1 = assert (1.0R <. 2.0R)
false
true
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test_lt3 : Prims.unit
[]
FStar.Real.test_lt3
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.unit
{ "end_col": 40, "end_line": 64, "start_col": 15, "start_line": 64 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mul_dist = assert (forall x y z. x *. (y +. z) = (x *. y) +. (x *.z))
let mul_dist =
false
null
false
assert (forall x y z. x *. (y +. z) = (x *. y) +. (x *. z))
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "Prims._assert", "Prims.l_Forall", "FStar.Real.real", "Prims.b2t", "Prims.op_Equality", "FStar.Real.op_Star_Dot", "FStar.Real.op_Plus_Dot" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two} let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n) let test = assert (two >. one) let test1 = assert (one = 1.0R) let test_lt1 = assert (1.0R <. 2.0R) let test_lt2 = assert (~ (1.0R <. 1.0R)) let test_lt3 = assert (~ (2.0R <. 1.0R)) let test_le1 = assert (1.0R <=. 2.0R) let test_le2 = assert (1.0R <=. 1.0R) let test_le3 = assert (~ (2.0R <=. 1.0R)) let test_gt1 = assert (~ (1.0R >. 2.0R)) let test_gt2 = assert (~ (1.0R >. 1.0R)) let test_gt3 = assert (2.0R >. 1.0R) let test_ge1 = assert (~ (1.0R >=. 2.0R)) let test_ge2 = assert (1.0R >=. 1.0R) let test_ge3 = assert (2.0R >=. 1.0R) let test_add_eq = assert (1.0R +. 1.0R = 2.0R) let test_add_eq' = assert (1.0R +. 3.0R = 4.0R) let test_add_lt = assert (1.0R +. 1.0R <. 3.0R) let test_mul_eq = assert (2.0R *. 2.0R = 4.0R) let test_mul_lt = assert (2.0R *. 2.0R <. 5.0R) let test_div_eq = assert (8.0R /. 2.0R = 4.0R) let test_div_lt = assert (8.0R /. 2.0R <. 5.0R) let test_sqrt_2_mul = assert (sqrt_2 *. sqrt_2 = 2.0R) //let test_sqrt_2_add = assert (sqrt_2 +. sqrt_2 >. 2.0R) // Fails let test_sqrt_2_scale = assert (1.0R /. sqrt_2 = sqrt_2 /. 2.0R) // Common identities let add_id_l = assert (forall n. 0.0R +. n = n) let add_id_r = assert (forall n. n +. 0.0R = n) let mul_nil_l = assert (forall n. 0.0R *. n = 0.0R) let mul_nil_r = assert (forall n. n *. 0.0R = 0.0R) let mul_id_l = assert (forall n. 1.0R *. n = n) let mul_id_r = assert (forall n. n *. 1.0R = n) let add_comm = assert (forall x y. x +. y = y +.x) let add_assoc = assert (forall x y z. ((x +. y) +.z) = (x +. (y +. z))) let mul_comm = assert (forall x y. x *. y = y *.x)
false
true
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mul_dist : Prims.unit
[]
FStar.Real.mul_dist
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.unit
{ "end_col": 73, "end_line": 107, "start_col": 15, "start_line": 107 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test_le1 = assert (1.0R <=. 2.0R)
let test_le1 =
false
null
false
assert (1.0R <=. 2.0R)
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "Prims._assert", "Prims.b2t", "FStar.Real.op_Less_Equals_Dot" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two} let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n) let test = assert (two >. one) let test1 = assert (one = 1.0R) let test_lt1 = assert (1.0R <. 2.0R) let test_lt2 = assert (~ (1.0R <. 1.0R)) let test_lt3 = assert (~ (2.0R <. 1.0R))
false
true
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test_le1 : Prims.unit
[]
FStar.Real.test_le1
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.unit
{ "end_col": 37, "end_line": 66, "start_col": 15, "start_line": 66 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let add_assoc = assert (forall x y z. ((x +. y) +.z) = (x +. (y +. z)))
let add_assoc =
false
null
false
assert (forall x y z. ((x +. y) +. z) = (x +. (y +. z)))
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "Prims._assert", "Prims.l_Forall", "FStar.Real.real", "Prims.b2t", "Prims.op_Equality", "FStar.Real.op_Plus_Dot" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two} let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n) let test = assert (two >. one) let test1 = assert (one = 1.0R) let test_lt1 = assert (1.0R <. 2.0R) let test_lt2 = assert (~ (1.0R <. 1.0R)) let test_lt3 = assert (~ (2.0R <. 1.0R)) let test_le1 = assert (1.0R <=. 2.0R) let test_le2 = assert (1.0R <=. 1.0R) let test_le3 = assert (~ (2.0R <=. 1.0R)) let test_gt1 = assert (~ (1.0R >. 2.0R)) let test_gt2 = assert (~ (1.0R >. 1.0R)) let test_gt3 = assert (2.0R >. 1.0R) let test_ge1 = assert (~ (1.0R >=. 2.0R)) let test_ge2 = assert (1.0R >=. 1.0R) let test_ge3 = assert (2.0R >=. 1.0R) let test_add_eq = assert (1.0R +. 1.0R = 2.0R) let test_add_eq' = assert (1.0R +. 3.0R = 4.0R) let test_add_lt = assert (1.0R +. 1.0R <. 3.0R) let test_mul_eq = assert (2.0R *. 2.0R = 4.0R) let test_mul_lt = assert (2.0R *. 2.0R <. 5.0R) let test_div_eq = assert (8.0R /. 2.0R = 4.0R) let test_div_lt = assert (8.0R /. 2.0R <. 5.0R) let test_sqrt_2_mul = assert (sqrt_2 *. sqrt_2 = 2.0R) //let test_sqrt_2_add = assert (sqrt_2 +. sqrt_2 >. 2.0R) // Fails let test_sqrt_2_scale = assert (1.0R /. sqrt_2 = sqrt_2 /. 2.0R) // Common identities let add_id_l = assert (forall n. 0.0R +. n = n) let add_id_r = assert (forall n. n +. 0.0R = n) let mul_nil_l = assert (forall n. 0.0R *. n = 0.0R) let mul_nil_r = assert (forall n. n *. 0.0R = 0.0R) let mul_id_l = assert (forall n. 1.0R *. n = n) let mul_id_r = assert (forall n. n *. 1.0R = n)
false
true
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val add_assoc : Prims.unit
[]
FStar.Real.add_assoc
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.unit
{ "end_col": 71, "end_line": 103, "start_col": 16, "start_line": 103 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test_ge3 = assert (2.0R >=. 1.0R)
let test_ge3 =
false
null
false
assert (2.0R >=. 1.0R)
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "Prims._assert", "Prims.b2t", "FStar.Real.op_Greater_Equals_Dot" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two} let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n) let test = assert (two >. one) let test1 = assert (one = 1.0R) let test_lt1 = assert (1.0R <. 2.0R) let test_lt2 = assert (~ (1.0R <. 1.0R)) let test_lt3 = assert (~ (2.0R <. 1.0R)) let test_le1 = assert (1.0R <=. 2.0R) let test_le2 = assert (1.0R <=. 1.0R) let test_le3 = assert (~ (2.0R <=. 1.0R)) let test_gt1 = assert (~ (1.0R >. 2.0R)) let test_gt2 = assert (~ (1.0R >. 1.0R)) let test_gt3 = assert (2.0R >. 1.0R) let test_ge1 = assert (~ (1.0R >=. 2.0R))
false
true
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test_ge3 : Prims.unit
[]
FStar.Real.test_ge3
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.unit
{ "end_col": 37, "end_line": 76, "start_col": 15, "start_line": 76 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test_lt2 = assert (~ (1.0R <. 1.0R))
let test_lt2 =
false
null
false
assert (~(1.0R <. 1.0R))
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "Prims._assert", "Prims.l_not", "Prims.b2t", "FStar.Real.op_Less_Dot" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two} let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n) let test = assert (two >. one) let test1 = assert (one = 1.0R)
false
true
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test_lt2 : Prims.unit
[]
FStar.Real.test_lt2
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.unit
{ "end_col": 40, "end_line": 63, "start_col": 15, "start_line": 63 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test_add_lt = assert (1.0R +. 1.0R <. 3.0R)
let test_add_lt =
false
null
false
assert (1.0R +. 1.0R <. 3.0R)
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "Prims._assert", "Prims.b2t", "FStar.Real.op_Less_Dot", "FStar.Real.op_Plus_Dot" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two} let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n) let test = assert (two >. one) let test1 = assert (one = 1.0R) let test_lt1 = assert (1.0R <. 2.0R) let test_lt2 = assert (~ (1.0R <. 1.0R)) let test_lt3 = assert (~ (2.0R <. 1.0R)) let test_le1 = assert (1.0R <=. 2.0R) let test_le2 = assert (1.0R <=. 1.0R) let test_le3 = assert (~ (2.0R <=. 1.0R)) let test_gt1 = assert (~ (1.0R >. 2.0R)) let test_gt2 = assert (~ (1.0R >. 1.0R)) let test_gt3 = assert (2.0R >. 1.0R) let test_ge1 = assert (~ (1.0R >=. 2.0R)) let test_ge2 = assert (1.0R >=. 1.0R) let test_ge3 = assert (2.0R >=. 1.0R) let test_add_eq = assert (1.0R +. 1.0R = 2.0R)
false
true
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test_add_lt : Prims.unit
[]
FStar.Real.test_add_lt
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.unit
{ "end_col": 47, "end_line": 80, "start_col": 18, "start_line": 80 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let add_id_l = assert (forall n. 0.0R +. n = n)
let add_id_l =
false
null
false
assert (forall n. 0.0R +. n = n)
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "Prims._assert", "Prims.l_Forall", "FStar.Real.real", "Prims.b2t", "Prims.op_Equality", "FStar.Real.op_Plus_Dot" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two} let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n) let test = assert (two >. one) let test1 = assert (one = 1.0R) let test_lt1 = assert (1.0R <. 2.0R) let test_lt2 = assert (~ (1.0R <. 1.0R)) let test_lt3 = assert (~ (2.0R <. 1.0R)) let test_le1 = assert (1.0R <=. 2.0R) let test_le2 = assert (1.0R <=. 1.0R) let test_le3 = assert (~ (2.0R <=. 1.0R)) let test_gt1 = assert (~ (1.0R >. 2.0R)) let test_gt2 = assert (~ (1.0R >. 1.0R)) let test_gt3 = assert (2.0R >. 1.0R) let test_ge1 = assert (~ (1.0R >=. 2.0R)) let test_ge2 = assert (1.0R >=. 1.0R) let test_ge3 = assert (2.0R >=. 1.0R) let test_add_eq = assert (1.0R +. 1.0R = 2.0R) let test_add_eq' = assert (1.0R +. 3.0R = 4.0R) let test_add_lt = assert (1.0R +. 1.0R <. 3.0R) let test_mul_eq = assert (2.0R *. 2.0R = 4.0R) let test_mul_lt = assert (2.0R *. 2.0R <. 5.0R) let test_div_eq = assert (8.0R /. 2.0R = 4.0R) let test_div_lt = assert (8.0R /. 2.0R <. 5.0R) let test_sqrt_2_mul = assert (sqrt_2 *. sqrt_2 = 2.0R) //let test_sqrt_2_add = assert (sqrt_2 +. sqrt_2 >. 2.0R) // Fails let test_sqrt_2_scale = assert (1.0R /. sqrt_2 = sqrt_2 /. 2.0R)
false
true
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val add_id_l : Prims.unit
[]
FStar.Real.add_id_l
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.unit
{ "end_col": 47, "end_line": 93, "start_col": 15, "start_line": 93 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let add_id_r = assert (forall n. n +. 0.0R = n)
let add_id_r =
false
null
false
assert (forall n. n +. 0.0R = n)
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "Prims._assert", "Prims.l_Forall", "FStar.Real.real", "Prims.b2t", "Prims.op_Equality", "FStar.Real.op_Plus_Dot" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two} let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n) let test = assert (two >. one) let test1 = assert (one = 1.0R) let test_lt1 = assert (1.0R <. 2.0R) let test_lt2 = assert (~ (1.0R <. 1.0R)) let test_lt3 = assert (~ (2.0R <. 1.0R)) let test_le1 = assert (1.0R <=. 2.0R) let test_le2 = assert (1.0R <=. 1.0R) let test_le3 = assert (~ (2.0R <=. 1.0R)) let test_gt1 = assert (~ (1.0R >. 2.0R)) let test_gt2 = assert (~ (1.0R >. 1.0R)) let test_gt3 = assert (2.0R >. 1.0R) let test_ge1 = assert (~ (1.0R >=. 2.0R)) let test_ge2 = assert (1.0R >=. 1.0R) let test_ge3 = assert (2.0R >=. 1.0R) let test_add_eq = assert (1.0R +. 1.0R = 2.0R) let test_add_eq' = assert (1.0R +. 3.0R = 4.0R) let test_add_lt = assert (1.0R +. 1.0R <. 3.0R) let test_mul_eq = assert (2.0R *. 2.0R = 4.0R) let test_mul_lt = assert (2.0R *. 2.0R <. 5.0R) let test_div_eq = assert (8.0R /. 2.0R = 4.0R) let test_div_lt = assert (8.0R /. 2.0R <. 5.0R) let test_sqrt_2_mul = assert (sqrt_2 *. sqrt_2 = 2.0R) //let test_sqrt_2_add = assert (sqrt_2 +. sqrt_2 >. 2.0R) // Fails let test_sqrt_2_scale = assert (1.0R /. sqrt_2 = sqrt_2 /. 2.0R) // Common identities
false
true
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val add_id_r : Prims.unit
[]
FStar.Real.add_id_r
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.unit
{ "end_col": 47, "end_line": 94, "start_col": 15, "start_line": 94 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test = assert (two >. one)
let test =
false
null
false
assert (two >. one)
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "Prims._assert", "Prims.b2t", "FStar.Real.op_Greater_Dot", "FStar.Real.two", "FStar.Real.one" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two} let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n)
false
true
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test : Prims.unit
[]
FStar.Real.test
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.unit
{ "end_col": 30, "end_line": 59, "start_col": 11, "start_line": 59 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test_ge2 = assert (1.0R >=. 1.0R)
let test_ge2 =
false
null
false
assert (1.0R >=. 1.0R)
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "Prims._assert", "Prims.b2t", "FStar.Real.op_Greater_Equals_Dot" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two} let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n) let test = assert (two >. one) let test1 = assert (one = 1.0R) let test_lt1 = assert (1.0R <. 2.0R) let test_lt2 = assert (~ (1.0R <. 1.0R)) let test_lt3 = assert (~ (2.0R <. 1.0R)) let test_le1 = assert (1.0R <=. 2.0R) let test_le2 = assert (1.0R <=. 1.0R) let test_le3 = assert (~ (2.0R <=. 1.0R)) let test_gt1 = assert (~ (1.0R >. 2.0R)) let test_gt2 = assert (~ (1.0R >. 1.0R)) let test_gt3 = assert (2.0R >. 1.0R)
false
true
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test_ge2 : Prims.unit
[]
FStar.Real.test_ge2
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.unit
{ "end_col": 37, "end_line": 75, "start_col": 15, "start_line": 75 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test_gt3 = assert (2.0R >. 1.0R)
let test_gt3 =
false
null
false
assert (2.0R >. 1.0R)
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "Prims._assert", "Prims.b2t", "FStar.Real.op_Greater_Dot" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two} let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n) let test = assert (two >. one) let test1 = assert (one = 1.0R) let test_lt1 = assert (1.0R <. 2.0R) let test_lt2 = assert (~ (1.0R <. 1.0R)) let test_lt3 = assert (~ (2.0R <. 1.0R)) let test_le1 = assert (1.0R <=. 2.0R) let test_le2 = assert (1.0R <=. 1.0R) let test_le3 = assert (~ (2.0R <=. 1.0R)) let test_gt1 = assert (~ (1.0R >. 2.0R))
false
true
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test_gt3 : Prims.unit
[]
FStar.Real.test_gt3
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.unit
{ "end_col": 36, "end_line": 72, "start_col": 15, "start_line": 72 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test_div_eq = assert (8.0R /. 2.0R = 4.0R)
let test_div_eq =
false
null
false
assert (8.0R /. 2.0R = 4.0R)
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "Prims._assert", "Prims.b2t", "Prims.op_Equality", "FStar.Real.real", "FStar.Real.op_Slash_Dot" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two} let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n) let test = assert (two >. one) let test1 = assert (one = 1.0R) let test_lt1 = assert (1.0R <. 2.0R) let test_lt2 = assert (~ (1.0R <. 1.0R)) let test_lt3 = assert (~ (2.0R <. 1.0R)) let test_le1 = assert (1.0R <=. 2.0R) let test_le2 = assert (1.0R <=. 1.0R) let test_le3 = assert (~ (2.0R <=. 1.0R)) let test_gt1 = assert (~ (1.0R >. 2.0R)) let test_gt2 = assert (~ (1.0R >. 1.0R)) let test_gt3 = assert (2.0R >. 1.0R) let test_ge1 = assert (~ (1.0R >=. 2.0R)) let test_ge2 = assert (1.0R >=. 1.0R) let test_ge3 = assert (2.0R >=. 1.0R) let test_add_eq = assert (1.0R +. 1.0R = 2.0R) let test_add_eq' = assert (1.0R +. 3.0R = 4.0R) let test_add_lt = assert (1.0R +. 1.0R <. 3.0R) let test_mul_eq = assert (2.0R *. 2.0R = 4.0R) let test_mul_lt = assert (2.0R *. 2.0R <. 5.0R)
false
true
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test_div_eq : Prims.unit
[]
FStar.Real.test_div_eq
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.unit
{ "end_col": 46, "end_line": 85, "start_col": 18, "start_line": 85 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test_sqrt_2_mul = assert (sqrt_2 *. sqrt_2 = 2.0R)
let test_sqrt_2_mul =
false
null
false
assert (sqrt_2 *. sqrt_2 = 2.0R)
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "Prims._assert", "Prims.b2t", "Prims.op_Equality", "FStar.Real.real", "FStar.Real.op_Star_Dot", "FStar.Real.sqrt_2" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two} let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n) let test = assert (two >. one) let test1 = assert (one = 1.0R) let test_lt1 = assert (1.0R <. 2.0R) let test_lt2 = assert (~ (1.0R <. 1.0R)) let test_lt3 = assert (~ (2.0R <. 1.0R)) let test_le1 = assert (1.0R <=. 2.0R) let test_le2 = assert (1.0R <=. 1.0R) let test_le3 = assert (~ (2.0R <=. 1.0R)) let test_gt1 = assert (~ (1.0R >. 2.0R)) let test_gt2 = assert (~ (1.0R >. 1.0R)) let test_gt3 = assert (2.0R >. 1.0R) let test_ge1 = assert (~ (1.0R >=. 2.0R)) let test_ge2 = assert (1.0R >=. 1.0R) let test_ge3 = assert (2.0R >=. 1.0R) let test_add_eq = assert (1.0R +. 1.0R = 2.0R) let test_add_eq' = assert (1.0R +. 3.0R = 4.0R) let test_add_lt = assert (1.0R +. 1.0R <. 3.0R) let test_mul_eq = assert (2.0R *. 2.0R = 4.0R) let test_mul_lt = assert (2.0R *. 2.0R <. 5.0R) let test_div_eq = assert (8.0R /. 2.0R = 4.0R) let test_div_lt = assert (8.0R /. 2.0R <. 5.0R)
false
true
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test_sqrt_2_mul : Prims.unit
[]
FStar.Real.test_sqrt_2_mul
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.unit
{ "end_col": 54, "end_line": 88, "start_col": 22, "start_line": 88 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mul_assoc = assert (forall x y z. ((x *. y) *.z) = (x *. (y *. z)))
let mul_assoc =
false
null
false
assert (forall x y z. ((x *. y) *. z) = (x *. (y *. z)))
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "Prims._assert", "Prims.l_Forall", "FStar.Real.real", "Prims.b2t", "Prims.op_Equality", "FStar.Real.op_Star_Dot" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two} let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n) let test = assert (two >. one) let test1 = assert (one = 1.0R) let test_lt1 = assert (1.0R <. 2.0R) let test_lt2 = assert (~ (1.0R <. 1.0R)) let test_lt3 = assert (~ (2.0R <. 1.0R)) let test_le1 = assert (1.0R <=. 2.0R) let test_le2 = assert (1.0R <=. 1.0R) let test_le3 = assert (~ (2.0R <=. 1.0R)) let test_gt1 = assert (~ (1.0R >. 2.0R)) let test_gt2 = assert (~ (1.0R >. 1.0R)) let test_gt3 = assert (2.0R >. 1.0R) let test_ge1 = assert (~ (1.0R >=. 2.0R)) let test_ge2 = assert (1.0R >=. 1.0R) let test_ge3 = assert (2.0R >=. 1.0R) let test_add_eq = assert (1.0R +. 1.0R = 2.0R) let test_add_eq' = assert (1.0R +. 3.0R = 4.0R) let test_add_lt = assert (1.0R +. 1.0R <. 3.0R) let test_mul_eq = assert (2.0R *. 2.0R = 4.0R) let test_mul_lt = assert (2.0R *. 2.0R <. 5.0R) let test_div_eq = assert (8.0R /. 2.0R = 4.0R) let test_div_lt = assert (8.0R /. 2.0R <. 5.0R) let test_sqrt_2_mul = assert (sqrt_2 *. sqrt_2 = 2.0R) //let test_sqrt_2_add = assert (sqrt_2 +. sqrt_2 >. 2.0R) // Fails let test_sqrt_2_scale = assert (1.0R /. sqrt_2 = sqrt_2 /. 2.0R) // Common identities let add_id_l = assert (forall n. 0.0R +. n = n) let add_id_r = assert (forall n. n +. 0.0R = n) let mul_nil_l = assert (forall n. 0.0R *. n = 0.0R) let mul_nil_r = assert (forall n. n *. 0.0R = 0.0R) let mul_id_l = assert (forall n. 1.0R *. n = n) let mul_id_r = assert (forall n. n *. 1.0R = n) let add_comm = assert (forall x y. x +. y = y +.x) let add_assoc = assert (forall x y z. ((x +. y) +.z) = (x +. (y +. z)))
false
true
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mul_assoc : Prims.unit
[]
FStar.Real.mul_assoc
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.unit
{ "end_col": 71, "end_line": 106, "start_col": 16, "start_line": 106 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mul_id_l = assert (forall n. 1.0R *. n = n)
let mul_id_l =
false
null
false
assert (forall n. 1.0R *. n = n)
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "Prims._assert", "Prims.l_Forall", "FStar.Real.real", "Prims.b2t", "Prims.op_Equality", "FStar.Real.op_Star_Dot" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two} let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n) let test = assert (two >. one) let test1 = assert (one = 1.0R) let test_lt1 = assert (1.0R <. 2.0R) let test_lt2 = assert (~ (1.0R <. 1.0R)) let test_lt3 = assert (~ (2.0R <. 1.0R)) let test_le1 = assert (1.0R <=. 2.0R) let test_le2 = assert (1.0R <=. 1.0R) let test_le3 = assert (~ (2.0R <=. 1.0R)) let test_gt1 = assert (~ (1.0R >. 2.0R)) let test_gt2 = assert (~ (1.0R >. 1.0R)) let test_gt3 = assert (2.0R >. 1.0R) let test_ge1 = assert (~ (1.0R >=. 2.0R)) let test_ge2 = assert (1.0R >=. 1.0R) let test_ge3 = assert (2.0R >=. 1.0R) let test_add_eq = assert (1.0R +. 1.0R = 2.0R) let test_add_eq' = assert (1.0R +. 3.0R = 4.0R) let test_add_lt = assert (1.0R +. 1.0R <. 3.0R) let test_mul_eq = assert (2.0R *. 2.0R = 4.0R) let test_mul_lt = assert (2.0R *. 2.0R <. 5.0R) let test_div_eq = assert (8.0R /. 2.0R = 4.0R) let test_div_lt = assert (8.0R /. 2.0R <. 5.0R) let test_sqrt_2_mul = assert (sqrt_2 *. sqrt_2 = 2.0R) //let test_sqrt_2_add = assert (sqrt_2 +. sqrt_2 >. 2.0R) // Fails let test_sqrt_2_scale = assert (1.0R /. sqrt_2 = sqrt_2 /. 2.0R) // Common identities let add_id_l = assert (forall n. 0.0R +. n = n) let add_id_r = assert (forall n. n +. 0.0R = n) let mul_nil_l = assert (forall n. 0.0R *. n = 0.0R) let mul_nil_r = assert (forall n. n *. 0.0R = 0.0R)
false
true
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mul_id_l : Prims.unit
[]
FStar.Real.mul_id_l
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.unit
{ "end_col": 47, "end_line": 99, "start_col": 15, "start_line": 99 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test_le2 = assert (1.0R <=. 1.0R)
let test_le2 =
false
null
false
assert (1.0R <=. 1.0R)
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "Prims._assert", "Prims.b2t", "FStar.Real.op_Less_Equals_Dot" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two} let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n) let test = assert (two >. one) let test1 = assert (one = 1.0R) let test_lt1 = assert (1.0R <. 2.0R) let test_lt2 = assert (~ (1.0R <. 1.0R)) let test_lt3 = assert (~ (2.0R <. 1.0R))
false
true
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test_le2 : Prims.unit
[]
FStar.Real.test_le2
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.unit
{ "end_col": 37, "end_line": 67, "start_col": 15, "start_line": 67 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n)
let n_over_n2 (n: real{n <> 0.0R /\ n *. n <> 0.0R}) =
false
null
false
assert (n /. (n *. n) == 1.0R /. n)
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "FStar.Real.real", "Prims.l_and", "Prims.b2t", "Prims.op_disEquality", "FStar.Real.op_Star_Dot", "Prims._assert", "Prims.eq2", "FStar.Real.op_Slash_Dot", "Prims.unit" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two}
false
false
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val n_over_n2 : n: FStar.Real.real{n <> 0.0R /\ n *. n <> 0.0R} -> Prims.unit
[]
FStar.Real.n_over_n2
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
n: FStar.Real.real{n <> 0.0R /\ n *. n <> 0.0R} -> Prims.unit
{ "end_col": 87, "end_line": 57, "start_col": 52, "start_line": 57 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mul_id_r = assert (forall n. n *. 1.0R = n)
let mul_id_r =
false
null
false
assert (forall n. n *. 1.0R = n)
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "Prims._assert", "Prims.l_Forall", "FStar.Real.real", "Prims.b2t", "Prims.op_Equality", "FStar.Real.op_Star_Dot" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two} let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n) let test = assert (two >. one) let test1 = assert (one = 1.0R) let test_lt1 = assert (1.0R <. 2.0R) let test_lt2 = assert (~ (1.0R <. 1.0R)) let test_lt3 = assert (~ (2.0R <. 1.0R)) let test_le1 = assert (1.0R <=. 2.0R) let test_le2 = assert (1.0R <=. 1.0R) let test_le3 = assert (~ (2.0R <=. 1.0R)) let test_gt1 = assert (~ (1.0R >. 2.0R)) let test_gt2 = assert (~ (1.0R >. 1.0R)) let test_gt3 = assert (2.0R >. 1.0R) let test_ge1 = assert (~ (1.0R >=. 2.0R)) let test_ge2 = assert (1.0R >=. 1.0R) let test_ge3 = assert (2.0R >=. 1.0R) let test_add_eq = assert (1.0R +. 1.0R = 2.0R) let test_add_eq' = assert (1.0R +. 3.0R = 4.0R) let test_add_lt = assert (1.0R +. 1.0R <. 3.0R) let test_mul_eq = assert (2.0R *. 2.0R = 4.0R) let test_mul_lt = assert (2.0R *. 2.0R <. 5.0R) let test_div_eq = assert (8.0R /. 2.0R = 4.0R) let test_div_lt = assert (8.0R /. 2.0R <. 5.0R) let test_sqrt_2_mul = assert (sqrt_2 *. sqrt_2 = 2.0R) //let test_sqrt_2_add = assert (sqrt_2 +. sqrt_2 >. 2.0R) // Fails let test_sqrt_2_scale = assert (1.0R /. sqrt_2 = sqrt_2 /. 2.0R) // Common identities let add_id_l = assert (forall n. 0.0R +. n = n) let add_id_r = assert (forall n. n +. 0.0R = n) let mul_nil_l = assert (forall n. 0.0R *. n = 0.0R) let mul_nil_r = assert (forall n. n *. 0.0R = 0.0R)
false
true
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mul_id_r : Prims.unit
[]
FStar.Real.mul_id_r
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.unit
{ "end_col": 47, "end_line": 100, "start_col": 15, "start_line": 100 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let test1 = assert (one = 1.0R)
let test1 =
false
null
false
assert (one = 1.0R)
{ "checked_file": "FStar.Real.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Real.fsti" }
[ "total" ]
[ "Prims._assert", "Prims.b2t", "Prims.op_Equality", "FStar.Real.real", "FStar.Real.one" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Real (* This module provides a signature for real arithmetic. Real number constants can be specific in floating point format with an 'R' suffix, e.g., 1.0R All these operations are mapped to the corresponding primitives in Z3's theory of real arithmetic. *) val real : eqtype val of_int : int -> Tot real (** Used to extract real constants; this function is uninterpreted logically. i.e., 1.1R is extracted to [of_string "1.1"] *) val of_string: string -> Tot real val ( +. ) : real -> real -> Tot real val ( -. ) : real -> real -> Tot real val ( *. ) : real -> real -> Tot real val ( /. ) : real -> d:real{d <> 0.0R} -> Tot real val ( >. ) : real -> real -> Tot bool val ( >=. ) : real -> real -> Tot bool val ( <. ) : real -> real -> Tot bool val ( <=. ) : real -> real -> Tot bool #reset-options "--smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native" //Tests let zero : real = of_int 0 let one : real = of_int 1 let two : real = of_int 2 val sqrt_2 : r:real{r *. r = two} let n_over_n2 (n:real{n <> 0.0R /\ n*.n <> 0.0R}) = assert (n /. (n *. n) == 1.0R /. n)
false
true
FStar.Real.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val test1 : Prims.unit
[]
FStar.Real.test1
{ "file_name": "ulib/FStar.Real.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.unit
{ "end_col": 31, "end_line": 60, "start_col": 12, "start_line": 60 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.Curve25519", "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": "Hacl.Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.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 } ]
false
let montgomery_ladder1_1 (nq:proj_point) = let nq = double nq in let nq = double nq in let nq = double nq in nq
let montgomery_ladder1_1 (nq: proj_point) =
false
null
false
let nq = double nq in let nq = double nq in let nq = double nq in nq
{ "checked_file": "Hacl.Spec.Curve25519.AddAndDouble.fst.checked", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Curve25519.AddAndDouble.fst" }
[ "total" ]
[ "Spec.Curve25519.proj_point", "FStar.Pervasives.Native.tuple2", "Spec.Curve25519.elem", "Spec.Curve25519.double" ]
[]
module Hacl.Spec.Curve25519.AddAndDouble open FStar.Mul open Lib.IntTypes open Spec.Curve25519 let add_and_double1_0 a b nqp1 = let x_3, z_3 = nqp1 in let c = x_3 +% z_3 in let d = x_3 -% z_3 in let da = d *% a in let cb = c *% b in let x_3 = da +% cb in let z_3 = da -% cb in (x_3, z_3) let add_and_double1_1 a b nqp1 = let x_3, z_3 = nqp1 in let aa = a *% a in let bb = b *% b in let x_3 = x_3 *% x_3 in let z_3 = z_3 *% z_3 in let e = aa -% bb in let e121665 = e *% 121665 in let aa_e121665 = e121665 +% aa in let x_2 = aa *% bb in let z_2 = e *% aa_e121665 in (x_2, z_2), (x_3, z_3) let add_and_double1 q nq nqp1 = let x_1, z_1 = q in let x_2, z_2 = nq in let a = x_2 +% z_2 in let b = x_2 -% z_2 in let nqp1 = add_and_double1_0 a b nqp1 in let (x_2, z_2), (x_3, z_3) = add_and_double1_1 a b nqp1 in let z_3 = z_3 *% x_1 in (x_2, z_2), (x_3, z_3) val lemma_add_and_double: q:proj_point -> nq:proj_point -> nqp1:proj_point -> Lemma (add_and_double1 q nq nqp1 == add_and_double q nq nqp1) let lemma_add_and_double q nq nqp1 = () let montgomery_ladder1_0 (k:scalar) (q:proj_point) (nq:proj_point) (nqp1:proj_point) = // bit 255 is 0 and bit 254 is 1 let nq,nqp1 = cswap2 (u64 1) nq nqp1 in let nq,nqp1 = add_and_double q nq nqp1 in let swap = u64 1 in let nq,nqp1,swap = Lib.LoopCombinators.repeati 251 (ladder_step k q) (nq, nqp1, swap) in let nq,nqp1 = cswap2 swap nq nqp1 in nq
false
true
Hacl.Spec.Curve25519.AddAndDouble.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val montgomery_ladder1_1 : nq: Spec.Curve25519.proj_point -> Spec.Curve25519.elem * Spec.Curve25519.elem
[]
Hacl.Spec.Curve25519.AddAndDouble.montgomery_ladder1_1
{ "file_name": "code/curve25519/Hacl.Spec.Curve25519.AddAndDouble.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
nq: Spec.Curve25519.proj_point -> Spec.Curve25519.elem * Spec.Curve25519.elem
{ "end_col": 4, "end_line": 61, "start_col": 42, "start_line": 57 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.Curve25519", "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": "Hacl.Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.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 } ]
false
let montgomery_ladder1_2 (init:elem) = let q = (init, one) in let nq = (one, zero) in let nqp1 = (init, one) in q, nq, nqp1
let montgomery_ladder1_2 (init: elem) =
false
null
false
let q = (init, one) in let nq = (one, zero) in let nqp1 = (init, one) in q, nq, nqp1
{ "checked_file": "Hacl.Spec.Curve25519.AddAndDouble.fst.checked", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Curve25519.AddAndDouble.fst" }
[ "total" ]
[ "Spec.Curve25519.elem", "FStar.Pervasives.Native.Mktuple3", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "Spec.Curve25519.one", "Spec.Curve25519.zero", "FStar.Pervasives.Native.tuple3" ]
[]
module Hacl.Spec.Curve25519.AddAndDouble open FStar.Mul open Lib.IntTypes open Spec.Curve25519 let add_and_double1_0 a b nqp1 = let x_3, z_3 = nqp1 in let c = x_3 +% z_3 in let d = x_3 -% z_3 in let da = d *% a in let cb = c *% b in let x_3 = da +% cb in let z_3 = da -% cb in (x_3, z_3) let add_and_double1_1 a b nqp1 = let x_3, z_3 = nqp1 in let aa = a *% a in let bb = b *% b in let x_3 = x_3 *% x_3 in let z_3 = z_3 *% z_3 in let e = aa -% bb in let e121665 = e *% 121665 in let aa_e121665 = e121665 +% aa in let x_2 = aa *% bb in let z_2 = e *% aa_e121665 in (x_2, z_2), (x_3, z_3) let add_and_double1 q nq nqp1 = let x_1, z_1 = q in let x_2, z_2 = nq in let a = x_2 +% z_2 in let b = x_2 -% z_2 in let nqp1 = add_and_double1_0 a b nqp1 in let (x_2, z_2), (x_3, z_3) = add_and_double1_1 a b nqp1 in let z_3 = z_3 *% x_1 in (x_2, z_2), (x_3, z_3) val lemma_add_and_double: q:proj_point -> nq:proj_point -> nqp1:proj_point -> Lemma (add_and_double1 q nq nqp1 == add_and_double q nq nqp1) let lemma_add_and_double q nq nqp1 = () let montgomery_ladder1_0 (k:scalar) (q:proj_point) (nq:proj_point) (nqp1:proj_point) = // bit 255 is 0 and bit 254 is 1 let nq,nqp1 = cswap2 (u64 1) nq nqp1 in let nq,nqp1 = add_and_double q nq nqp1 in let swap = u64 1 in let nq,nqp1,swap = Lib.LoopCombinators.repeati 251 (ladder_step k q) (nq, nqp1, swap) in let nq,nqp1 = cswap2 swap nq nqp1 in nq let montgomery_ladder1_1 (nq:proj_point) = let nq = double nq in let nq = double nq in let nq = double nq in nq
false
true
Hacl.Spec.Curve25519.AddAndDouble.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val montgomery_ladder1_2 : init: Spec.Curve25519.elem -> ((Spec.Curve25519.elem * Spec.Curve25519.elem) * (Spec.Curve25519.elem * Spec.Curve25519.elem)) * (Spec.Curve25519.elem * Spec.Curve25519.elem)
[]
Hacl.Spec.Curve25519.AddAndDouble.montgomery_ladder1_2
{ "file_name": "code/curve25519/Hacl.Spec.Curve25519.AddAndDouble.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
init: Spec.Curve25519.elem -> ((Spec.Curve25519.elem * Spec.Curve25519.elem) * (Spec.Curve25519.elem * Spec.Curve25519.elem)) * (Spec.Curve25519.elem * Spec.Curve25519.elem)
{ "end_col": 13, "end_line": 67, "start_col": 38, "start_line": 63 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.Curve25519", "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": "Hacl.Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.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 } ]
false
let add_and_double1_0 a b nqp1 = let x_3, z_3 = nqp1 in let c = x_3 +% z_3 in let d = x_3 -% z_3 in let da = d *% a in let cb = c *% b in let x_3 = da +% cb in let z_3 = da -% cb in (x_3, z_3)
let add_and_double1_0 a b nqp1 =
false
null
false
let x_3, z_3 = nqp1 in let c = x_3 +% z_3 in let d = x_3 -% z_3 in let da = d *% a in let cb = c *% b in let x_3 = da +% cb in let z_3 = da -% cb in (x_3, z_3)
{ "checked_file": "Hacl.Spec.Curve25519.AddAndDouble.fst.checked", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Curve25519.AddAndDouble.fst" }
[ "total" ]
[ "Spec.Curve25519.elem", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "Spec.Curve25519.op_Subtraction_Percent", "Spec.Curve25519.op_Plus_Percent", "Spec.Curve25519.op_Star_Percent" ]
[]
module Hacl.Spec.Curve25519.AddAndDouble open FStar.Mul open Lib.IntTypes open Spec.Curve25519
false
true
Hacl.Spec.Curve25519.AddAndDouble.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val add_and_double1_0 : a: Spec.Curve25519.elem -> b: Spec.Curve25519.elem -> nqp1: (Spec.Curve25519.elem * Spec.Curve25519.elem) -> Spec.Curve25519.elem * Spec.Curve25519.elem
[]
Hacl.Spec.Curve25519.AddAndDouble.add_and_double1_0
{ "file_name": "code/curve25519/Hacl.Spec.Curve25519.AddAndDouble.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Curve25519.elem -> b: Spec.Curve25519.elem -> nqp1: (Spec.Curve25519.elem * Spec.Curve25519.elem) -> Spec.Curve25519.elem * Spec.Curve25519.elem
{ "end_col": 12, "end_line": 16, "start_col": 32, "start_line": 7 }
Prims.Tot
val montgomery_ladder1 (init: elem) (k: scalar) : Tot proj_point
[ { "abbrev": false, "full_module": "Spec.Curve25519", "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": "Hacl.Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.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 } ]
false
let montgomery_ladder1 (init:elem) (k:scalar) : Tot proj_point = let q, nq, nqp1 = montgomery_ladder1_2 init in let nq = montgomery_ladder1_0 k q nq nqp1 in montgomery_ladder1_1 nq
val montgomery_ladder1 (init: elem) (k: scalar) : Tot proj_point let montgomery_ladder1 (init: elem) (k: scalar) : Tot proj_point =
false
null
false
let q, nq, nqp1 = montgomery_ladder1_2 init in let nq = montgomery_ladder1_0 k q nq nqp1 in montgomery_ladder1_1 nq
{ "checked_file": "Hacl.Spec.Curve25519.AddAndDouble.fst.checked", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Curve25519.AddAndDouble.fst" }
[ "total" ]
[ "Spec.Curve25519.elem", "Spec.Curve25519.scalar", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Curve25519.AddAndDouble.montgomery_ladder1_1", "Spec.Curve25519.proj_point", "Hacl.Spec.Curve25519.AddAndDouble.montgomery_ladder1_0", "FStar.Pervasives.Native.tuple3", "Hacl.Spec.Curve25519.AddAndDouble.montgomery_ladder1_2" ]
[]
module Hacl.Spec.Curve25519.AddAndDouble open FStar.Mul open Lib.IntTypes open Spec.Curve25519 let add_and_double1_0 a b nqp1 = let x_3, z_3 = nqp1 in let c = x_3 +% z_3 in let d = x_3 -% z_3 in let da = d *% a in let cb = c *% b in let x_3 = da +% cb in let z_3 = da -% cb in (x_3, z_3) let add_and_double1_1 a b nqp1 = let x_3, z_3 = nqp1 in let aa = a *% a in let bb = b *% b in let x_3 = x_3 *% x_3 in let z_3 = z_3 *% z_3 in let e = aa -% bb in let e121665 = e *% 121665 in let aa_e121665 = e121665 +% aa in let x_2 = aa *% bb in let z_2 = e *% aa_e121665 in (x_2, z_2), (x_3, z_3) let add_and_double1 q nq nqp1 = let x_1, z_1 = q in let x_2, z_2 = nq in let a = x_2 +% z_2 in let b = x_2 -% z_2 in let nqp1 = add_and_double1_0 a b nqp1 in let (x_2, z_2), (x_3, z_3) = add_and_double1_1 a b nqp1 in let z_3 = z_3 *% x_1 in (x_2, z_2), (x_3, z_3) val lemma_add_and_double: q:proj_point -> nq:proj_point -> nqp1:proj_point -> Lemma (add_and_double1 q nq nqp1 == add_and_double q nq nqp1) let lemma_add_and_double q nq nqp1 = () let montgomery_ladder1_0 (k:scalar) (q:proj_point) (nq:proj_point) (nqp1:proj_point) = // bit 255 is 0 and bit 254 is 1 let nq,nqp1 = cswap2 (u64 1) nq nqp1 in let nq,nqp1 = add_and_double q nq nqp1 in let swap = u64 1 in let nq,nqp1,swap = Lib.LoopCombinators.repeati 251 (ladder_step k q) (nq, nqp1, swap) in let nq,nqp1 = cswap2 swap nq nqp1 in nq let montgomery_ladder1_1 (nq:proj_point) = let nq = double nq in let nq = double nq in let nq = double nq in nq let montgomery_ladder1_2 (init:elem) = let q = (init, one) in let nq = (one, zero) in let nqp1 = (init, one) in q, nq, nqp1
false
true
Hacl.Spec.Curve25519.AddAndDouble.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val montgomery_ladder1 (init: elem) (k: scalar) : Tot proj_point
[]
Hacl.Spec.Curve25519.AddAndDouble.montgomery_ladder1
{ "file_name": "code/curve25519/Hacl.Spec.Curve25519.AddAndDouble.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
init: Spec.Curve25519.elem -> k: Spec.Curve25519.scalar -> Spec.Curve25519.proj_point
{ "end_col": 25, "end_line": 72, "start_col": 64, "start_line": 69 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.Curve25519", "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": "Hacl.Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.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 } ]
false
let add_and_double1 q nq nqp1 = let x_1, z_1 = q in let x_2, z_2 = nq in let a = x_2 +% z_2 in let b = x_2 -% z_2 in let nqp1 = add_and_double1_0 a b nqp1 in let (x_2, z_2), (x_3, z_3) = add_and_double1_1 a b nqp1 in let z_3 = z_3 *% x_1 in (x_2, z_2), (x_3, z_3)
let add_and_double1 q nq nqp1 =
false
null
false
let x_1, z_1 = q in let x_2, z_2 = nq in let a = x_2 +% z_2 in let b = x_2 -% z_2 in let nqp1 = add_and_double1_0 a b nqp1 in let (x_2, z_2), (x_3, z_3) = add_and_double1_1 a b nqp1 in let z_3 = z_3 *% x_1 in (x_2, z_2), (x_3, z_3)
{ "checked_file": "Hacl.Spec.Curve25519.AddAndDouble.fst.checked", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Curve25519.AddAndDouble.fst" }
[ "total" ]
[ "FStar.Pervasives.Native.tuple2", "Spec.Curve25519.elem", "FStar.Pervasives.Native.Mktuple2", "Spec.Curve25519.op_Star_Percent", "Hacl.Spec.Curve25519.AddAndDouble.add_and_double1_1", "Hacl.Spec.Curve25519.AddAndDouble.add_and_double1_0", "Spec.Curve25519.op_Subtraction_Percent", "Spec.Curve25519.op_Plus_Percent" ]
[]
module Hacl.Spec.Curve25519.AddAndDouble open FStar.Mul open Lib.IntTypes open Spec.Curve25519 let add_and_double1_0 a b nqp1 = let x_3, z_3 = nqp1 in let c = x_3 +% z_3 in let d = x_3 -% z_3 in let da = d *% a in let cb = c *% b in let x_3 = da +% cb in let z_3 = da -% cb in (x_3, z_3) let add_and_double1_1 a b nqp1 = let x_3, z_3 = nqp1 in let aa = a *% a in let bb = b *% b in let x_3 = x_3 *% x_3 in let z_3 = z_3 *% z_3 in let e = aa -% bb in let e121665 = e *% 121665 in let aa_e121665 = e121665 +% aa in let x_2 = aa *% bb in let z_2 = e *% aa_e121665 in (x_2, z_2), (x_3, z_3)
false
false
Hacl.Spec.Curve25519.AddAndDouble.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val add_and_double1 : q: (Spec.Curve25519.elem * _) -> nq: (Spec.Curve25519.elem * Spec.Curve25519.elem) -> nqp1: (Spec.Curve25519.elem * Spec.Curve25519.elem) -> (Spec.Curve25519.elem * Spec.Curve25519.elem) * (Spec.Curve25519.elem * Spec.Curve25519.elem)
[]
Hacl.Spec.Curve25519.AddAndDouble.add_and_double1
{ "file_name": "code/curve25519/Hacl.Spec.Curve25519.AddAndDouble.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
q: (Spec.Curve25519.elem * _) -> nq: (Spec.Curve25519.elem * Spec.Curve25519.elem) -> nqp1: (Spec.Curve25519.elem * Spec.Curve25519.elem) -> (Spec.Curve25519.elem * Spec.Curve25519.elem) * (Spec.Curve25519.elem * Spec.Curve25519.elem)
{ "end_col": 24, "end_line": 41, "start_col": 31, "start_line": 33 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.Curve25519", "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": "Hacl.Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.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 } ]
false
let add_and_double1_1 a b nqp1 = let x_3, z_3 = nqp1 in let aa = a *% a in let bb = b *% b in let x_3 = x_3 *% x_3 in let z_3 = z_3 *% z_3 in let e = aa -% bb in let e121665 = e *% 121665 in let aa_e121665 = e121665 +% aa in let x_2 = aa *% bb in let z_2 = e *% aa_e121665 in (x_2, z_2), (x_3, z_3)
let add_and_double1_1 a b nqp1 =
false
null
false
let x_3, z_3 = nqp1 in let aa = a *% a in let bb = b *% b in let x_3 = x_3 *% x_3 in let z_3 = z_3 *% z_3 in let e = aa -% bb in let e121665 = e *% 121665 in let aa_e121665 = e121665 +% aa in let x_2 = aa *% bb in let z_2 = e *% aa_e121665 in (x_2, z_2), (x_3, z_3)
{ "checked_file": "Hacl.Spec.Curve25519.AddAndDouble.fst.checked", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Curve25519.AddAndDouble.fst" }
[ "total" ]
[ "Spec.Curve25519.elem", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "Spec.Curve25519.op_Star_Percent", "Spec.Curve25519.op_Plus_Percent", "Spec.Curve25519.op_Subtraction_Percent" ]
[]
module Hacl.Spec.Curve25519.AddAndDouble open FStar.Mul open Lib.IntTypes open Spec.Curve25519 let add_and_double1_0 a b nqp1 = let x_3, z_3 = nqp1 in let c = x_3 +% z_3 in let d = x_3 -% z_3 in let da = d *% a in let cb = c *% b in let x_3 = da +% cb in let z_3 = da -% cb in (x_3, z_3)
false
true
Hacl.Spec.Curve25519.AddAndDouble.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val add_and_double1_1 : a: Spec.Curve25519.elem -> b: Spec.Curve25519.elem -> nqp1: (Spec.Curve25519.elem * Spec.Curve25519.elem) -> (Spec.Curve25519.elem * Spec.Curve25519.elem) * (Spec.Curve25519.elem * Spec.Curve25519.elem)
[]
Hacl.Spec.Curve25519.AddAndDouble.add_and_double1_1
{ "file_name": "code/curve25519/Hacl.Spec.Curve25519.AddAndDouble.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Curve25519.elem -> b: Spec.Curve25519.elem -> nqp1: (Spec.Curve25519.elem * Spec.Curve25519.elem) -> (Spec.Curve25519.elem * Spec.Curve25519.elem) * (Spec.Curve25519.elem * Spec.Curve25519.elem)
{ "end_col": 24, "end_line": 31, "start_col": 32, "start_line": 18 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.Curve25519", "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": "Hacl.Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.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 } ]
false
let montgomery_ladder1_0 (k:scalar) (q:proj_point) (nq:proj_point) (nqp1:proj_point) = // bit 255 is 0 and bit 254 is 1 let nq,nqp1 = cswap2 (u64 1) nq nqp1 in let nq,nqp1 = add_and_double q nq nqp1 in let swap = u64 1 in let nq,nqp1,swap = Lib.LoopCombinators.repeati 251 (ladder_step k q) (nq, nqp1, swap) in let nq,nqp1 = cswap2 swap nq nqp1 in nq
let montgomery_ladder1_0 (k: scalar) (q nq nqp1: proj_point) =
false
null
false
let nq, nqp1 = cswap2 (u64 1) nq nqp1 in let nq, nqp1 = add_and_double q nq nqp1 in let swap = u64 1 in let nq, nqp1, swap = Lib.LoopCombinators.repeati 251 (ladder_step k q) (nq, nqp1, swap) in let nq, nqp1 = cswap2 swap nq nqp1 in nq
{ "checked_file": "Hacl.Spec.Curve25519.AddAndDouble.fst.checked", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Curve25519.AddAndDouble.fst" }
[ "total" ]
[ "Spec.Curve25519.scalar", "Spec.Curve25519.proj_point", "FStar.Pervasives.Native.tuple2", "Spec.Curve25519.elem", "Lib.IntTypes.uint64", "Spec.Curve25519.cswap2", "FStar.Pervasives.Native.tuple3", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.LoopCombinators.repeati", "Spec.Curve25519.ladder_step", "FStar.Pervasives.Native.Mktuple3", "Prims.eq2", "Prims.int", "Lib.IntTypes.range", "Lib.IntTypes.v", "Lib.IntTypes.u64", "Spec.Curve25519.add_and_double" ]
[]
module Hacl.Spec.Curve25519.AddAndDouble open FStar.Mul open Lib.IntTypes open Spec.Curve25519 let add_and_double1_0 a b nqp1 = let x_3, z_3 = nqp1 in let c = x_3 +% z_3 in let d = x_3 -% z_3 in let da = d *% a in let cb = c *% b in let x_3 = da +% cb in let z_3 = da -% cb in (x_3, z_3) let add_and_double1_1 a b nqp1 = let x_3, z_3 = nqp1 in let aa = a *% a in let bb = b *% b in let x_3 = x_3 *% x_3 in let z_3 = z_3 *% z_3 in let e = aa -% bb in let e121665 = e *% 121665 in let aa_e121665 = e121665 +% aa in let x_2 = aa *% bb in let z_2 = e *% aa_e121665 in (x_2, z_2), (x_3, z_3) let add_and_double1 q nq nqp1 = let x_1, z_1 = q in let x_2, z_2 = nq in let a = x_2 +% z_2 in let b = x_2 -% z_2 in let nqp1 = add_and_double1_0 a b nqp1 in let (x_2, z_2), (x_3, z_3) = add_and_double1_1 a b nqp1 in let z_3 = z_3 *% x_1 in (x_2, z_2), (x_3, z_3) val lemma_add_and_double: q:proj_point -> nq:proj_point -> nqp1:proj_point -> Lemma (add_and_double1 q nq nqp1 == add_and_double q nq nqp1) let lemma_add_and_double q nq nqp1 = ()
false
true
Hacl.Spec.Curve25519.AddAndDouble.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val montgomery_ladder1_0 : k: Spec.Curve25519.scalar -> q: Spec.Curve25519.proj_point -> nq: Spec.Curve25519.proj_point -> nqp1: Spec.Curve25519.proj_point -> Spec.Curve25519.proj_point
[]
Hacl.Spec.Curve25519.AddAndDouble.montgomery_ladder1_0
{ "file_name": "code/curve25519/Hacl.Spec.Curve25519.AddAndDouble.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Spec.Curve25519.scalar -> q: Spec.Curve25519.proj_point -> nq: Spec.Curve25519.proj_point -> nqp1: Spec.Curve25519.proj_point -> Spec.Curve25519.proj_point
{ "end_col": 4, "end_line": 55, "start_col": 86, "start_line": 48 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.Ed25519.PointOps", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519.Lemmas", "short_module": "EL" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aff_point_c = p:aff_point{is_on_curve p}
let aff_point_c =
false
null
false
p: aff_point{is_on_curve p}
{ "checked_file": "Spec.Ed25519.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Exponentiation.fsti.checked", "Spec.Ed25519.PointOps.fst.checked", "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Curve25519.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Ed25519.fst" }
[ "total" ]
[ "Spec.Ed25519.PointOps.aff_point", "Spec.Ed25519.PointOps.is_on_curve" ]
[]
module Spec.Ed25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519 module LE = Lib.Exponentiation module SE = Spec.Exponentiation module EL = Spec.Ed25519.Lemmas include Spec.Ed25519.PointOps #reset-options "--fuel 0 --ifuel 0 --z3rlimit 100" inline_for_extraction let size_signature: size_nat = 64 let q: n:nat{n < pow2 256} = assert_norm(pow2 252 + 27742317777372353535851937790883648493 < pow2 255 - 19); (pow2 252 + 27742317777372353535851937790883648493) // Group order let max_input_length_sha512 = Some?.v (Spec.Hash.Definitions.max_input_length Spec.Hash.Definitions.SHA2_512) let _: squash(max_input_length_sha512 > pow2 32 + 64) = assert_norm (max_input_length_sha512 > pow2 32 + 64) let sha512_modq (len:nat{len <= max_input_length_sha512}) (s:bytes{length s = len}) : n:nat{n < pow2 256} = nat_from_bytes_le (Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 s) % q /// Point Multiplication
false
true
Spec.Ed25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aff_point_c : Type0
[]
Spec.Ed25519.aff_point_c
{ "file_name": "specs/Spec.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 44, "end_line": 34, "start_col": 18, "start_line": 34 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.Ed25519.PointOps", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519.Lemmas", "short_module": "EL" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ext_point_c = p:ext_point{point_inv p}
let ext_point_c =
false
null
false
p: ext_point{point_inv p}
{ "checked_file": "Spec.Ed25519.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Exponentiation.fsti.checked", "Spec.Ed25519.PointOps.fst.checked", "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Curve25519.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Ed25519.fst" }
[ "total" ]
[ "Spec.Ed25519.PointOps.ext_point", "Spec.Ed25519.PointOps.point_inv" ]
[]
module Spec.Ed25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519 module LE = Lib.Exponentiation module SE = Spec.Exponentiation module EL = Spec.Ed25519.Lemmas include Spec.Ed25519.PointOps #reset-options "--fuel 0 --ifuel 0 --z3rlimit 100" inline_for_extraction let size_signature: size_nat = 64 let q: n:nat{n < pow2 256} = assert_norm(pow2 252 + 27742317777372353535851937790883648493 < pow2 255 - 19); (pow2 252 + 27742317777372353535851937790883648493) // Group order let max_input_length_sha512 = Some?.v (Spec.Hash.Definitions.max_input_length Spec.Hash.Definitions.SHA2_512) let _: squash(max_input_length_sha512 > pow2 32 + 64) = assert_norm (max_input_length_sha512 > pow2 32 + 64) let sha512_modq (len:nat{len <= max_input_length_sha512}) (s:bytes{length s = len}) : n:nat{n < pow2 256} = nat_from_bytes_le (Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 s) % q /// Point Multiplication let aff_point_c = p:aff_point{is_on_curve p} let aff_point_add_c (p:aff_point_c) (q:aff_point_c) : aff_point_c = EL.aff_point_add_lemma p q; aff_point_add p q let mk_ed25519_comm_monoid: LE.comm_monoid aff_point_c = { LE.one = aff_point_at_infinity; LE.mul = aff_point_add_c; LE.lemma_one = EL.aff_point_at_infinity_lemma; LE.lemma_mul_assoc = EL.aff_point_add_assoc_lemma; LE.lemma_mul_comm = EL.aff_point_add_comm_lemma; }
false
true
Spec.Ed25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ext_point_c : Type0
[]
Spec.Ed25519.ext_point_c
{ "file_name": "specs/Spec.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 42, "end_line": 47, "start_col": 18, "start_line": 47 }
Prims.Tot
val size_signature:size_nat
[ { "abbrev": false, "full_module": "Spec.Ed25519.PointOps", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519.Lemmas", "short_module": "EL" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size_signature: size_nat = 64
val size_signature:size_nat let size_signature:size_nat =
false
null
false
64
{ "checked_file": "Spec.Ed25519.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Exponentiation.fsti.checked", "Spec.Ed25519.PointOps.fst.checked", "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Curve25519.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Ed25519.fst" }
[ "total" ]
[]
[]
module Spec.Ed25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519 module LE = Lib.Exponentiation module SE = Spec.Exponentiation module EL = Spec.Ed25519.Lemmas include Spec.Ed25519.PointOps #reset-options "--fuel 0 --ifuel 0 --z3rlimit 100"
false
false
Spec.Ed25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size_signature:size_nat
[]
Spec.Ed25519.size_signature
{ "file_name": "specs/Spec.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Prims.nat{n <= Prims.pow2 32 - 1}
{ "end_col": 33, "end_line": 19, "start_col": 31, "start_line": 19 }
Prims.Tot
val aff_point_add_c (p q: aff_point_c) : aff_point_c
[ { "abbrev": false, "full_module": "Spec.Ed25519.PointOps", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519.Lemmas", "short_module": "EL" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aff_point_add_c (p:aff_point_c) (q:aff_point_c) : aff_point_c = EL.aff_point_add_lemma p q; aff_point_add p q
val aff_point_add_c (p q: aff_point_c) : aff_point_c let aff_point_add_c (p q: aff_point_c) : aff_point_c =
false
null
false
EL.aff_point_add_lemma p q; aff_point_add p q
{ "checked_file": "Spec.Ed25519.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Exponentiation.fsti.checked", "Spec.Ed25519.PointOps.fst.checked", "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Curve25519.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Ed25519.fst" }
[ "total" ]
[ "Spec.Ed25519.aff_point_c", "Spec.Ed25519.PointOps.aff_point_add", "Prims.unit", "Spec.Ed25519.Lemmas.aff_point_add_lemma" ]
[]
module Spec.Ed25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519 module LE = Lib.Exponentiation module SE = Spec.Exponentiation module EL = Spec.Ed25519.Lemmas include Spec.Ed25519.PointOps #reset-options "--fuel 0 --ifuel 0 --z3rlimit 100" inline_for_extraction let size_signature: size_nat = 64 let q: n:nat{n < pow2 256} = assert_norm(pow2 252 + 27742317777372353535851937790883648493 < pow2 255 - 19); (pow2 252 + 27742317777372353535851937790883648493) // Group order let max_input_length_sha512 = Some?.v (Spec.Hash.Definitions.max_input_length Spec.Hash.Definitions.SHA2_512) let _: squash(max_input_length_sha512 > pow2 32 + 64) = assert_norm (max_input_length_sha512 > pow2 32 + 64) let sha512_modq (len:nat{len <= max_input_length_sha512}) (s:bytes{length s = len}) : n:nat{n < pow2 256} = nat_from_bytes_le (Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 s) % q /// Point Multiplication let aff_point_c = p:aff_point{is_on_curve p}
false
true
Spec.Ed25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aff_point_add_c (p q: aff_point_c) : aff_point_c
[]
Spec.Ed25519.aff_point_add_c
{ "file_name": "specs/Spec.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Spec.Ed25519.aff_point_c -> q: Spec.Ed25519.aff_point_c -> Spec.Ed25519.aff_point_c
{ "end_col": 19, "end_line": 37, "start_col": 2, "start_line": 36 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.Ed25519.PointOps", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519.Lemmas", "short_module": "EL" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let max_input_length_sha512 = Some?.v (Spec.Hash.Definitions.max_input_length Spec.Hash.Definitions.SHA2_512)
let max_input_length_sha512 =
false
null
false
Some?.v (Spec.Hash.Definitions.max_input_length Spec.Hash.Definitions.SHA2_512)
{ "checked_file": "Spec.Ed25519.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Exponentiation.fsti.checked", "Spec.Ed25519.PointOps.fst.checked", "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Curve25519.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Ed25519.fst" }
[ "total" ]
[ "FStar.Pervasives.Native.__proj__Some__item__v", "Prims.pos", "Spec.Hash.Definitions.max_input_length", "Spec.Hash.Definitions.SHA2_512" ]
[]
module Spec.Ed25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519 module LE = Lib.Exponentiation module SE = Spec.Exponentiation module EL = Spec.Ed25519.Lemmas include Spec.Ed25519.PointOps #reset-options "--fuel 0 --ifuel 0 --z3rlimit 100" inline_for_extraction let size_signature: size_nat = 64 let q: n:nat{n < pow2 256} = assert_norm(pow2 252 + 27742317777372353535851937790883648493 < pow2 255 - 19); (pow2 252 + 27742317777372353535851937790883648493) // Group order
false
true
Spec.Ed25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val max_input_length_sha512 : Prims.pos
[]
Spec.Ed25519.max_input_length_sha512
{ "file_name": "specs/Spec.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Prims.pos
{ "end_col": 109, "end_line": 25, "start_col": 30, "start_line": 25 }
Prims.Tot
val point_add_c: SE.mul_st ext_point_c mk_to_ed25519_comm_monoid
[ { "abbrev": false, "full_module": "Spec.Ed25519.PointOps", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519.Lemmas", "short_module": "EL" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_add_c p q = EL.to_aff_point_add_lemma p q; point_add p q
val point_add_c: SE.mul_st ext_point_c mk_to_ed25519_comm_monoid let point_add_c p q =
false
null
false
EL.to_aff_point_add_lemma p q; point_add p q
{ "checked_file": "Spec.Ed25519.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Exponentiation.fsti.checked", "Spec.Ed25519.PointOps.fst.checked", "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Curve25519.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Ed25519.fst" }
[ "total" ]
[ "Spec.Ed25519.ext_point_c", "Spec.Ed25519.PointOps.point_add", "Prims.unit", "Spec.Ed25519.Lemmas.to_aff_point_add_lemma" ]
[]
module Spec.Ed25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519 module LE = Lib.Exponentiation module SE = Spec.Exponentiation module EL = Spec.Ed25519.Lemmas include Spec.Ed25519.PointOps #reset-options "--fuel 0 --ifuel 0 --z3rlimit 100" inline_for_extraction let size_signature: size_nat = 64 let q: n:nat{n < pow2 256} = assert_norm(pow2 252 + 27742317777372353535851937790883648493 < pow2 255 - 19); (pow2 252 + 27742317777372353535851937790883648493) // Group order let max_input_length_sha512 = Some?.v (Spec.Hash.Definitions.max_input_length Spec.Hash.Definitions.SHA2_512) let _: squash(max_input_length_sha512 > pow2 32 + 64) = assert_norm (max_input_length_sha512 > pow2 32 + 64) let sha512_modq (len:nat{len <= max_input_length_sha512}) (s:bytes{length s = len}) : n:nat{n < pow2 256} = nat_from_bytes_le (Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 s) % q /// Point Multiplication let aff_point_c = p:aff_point{is_on_curve p} let aff_point_add_c (p:aff_point_c) (q:aff_point_c) : aff_point_c = EL.aff_point_add_lemma p q; aff_point_add p q let mk_ed25519_comm_monoid: LE.comm_monoid aff_point_c = { LE.one = aff_point_at_infinity; LE.mul = aff_point_add_c; LE.lemma_one = EL.aff_point_at_infinity_lemma; LE.lemma_mul_assoc = EL.aff_point_add_assoc_lemma; LE.lemma_mul_comm = EL.aff_point_add_comm_lemma; } let ext_point_c = p:ext_point{point_inv p} let mk_to_ed25519_comm_monoid : SE.to_comm_monoid ext_point_c = { SE.a_spec = aff_point_c; SE.comm_monoid = mk_ed25519_comm_monoid; SE.refl = (fun (x:ext_point_c) -> to_aff_point x); } val point_at_inifinity_c: SE.one_st ext_point_c mk_to_ed25519_comm_monoid let point_at_inifinity_c _ = EL.to_aff_point_at_infinity_lemma (); point_at_infinity val point_add_c: SE.mul_st ext_point_c mk_to_ed25519_comm_monoid
false
true
Spec.Ed25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val point_add_c: SE.mul_st ext_point_c mk_to_ed25519_comm_monoid
[]
Spec.Ed25519.point_add_c
{ "file_name": "specs/Spec.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Spec.Exponentiation.mul_st Spec.Ed25519.ext_point_c Spec.Ed25519.mk_to_ed25519_comm_monoid
{ "end_col": 15, "end_line": 62, "start_col": 2, "start_line": 61 }
Prims.Tot
val point_double_c: SE.sqr_st ext_point_c mk_to_ed25519_comm_monoid
[ { "abbrev": false, "full_module": "Spec.Ed25519.PointOps", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519.Lemmas", "short_module": "EL" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_double_c p = EL.to_aff_point_double_lemma p; point_double p
val point_double_c: SE.sqr_st ext_point_c mk_to_ed25519_comm_monoid let point_double_c p =
false
null
false
EL.to_aff_point_double_lemma p; point_double p
{ "checked_file": "Spec.Ed25519.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Exponentiation.fsti.checked", "Spec.Ed25519.PointOps.fst.checked", "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Curve25519.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Ed25519.fst" }
[ "total" ]
[ "Spec.Ed25519.ext_point_c", "Spec.Ed25519.PointOps.point_double", "Prims.unit", "Spec.Ed25519.Lemmas.to_aff_point_double_lemma" ]
[]
module Spec.Ed25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519 module LE = Lib.Exponentiation module SE = Spec.Exponentiation module EL = Spec.Ed25519.Lemmas include Spec.Ed25519.PointOps #reset-options "--fuel 0 --ifuel 0 --z3rlimit 100" inline_for_extraction let size_signature: size_nat = 64 let q: n:nat{n < pow2 256} = assert_norm(pow2 252 + 27742317777372353535851937790883648493 < pow2 255 - 19); (pow2 252 + 27742317777372353535851937790883648493) // Group order let max_input_length_sha512 = Some?.v (Spec.Hash.Definitions.max_input_length Spec.Hash.Definitions.SHA2_512) let _: squash(max_input_length_sha512 > pow2 32 + 64) = assert_norm (max_input_length_sha512 > pow2 32 + 64) let sha512_modq (len:nat{len <= max_input_length_sha512}) (s:bytes{length s = len}) : n:nat{n < pow2 256} = nat_from_bytes_le (Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 s) % q /// Point Multiplication let aff_point_c = p:aff_point{is_on_curve p} let aff_point_add_c (p:aff_point_c) (q:aff_point_c) : aff_point_c = EL.aff_point_add_lemma p q; aff_point_add p q let mk_ed25519_comm_monoid: LE.comm_monoid aff_point_c = { LE.one = aff_point_at_infinity; LE.mul = aff_point_add_c; LE.lemma_one = EL.aff_point_at_infinity_lemma; LE.lemma_mul_assoc = EL.aff_point_add_assoc_lemma; LE.lemma_mul_comm = EL.aff_point_add_comm_lemma; } let ext_point_c = p:ext_point{point_inv p} let mk_to_ed25519_comm_monoid : SE.to_comm_monoid ext_point_c = { SE.a_spec = aff_point_c; SE.comm_monoid = mk_ed25519_comm_monoid; SE.refl = (fun (x:ext_point_c) -> to_aff_point x); } val point_at_inifinity_c: SE.one_st ext_point_c mk_to_ed25519_comm_monoid let point_at_inifinity_c _ = EL.to_aff_point_at_infinity_lemma (); point_at_infinity val point_add_c: SE.mul_st ext_point_c mk_to_ed25519_comm_monoid let point_add_c p q = EL.to_aff_point_add_lemma p q; point_add p q val point_double_c: SE.sqr_st ext_point_c mk_to_ed25519_comm_monoid
false
true
Spec.Ed25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val point_double_c: SE.sqr_st ext_point_c mk_to_ed25519_comm_monoid
[]
Spec.Ed25519.point_double_c
{ "file_name": "specs/Spec.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Spec.Exponentiation.sqr_st Spec.Ed25519.ext_point_c Spec.Ed25519.mk_to_ed25519_comm_monoid
{ "end_col": 16, "end_line": 67, "start_col": 2, "start_line": 66 }
Prims.Tot
val q:n: nat{n < pow2 256}
[ { "abbrev": false, "full_module": "Spec.Ed25519.PointOps", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519.Lemmas", "short_module": "EL" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let q: n:nat{n < pow2 256} = assert_norm(pow2 252 + 27742317777372353535851937790883648493 < pow2 255 - 19); (pow2 252 + 27742317777372353535851937790883648493)
val q:n: nat{n < pow2 256} let q:n: nat{n < pow2 256} =
false
null
false
assert_norm (pow2 252 + 27742317777372353535851937790883648493 < pow2 255 - 19); (pow2 252 + 27742317777372353535851937790883648493)
{ "checked_file": "Spec.Ed25519.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Exponentiation.fsti.checked", "Spec.Ed25519.PointOps.fst.checked", "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Curve25519.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Ed25519.fst" }
[ "total" ]
[ "Prims.op_Addition", "Prims.pow2", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Subtraction" ]
[]
module Spec.Ed25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519 module LE = Lib.Exponentiation module SE = Spec.Exponentiation module EL = Spec.Ed25519.Lemmas include Spec.Ed25519.PointOps #reset-options "--fuel 0 --ifuel 0 --z3rlimit 100" inline_for_extraction let size_signature: size_nat = 64
false
false
Spec.Ed25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val q:n: nat{n < pow2 256}
[]
Spec.Ed25519.q
{ "file_name": "specs/Spec.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Prims.nat{n < Prims.pow2 256}
{ "end_col": 53, "end_line": 23, "start_col": 2, "start_line": 22 }
Prims.Tot
val point_at_inifinity_c: SE.one_st ext_point_c mk_to_ed25519_comm_monoid
[ { "abbrev": false, "full_module": "Spec.Ed25519.PointOps", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519.Lemmas", "short_module": "EL" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_at_inifinity_c _ = EL.to_aff_point_at_infinity_lemma (); point_at_infinity
val point_at_inifinity_c: SE.one_st ext_point_c mk_to_ed25519_comm_monoid let point_at_inifinity_c _ =
false
null
false
EL.to_aff_point_at_infinity_lemma (); point_at_infinity
{ "checked_file": "Spec.Ed25519.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Exponentiation.fsti.checked", "Spec.Ed25519.PointOps.fst.checked", "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Curve25519.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Ed25519.fst" }
[ "total" ]
[ "Prims.unit", "Spec.Ed25519.PointOps.point_at_infinity", "Spec.Ed25519.Lemmas.to_aff_point_at_infinity_lemma", "Spec.Ed25519.ext_point_c" ]
[]
module Spec.Ed25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519 module LE = Lib.Exponentiation module SE = Spec.Exponentiation module EL = Spec.Ed25519.Lemmas include Spec.Ed25519.PointOps #reset-options "--fuel 0 --ifuel 0 --z3rlimit 100" inline_for_extraction let size_signature: size_nat = 64 let q: n:nat{n < pow2 256} = assert_norm(pow2 252 + 27742317777372353535851937790883648493 < pow2 255 - 19); (pow2 252 + 27742317777372353535851937790883648493) // Group order let max_input_length_sha512 = Some?.v (Spec.Hash.Definitions.max_input_length Spec.Hash.Definitions.SHA2_512) let _: squash(max_input_length_sha512 > pow2 32 + 64) = assert_norm (max_input_length_sha512 > pow2 32 + 64) let sha512_modq (len:nat{len <= max_input_length_sha512}) (s:bytes{length s = len}) : n:nat{n < pow2 256} = nat_from_bytes_le (Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 s) % q /// Point Multiplication let aff_point_c = p:aff_point{is_on_curve p} let aff_point_add_c (p:aff_point_c) (q:aff_point_c) : aff_point_c = EL.aff_point_add_lemma p q; aff_point_add p q let mk_ed25519_comm_monoid: LE.comm_monoid aff_point_c = { LE.one = aff_point_at_infinity; LE.mul = aff_point_add_c; LE.lemma_one = EL.aff_point_at_infinity_lemma; LE.lemma_mul_assoc = EL.aff_point_add_assoc_lemma; LE.lemma_mul_comm = EL.aff_point_add_comm_lemma; } let ext_point_c = p:ext_point{point_inv p} let mk_to_ed25519_comm_monoid : SE.to_comm_monoid ext_point_c = { SE.a_spec = aff_point_c; SE.comm_monoid = mk_ed25519_comm_monoid; SE.refl = (fun (x:ext_point_c) -> to_aff_point x); } val point_at_inifinity_c: SE.one_st ext_point_c mk_to_ed25519_comm_monoid
false
true
Spec.Ed25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val point_at_inifinity_c: SE.one_st ext_point_c mk_to_ed25519_comm_monoid
[]
Spec.Ed25519.point_at_inifinity_c
{ "file_name": "specs/Spec.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Spec.Exponentiation.one_st Spec.Ed25519.ext_point_c Spec.Ed25519.mk_to_ed25519_comm_monoid
{ "end_col": 19, "end_line": 57, "start_col": 2, "start_line": 56 }
Prims.Tot
val point_mul_g (a: lbytes 32) : ext_point_c
[ { "abbrev": false, "full_module": "Spec.Ed25519.PointOps", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519.Lemmas", "short_module": "EL" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_mul_g (a:lbytes 32) : ext_point_c = EL.g_is_on_curve (); point_mul a g
val point_mul_g (a: lbytes 32) : ext_point_c let point_mul_g (a: lbytes 32) : ext_point_c =
false
null
false
EL.g_is_on_curve (); point_mul a g
{ "checked_file": "Spec.Ed25519.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Exponentiation.fsti.checked", "Spec.Ed25519.PointOps.fst.checked", "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Curve25519.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Ed25519.fst" }
[ "total" ]
[ "Lib.ByteSequence.lbytes", "Spec.Ed25519.point_mul", "Spec.Ed25519.PointOps.g", "Prims.unit", "Spec.Ed25519.Lemmas.g_is_on_curve", "Spec.Ed25519.ext_point_c" ]
[]
module Spec.Ed25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519 module LE = Lib.Exponentiation module SE = Spec.Exponentiation module EL = Spec.Ed25519.Lemmas include Spec.Ed25519.PointOps #reset-options "--fuel 0 --ifuel 0 --z3rlimit 100" inline_for_extraction let size_signature: size_nat = 64 let q: n:nat{n < pow2 256} = assert_norm(pow2 252 + 27742317777372353535851937790883648493 < pow2 255 - 19); (pow2 252 + 27742317777372353535851937790883648493) // Group order let max_input_length_sha512 = Some?.v (Spec.Hash.Definitions.max_input_length Spec.Hash.Definitions.SHA2_512) let _: squash(max_input_length_sha512 > pow2 32 + 64) = assert_norm (max_input_length_sha512 > pow2 32 + 64) let sha512_modq (len:nat{len <= max_input_length_sha512}) (s:bytes{length s = len}) : n:nat{n < pow2 256} = nat_from_bytes_le (Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 s) % q /// Point Multiplication let aff_point_c = p:aff_point{is_on_curve p} let aff_point_add_c (p:aff_point_c) (q:aff_point_c) : aff_point_c = EL.aff_point_add_lemma p q; aff_point_add p q let mk_ed25519_comm_monoid: LE.comm_monoid aff_point_c = { LE.one = aff_point_at_infinity; LE.mul = aff_point_add_c; LE.lemma_one = EL.aff_point_at_infinity_lemma; LE.lemma_mul_assoc = EL.aff_point_add_assoc_lemma; LE.lemma_mul_comm = EL.aff_point_add_comm_lemma; } let ext_point_c = p:ext_point{point_inv p} let mk_to_ed25519_comm_monoid : SE.to_comm_monoid ext_point_c = { SE.a_spec = aff_point_c; SE.comm_monoid = mk_ed25519_comm_monoid; SE.refl = (fun (x:ext_point_c) -> to_aff_point x); } val point_at_inifinity_c: SE.one_st ext_point_c mk_to_ed25519_comm_monoid let point_at_inifinity_c _ = EL.to_aff_point_at_infinity_lemma (); point_at_infinity val point_add_c: SE.mul_st ext_point_c mk_to_ed25519_comm_monoid let point_add_c p q = EL.to_aff_point_add_lemma p q; point_add p q val point_double_c: SE.sqr_st ext_point_c mk_to_ed25519_comm_monoid let point_double_c p = EL.to_aff_point_double_lemma p; point_double p let mk_ed25519_concrete_ops : SE.concrete_ops ext_point_c = { SE.to = mk_to_ed25519_comm_monoid; SE.one = point_at_inifinity_c; SE.mul = point_add_c; SE.sqr = point_double_c; } // [a]P let point_mul (a:lbytes 32) (p:ext_point_c) : ext_point_c = SE.exp_fw mk_ed25519_concrete_ops p 256 (nat_from_bytes_le a) 4 // [a1]P1 + [a2]P2 let point_mul_double (a1:lbytes 32) (p1:ext_point_c) (a2:lbytes 32) (p2:ext_point_c) : ext_point_c = SE.exp_double_fw mk_ed25519_concrete_ops p1 256 (nat_from_bytes_le a1) p2 (nat_from_bytes_le a2) 5 // [a]G
false
false
Spec.Ed25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val point_mul_g (a: lbytes 32) : ext_point_c
[]
Spec.Ed25519.point_mul_g
{ "file_name": "specs/Spec.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Lib.ByteSequence.lbytes 32 -> Spec.Ed25519.ext_point_c
{ "end_col": 15, "end_line": 87, "start_col": 2, "start_line": 86 }
Prims.Tot
val point_mul_double_g (a1 a2: lbytes 32) (p: ext_point_c) : ext_point_c
[ { "abbrev": false, "full_module": "Spec.Ed25519.PointOps", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519.Lemmas", "short_module": "EL" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_mul_double_g (a1:lbytes 32) (a2:lbytes 32) (p:ext_point_c) : ext_point_c = EL.g_is_on_curve (); point_mul_double a1 g a2 p
val point_mul_double_g (a1 a2: lbytes 32) (p: ext_point_c) : ext_point_c let point_mul_double_g (a1 a2: lbytes 32) (p: ext_point_c) : ext_point_c =
false
null
false
EL.g_is_on_curve (); point_mul_double a1 g a2 p
{ "checked_file": "Spec.Ed25519.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Exponentiation.fsti.checked", "Spec.Ed25519.PointOps.fst.checked", "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Curve25519.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Ed25519.fst" }
[ "total" ]
[ "Lib.ByteSequence.lbytes", "Spec.Ed25519.ext_point_c", "Spec.Ed25519.point_mul_double", "Spec.Ed25519.PointOps.g", "Prims.unit", "Spec.Ed25519.Lemmas.g_is_on_curve" ]
[]
module Spec.Ed25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519 module LE = Lib.Exponentiation module SE = Spec.Exponentiation module EL = Spec.Ed25519.Lemmas include Spec.Ed25519.PointOps #reset-options "--fuel 0 --ifuel 0 --z3rlimit 100" inline_for_extraction let size_signature: size_nat = 64 let q: n:nat{n < pow2 256} = assert_norm(pow2 252 + 27742317777372353535851937790883648493 < pow2 255 - 19); (pow2 252 + 27742317777372353535851937790883648493) // Group order let max_input_length_sha512 = Some?.v (Spec.Hash.Definitions.max_input_length Spec.Hash.Definitions.SHA2_512) let _: squash(max_input_length_sha512 > pow2 32 + 64) = assert_norm (max_input_length_sha512 > pow2 32 + 64) let sha512_modq (len:nat{len <= max_input_length_sha512}) (s:bytes{length s = len}) : n:nat{n < pow2 256} = nat_from_bytes_le (Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 s) % q /// Point Multiplication let aff_point_c = p:aff_point{is_on_curve p} let aff_point_add_c (p:aff_point_c) (q:aff_point_c) : aff_point_c = EL.aff_point_add_lemma p q; aff_point_add p q let mk_ed25519_comm_monoid: LE.comm_monoid aff_point_c = { LE.one = aff_point_at_infinity; LE.mul = aff_point_add_c; LE.lemma_one = EL.aff_point_at_infinity_lemma; LE.lemma_mul_assoc = EL.aff_point_add_assoc_lemma; LE.lemma_mul_comm = EL.aff_point_add_comm_lemma; } let ext_point_c = p:ext_point{point_inv p} let mk_to_ed25519_comm_monoid : SE.to_comm_monoid ext_point_c = { SE.a_spec = aff_point_c; SE.comm_monoid = mk_ed25519_comm_monoid; SE.refl = (fun (x:ext_point_c) -> to_aff_point x); } val point_at_inifinity_c: SE.one_st ext_point_c mk_to_ed25519_comm_monoid let point_at_inifinity_c _ = EL.to_aff_point_at_infinity_lemma (); point_at_infinity val point_add_c: SE.mul_st ext_point_c mk_to_ed25519_comm_monoid let point_add_c p q = EL.to_aff_point_add_lemma p q; point_add p q val point_double_c: SE.sqr_st ext_point_c mk_to_ed25519_comm_monoid let point_double_c p = EL.to_aff_point_double_lemma p; point_double p let mk_ed25519_concrete_ops : SE.concrete_ops ext_point_c = { SE.to = mk_to_ed25519_comm_monoid; SE.one = point_at_inifinity_c; SE.mul = point_add_c; SE.sqr = point_double_c; } // [a]P let point_mul (a:lbytes 32) (p:ext_point_c) : ext_point_c = SE.exp_fw mk_ed25519_concrete_ops p 256 (nat_from_bytes_le a) 4 // [a1]P1 + [a2]P2 let point_mul_double (a1:lbytes 32) (p1:ext_point_c) (a2:lbytes 32) (p2:ext_point_c) : ext_point_c = SE.exp_double_fw mk_ed25519_concrete_ops p1 256 (nat_from_bytes_le a1) p2 (nat_from_bytes_le a2) 5 // [a]G let point_mul_g (a:lbytes 32) : ext_point_c = EL.g_is_on_curve (); point_mul a g // [a1]G + [a2]P
false
false
Spec.Ed25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val point_mul_double_g (a1 a2: lbytes 32) (p: ext_point_c) : ext_point_c
[]
Spec.Ed25519.point_mul_double_g
{ "file_name": "specs/Spec.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a1: Lib.ByteSequence.lbytes 32 -> a2: Lib.ByteSequence.lbytes 32 -> p: Spec.Ed25519.ext_point_c -> Spec.Ed25519.ext_point_c
{ "end_col": 28, "end_line": 92, "start_col": 2, "start_line": 91 }
Prims.Tot
val sha512_modq (len: nat{len <= max_input_length_sha512}) (s: bytes{length s = len}) : n: nat{n < pow2 256}
[ { "abbrev": false, "full_module": "Spec.Ed25519.PointOps", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519.Lemmas", "short_module": "EL" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sha512_modq (len:nat{len <= max_input_length_sha512}) (s:bytes{length s = len}) : n:nat{n < pow2 256} = nat_from_bytes_le (Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 s) % q
val sha512_modq (len: nat{len <= max_input_length_sha512}) (s: bytes{length s = len}) : n: nat{n < pow2 256} let sha512_modq (len: nat{len <= max_input_length_sha512}) (s: bytes{length s = len}) : n: nat{n < pow2 256} =
false
null
false
nat_from_bytes_le (Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 s) % q
{ "checked_file": "Spec.Ed25519.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Exponentiation.fsti.checked", "Spec.Ed25519.PointOps.fst.checked", "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Curve25519.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Ed25519.fst" }
[ "total" ]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Spec.Ed25519.max_input_length_sha512", "Lib.ByteSequence.bytes", "Prims.op_Equality", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.op_Modulus", "Lib.ByteSequence.nat_from_bytes_le", "Spec.Agile.Hash.hash", "Spec.Hash.Definitions.SHA2_512", "Spec.Ed25519.q", "Prims.op_LessThan", "Prims.pow2" ]
[]
module Spec.Ed25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519 module LE = Lib.Exponentiation module SE = Spec.Exponentiation module EL = Spec.Ed25519.Lemmas include Spec.Ed25519.PointOps #reset-options "--fuel 0 --ifuel 0 --z3rlimit 100" inline_for_extraction let size_signature: size_nat = 64 let q: n:nat{n < pow2 256} = assert_norm(pow2 252 + 27742317777372353535851937790883648493 < pow2 255 - 19); (pow2 252 + 27742317777372353535851937790883648493) // Group order let max_input_length_sha512 = Some?.v (Spec.Hash.Definitions.max_input_length Spec.Hash.Definitions.SHA2_512) let _: squash(max_input_length_sha512 > pow2 32 + 64) = assert_norm (max_input_length_sha512 > pow2 32 + 64)
false
false
Spec.Ed25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sha512_modq (len: nat{len <= max_input_length_sha512}) (s: bytes{length s = len}) : n: nat{n < pow2 256}
[]
Spec.Ed25519.sha512_modq
{ "file_name": "specs/Spec.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Prims.nat{len <= Spec.Ed25519.max_input_length_sha512} -> s: Lib.ByteSequence.bytes{Lib.Sequence.length s = len} -> n: Prims.nat{n < Prims.pow2 256}
{ "end_col": 79, "end_line": 30, "start_col": 2, "start_line": 30 }
Prims.Tot
val mk_ed25519_comm_monoid:LE.comm_monoid aff_point_c
[ { "abbrev": false, "full_module": "Spec.Ed25519.PointOps", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519.Lemmas", "short_module": "EL" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mk_ed25519_comm_monoid: LE.comm_monoid aff_point_c = { LE.one = aff_point_at_infinity; LE.mul = aff_point_add_c; LE.lemma_one = EL.aff_point_at_infinity_lemma; LE.lemma_mul_assoc = EL.aff_point_add_assoc_lemma; LE.lemma_mul_comm = EL.aff_point_add_comm_lemma; }
val mk_ed25519_comm_monoid:LE.comm_monoid aff_point_c let mk_ed25519_comm_monoid:LE.comm_monoid aff_point_c =
false
null
false
{ LE.one = aff_point_at_infinity; LE.mul = aff_point_add_c; LE.lemma_one = EL.aff_point_at_infinity_lemma; LE.lemma_mul_assoc = EL.aff_point_add_assoc_lemma; LE.lemma_mul_comm = EL.aff_point_add_comm_lemma }
{ "checked_file": "Spec.Ed25519.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Exponentiation.fsti.checked", "Spec.Ed25519.PointOps.fst.checked", "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Curve25519.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Ed25519.fst" }
[ "total" ]
[ "Lib.Exponentiation.Definition.Mkcomm_monoid", "Spec.Ed25519.aff_point_c", "Spec.Ed25519.PointOps.aff_point_at_infinity", "Spec.Ed25519.aff_point_add_c", "Spec.Ed25519.Lemmas.aff_point_at_infinity_lemma", "Spec.Ed25519.Lemmas.aff_point_add_assoc_lemma", "Spec.Ed25519.Lemmas.aff_point_add_comm_lemma" ]
[]
module Spec.Ed25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519 module LE = Lib.Exponentiation module SE = Spec.Exponentiation module EL = Spec.Ed25519.Lemmas include Spec.Ed25519.PointOps #reset-options "--fuel 0 --ifuel 0 --z3rlimit 100" inline_for_extraction let size_signature: size_nat = 64 let q: n:nat{n < pow2 256} = assert_norm(pow2 252 + 27742317777372353535851937790883648493 < pow2 255 - 19); (pow2 252 + 27742317777372353535851937790883648493) // Group order let max_input_length_sha512 = Some?.v (Spec.Hash.Definitions.max_input_length Spec.Hash.Definitions.SHA2_512) let _: squash(max_input_length_sha512 > pow2 32 + 64) = assert_norm (max_input_length_sha512 > pow2 32 + 64) let sha512_modq (len:nat{len <= max_input_length_sha512}) (s:bytes{length s = len}) : n:nat{n < pow2 256} = nat_from_bytes_le (Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 s) % q /// Point Multiplication let aff_point_c = p:aff_point{is_on_curve p} let aff_point_add_c (p:aff_point_c) (q:aff_point_c) : aff_point_c = EL.aff_point_add_lemma p q; aff_point_add p q
false
true
Spec.Ed25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mk_ed25519_comm_monoid:LE.comm_monoid aff_point_c
[]
Spec.Ed25519.mk_ed25519_comm_monoid
{ "file_name": "specs/Spec.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Lib.Exponentiation.Definition.comm_monoid Spec.Ed25519.aff_point_c
{ "end_col": 50, "end_line": 44, "start_col": 2, "start_line": 40 }
Prims.Tot
val point_mul_double (a1: lbytes 32) (p1: ext_point_c) (a2: lbytes 32) (p2: ext_point_c) : ext_point_c
[ { "abbrev": false, "full_module": "Spec.Ed25519.PointOps", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519.Lemmas", "short_module": "EL" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_mul_double (a1:lbytes 32) (p1:ext_point_c) (a2:lbytes 32) (p2:ext_point_c) : ext_point_c = SE.exp_double_fw mk_ed25519_concrete_ops p1 256 (nat_from_bytes_le a1) p2 (nat_from_bytes_le a2) 5
val point_mul_double (a1: lbytes 32) (p1: ext_point_c) (a2: lbytes 32) (p2: ext_point_c) : ext_point_c let point_mul_double (a1: lbytes 32) (p1: ext_point_c) (a2: lbytes 32) (p2: ext_point_c) : ext_point_c =
false
null
false
SE.exp_double_fw mk_ed25519_concrete_ops p1 256 (nat_from_bytes_le a1) p2 (nat_from_bytes_le a2) 5
{ "checked_file": "Spec.Ed25519.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Exponentiation.fsti.checked", "Spec.Ed25519.PointOps.fst.checked", "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Curve25519.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Ed25519.fst" }
[ "total" ]
[ "Lib.ByteSequence.lbytes", "Spec.Ed25519.ext_point_c", "Spec.Exponentiation.exp_double_fw", "Spec.Ed25519.mk_ed25519_concrete_ops", "Lib.ByteSequence.nat_from_bytes_le", "Lib.IntTypes.SEC" ]
[]
module Spec.Ed25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519 module LE = Lib.Exponentiation module SE = Spec.Exponentiation module EL = Spec.Ed25519.Lemmas include Spec.Ed25519.PointOps #reset-options "--fuel 0 --ifuel 0 --z3rlimit 100" inline_for_extraction let size_signature: size_nat = 64 let q: n:nat{n < pow2 256} = assert_norm(pow2 252 + 27742317777372353535851937790883648493 < pow2 255 - 19); (pow2 252 + 27742317777372353535851937790883648493) // Group order let max_input_length_sha512 = Some?.v (Spec.Hash.Definitions.max_input_length Spec.Hash.Definitions.SHA2_512) let _: squash(max_input_length_sha512 > pow2 32 + 64) = assert_norm (max_input_length_sha512 > pow2 32 + 64) let sha512_modq (len:nat{len <= max_input_length_sha512}) (s:bytes{length s = len}) : n:nat{n < pow2 256} = nat_from_bytes_le (Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 s) % q /// Point Multiplication let aff_point_c = p:aff_point{is_on_curve p} let aff_point_add_c (p:aff_point_c) (q:aff_point_c) : aff_point_c = EL.aff_point_add_lemma p q; aff_point_add p q let mk_ed25519_comm_monoid: LE.comm_monoid aff_point_c = { LE.one = aff_point_at_infinity; LE.mul = aff_point_add_c; LE.lemma_one = EL.aff_point_at_infinity_lemma; LE.lemma_mul_assoc = EL.aff_point_add_assoc_lemma; LE.lemma_mul_comm = EL.aff_point_add_comm_lemma; } let ext_point_c = p:ext_point{point_inv p} let mk_to_ed25519_comm_monoid : SE.to_comm_monoid ext_point_c = { SE.a_spec = aff_point_c; SE.comm_monoid = mk_ed25519_comm_monoid; SE.refl = (fun (x:ext_point_c) -> to_aff_point x); } val point_at_inifinity_c: SE.one_st ext_point_c mk_to_ed25519_comm_monoid let point_at_inifinity_c _ = EL.to_aff_point_at_infinity_lemma (); point_at_infinity val point_add_c: SE.mul_st ext_point_c mk_to_ed25519_comm_monoid let point_add_c p q = EL.to_aff_point_add_lemma p q; point_add p q val point_double_c: SE.sqr_st ext_point_c mk_to_ed25519_comm_monoid let point_double_c p = EL.to_aff_point_double_lemma p; point_double p let mk_ed25519_concrete_ops : SE.concrete_ops ext_point_c = { SE.to = mk_to_ed25519_comm_monoid; SE.one = point_at_inifinity_c; SE.mul = point_add_c; SE.sqr = point_double_c; } // [a]P let point_mul (a:lbytes 32) (p:ext_point_c) : ext_point_c = SE.exp_fw mk_ed25519_concrete_ops p 256 (nat_from_bytes_le a) 4 // [a1]P1 + [a2]P2
false
false
Spec.Ed25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val point_mul_double (a1: lbytes 32) (p1: ext_point_c) (a2: lbytes 32) (p2: ext_point_c) : ext_point_c
[]
Spec.Ed25519.point_mul_double
{ "file_name": "specs/Spec.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a1: Lib.ByteSequence.lbytes 32 -> p1: Spec.Ed25519.ext_point_c -> a2: Lib.ByteSequence.lbytes 32 -> p2: Spec.Ed25519.ext_point_c -> Spec.Ed25519.ext_point_c
{ "end_col": 100, "end_line": 82, "start_col": 2, "start_line": 82 }
Prims.Tot
val point_mul (a: lbytes 32) (p: ext_point_c) : ext_point_c
[ { "abbrev": false, "full_module": "Spec.Ed25519.PointOps", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519.Lemmas", "short_module": "EL" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_mul (a:lbytes 32) (p:ext_point_c) : ext_point_c = SE.exp_fw mk_ed25519_concrete_ops p 256 (nat_from_bytes_le a) 4
val point_mul (a: lbytes 32) (p: ext_point_c) : ext_point_c let point_mul (a: lbytes 32) (p: ext_point_c) : ext_point_c =
false
null
false
SE.exp_fw mk_ed25519_concrete_ops p 256 (nat_from_bytes_le a) 4
{ "checked_file": "Spec.Ed25519.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Exponentiation.fsti.checked", "Spec.Ed25519.PointOps.fst.checked", "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Curve25519.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Ed25519.fst" }
[ "total" ]
[ "Lib.ByteSequence.lbytes", "Spec.Ed25519.ext_point_c", "Spec.Exponentiation.exp_fw", "Spec.Ed25519.mk_ed25519_concrete_ops", "Lib.ByteSequence.nat_from_bytes_le", "Lib.IntTypes.SEC" ]
[]
module Spec.Ed25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519 module LE = Lib.Exponentiation module SE = Spec.Exponentiation module EL = Spec.Ed25519.Lemmas include Spec.Ed25519.PointOps #reset-options "--fuel 0 --ifuel 0 --z3rlimit 100" inline_for_extraction let size_signature: size_nat = 64 let q: n:nat{n < pow2 256} = assert_norm(pow2 252 + 27742317777372353535851937790883648493 < pow2 255 - 19); (pow2 252 + 27742317777372353535851937790883648493) // Group order let max_input_length_sha512 = Some?.v (Spec.Hash.Definitions.max_input_length Spec.Hash.Definitions.SHA2_512) let _: squash(max_input_length_sha512 > pow2 32 + 64) = assert_norm (max_input_length_sha512 > pow2 32 + 64) let sha512_modq (len:nat{len <= max_input_length_sha512}) (s:bytes{length s = len}) : n:nat{n < pow2 256} = nat_from_bytes_le (Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 s) % q /// Point Multiplication let aff_point_c = p:aff_point{is_on_curve p} let aff_point_add_c (p:aff_point_c) (q:aff_point_c) : aff_point_c = EL.aff_point_add_lemma p q; aff_point_add p q let mk_ed25519_comm_monoid: LE.comm_monoid aff_point_c = { LE.one = aff_point_at_infinity; LE.mul = aff_point_add_c; LE.lemma_one = EL.aff_point_at_infinity_lemma; LE.lemma_mul_assoc = EL.aff_point_add_assoc_lemma; LE.lemma_mul_comm = EL.aff_point_add_comm_lemma; } let ext_point_c = p:ext_point{point_inv p} let mk_to_ed25519_comm_monoid : SE.to_comm_monoid ext_point_c = { SE.a_spec = aff_point_c; SE.comm_monoid = mk_ed25519_comm_monoid; SE.refl = (fun (x:ext_point_c) -> to_aff_point x); } val point_at_inifinity_c: SE.one_st ext_point_c mk_to_ed25519_comm_monoid let point_at_inifinity_c _ = EL.to_aff_point_at_infinity_lemma (); point_at_infinity val point_add_c: SE.mul_st ext_point_c mk_to_ed25519_comm_monoid let point_add_c p q = EL.to_aff_point_add_lemma p q; point_add p q val point_double_c: SE.sqr_st ext_point_c mk_to_ed25519_comm_monoid let point_double_c p = EL.to_aff_point_double_lemma p; point_double p let mk_ed25519_concrete_ops : SE.concrete_ops ext_point_c = { SE.to = mk_to_ed25519_comm_monoid; SE.one = point_at_inifinity_c; SE.mul = point_add_c; SE.sqr = point_double_c; } // [a]P
false
false
Spec.Ed25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val point_mul (a: lbytes 32) (p: ext_point_c) : ext_point_c
[]
Spec.Ed25519.point_mul
{ "file_name": "specs/Spec.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Lib.ByteSequence.lbytes 32 -> p: Spec.Ed25519.ext_point_c -> Spec.Ed25519.ext_point_c
{ "end_col": 65, "end_line": 78, "start_col": 2, "start_line": 78 }
Prims.Tot
val secret_to_public (secret: lbytes 32) : lbytes 32
[ { "abbrev": false, "full_module": "Spec.Ed25519.PointOps", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519.Lemmas", "short_module": "EL" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let secret_to_public (secret:lbytes 32) : lbytes 32 = let a, dummy = secret_expand secret in point_compress (point_mul_g a)
val secret_to_public (secret: lbytes 32) : lbytes 32 let secret_to_public (secret: lbytes 32) : lbytes 32 =
false
null
false
let a, dummy = secret_expand secret in point_compress (point_mul_g a)
{ "checked_file": "Spec.Ed25519.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Exponentiation.fsti.checked", "Spec.Ed25519.PointOps.fst.checked", "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Curve25519.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Ed25519.fst" }
[ "total" ]
[ "Lib.ByteSequence.lbytes", "Spec.Ed25519.PointOps.point_compress", "Spec.Ed25519.point_mul_g", "FStar.Pervasives.Native.tuple2", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.Ed25519.secret_expand" ]
[]
module Spec.Ed25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519 module LE = Lib.Exponentiation module SE = Spec.Exponentiation module EL = Spec.Ed25519.Lemmas include Spec.Ed25519.PointOps #reset-options "--fuel 0 --ifuel 0 --z3rlimit 100" inline_for_extraction let size_signature: size_nat = 64 let q: n:nat{n < pow2 256} = assert_norm(pow2 252 + 27742317777372353535851937790883648493 < pow2 255 - 19); (pow2 252 + 27742317777372353535851937790883648493) // Group order let max_input_length_sha512 = Some?.v (Spec.Hash.Definitions.max_input_length Spec.Hash.Definitions.SHA2_512) let _: squash(max_input_length_sha512 > pow2 32 + 64) = assert_norm (max_input_length_sha512 > pow2 32 + 64) let sha512_modq (len:nat{len <= max_input_length_sha512}) (s:bytes{length s = len}) : n:nat{n < pow2 256} = nat_from_bytes_le (Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 s) % q /// Point Multiplication let aff_point_c = p:aff_point{is_on_curve p} let aff_point_add_c (p:aff_point_c) (q:aff_point_c) : aff_point_c = EL.aff_point_add_lemma p q; aff_point_add p q let mk_ed25519_comm_monoid: LE.comm_monoid aff_point_c = { LE.one = aff_point_at_infinity; LE.mul = aff_point_add_c; LE.lemma_one = EL.aff_point_at_infinity_lemma; LE.lemma_mul_assoc = EL.aff_point_add_assoc_lemma; LE.lemma_mul_comm = EL.aff_point_add_comm_lemma; } let ext_point_c = p:ext_point{point_inv p} let mk_to_ed25519_comm_monoid : SE.to_comm_monoid ext_point_c = { SE.a_spec = aff_point_c; SE.comm_monoid = mk_ed25519_comm_monoid; SE.refl = (fun (x:ext_point_c) -> to_aff_point x); } val point_at_inifinity_c: SE.one_st ext_point_c mk_to_ed25519_comm_monoid let point_at_inifinity_c _ = EL.to_aff_point_at_infinity_lemma (); point_at_infinity val point_add_c: SE.mul_st ext_point_c mk_to_ed25519_comm_monoid let point_add_c p q = EL.to_aff_point_add_lemma p q; point_add p q val point_double_c: SE.sqr_st ext_point_c mk_to_ed25519_comm_monoid let point_double_c p = EL.to_aff_point_double_lemma p; point_double p let mk_ed25519_concrete_ops : SE.concrete_ops ext_point_c = { SE.to = mk_to_ed25519_comm_monoid; SE.one = point_at_inifinity_c; SE.mul = point_add_c; SE.sqr = point_double_c; } // [a]P let point_mul (a:lbytes 32) (p:ext_point_c) : ext_point_c = SE.exp_fw mk_ed25519_concrete_ops p 256 (nat_from_bytes_le a) 4 // [a1]P1 + [a2]P2 let point_mul_double (a1:lbytes 32) (p1:ext_point_c) (a2:lbytes 32) (p2:ext_point_c) : ext_point_c = SE.exp_double_fw mk_ed25519_concrete_ops p1 256 (nat_from_bytes_le a1) p2 (nat_from_bytes_le a2) 5 // [a]G let point_mul_g (a:lbytes 32) : ext_point_c = EL.g_is_on_curve (); point_mul a g // [a1]G + [a2]P let point_mul_double_g (a1:lbytes 32) (a2:lbytes 32) (p:ext_point_c) : ext_point_c = EL.g_is_on_curve (); point_mul_double a1 g a2 p // [a1]G - [a2]P let point_negate_mul_double_g (a1:lbytes 32) (a2:lbytes 32) (p:ext_point_c) : ext_point_c = let p1 = point_negate p in EL.to_aff_point_negate p; point_mul_double_g a1 a2 p1 /// Ed25519 API let secret_expand (secret:lbytes 32) : (lbytes 32 & lbytes 32) = let h = Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 secret in let h_low : lbytes 32 = slice h 0 32 in let h_high : lbytes 32 = slice h 32 64 in let h_low = h_low.[ 0] <- h_low.[0] &. u8 0xf8 in let h_low = h_low.[31] <- (h_low.[31] &. u8 127) |. u8 64 in h_low, h_high
false
false
Spec.Ed25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val secret_to_public (secret: lbytes 32) : lbytes 32
[]
Spec.Ed25519.secret_to_public
{ "file_name": "specs/Spec.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
secret: Lib.ByteSequence.lbytes 32 -> Lib.ByteSequence.lbytes 32
{ "end_col": 32, "end_line": 113, "start_col": 53, "start_line": 111 }
Prims.Tot
val point_negate_mul_double_g (a1 a2: lbytes 32) (p: ext_point_c) : ext_point_c
[ { "abbrev": false, "full_module": "Spec.Ed25519.PointOps", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519.Lemmas", "short_module": "EL" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_negate_mul_double_g (a1:lbytes 32) (a2:lbytes 32) (p:ext_point_c) : ext_point_c = let p1 = point_negate p in EL.to_aff_point_negate p; point_mul_double_g a1 a2 p1
val point_negate_mul_double_g (a1 a2: lbytes 32) (p: ext_point_c) : ext_point_c let point_negate_mul_double_g (a1 a2: lbytes 32) (p: ext_point_c) : ext_point_c =
false
null
false
let p1 = point_negate p in EL.to_aff_point_negate p; point_mul_double_g a1 a2 p1
{ "checked_file": "Spec.Ed25519.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Exponentiation.fsti.checked", "Spec.Ed25519.PointOps.fst.checked", "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Curve25519.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Ed25519.fst" }
[ "total" ]
[ "Lib.ByteSequence.lbytes", "Spec.Ed25519.ext_point_c", "Spec.Ed25519.point_mul_double_g", "Prims.unit", "Spec.Ed25519.Lemmas.to_aff_point_negate", "Spec.Ed25519.PointOps.ext_point", "Spec.Ed25519.PointOps.point_negate" ]
[]
module Spec.Ed25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519 module LE = Lib.Exponentiation module SE = Spec.Exponentiation module EL = Spec.Ed25519.Lemmas include Spec.Ed25519.PointOps #reset-options "--fuel 0 --ifuel 0 --z3rlimit 100" inline_for_extraction let size_signature: size_nat = 64 let q: n:nat{n < pow2 256} = assert_norm(pow2 252 + 27742317777372353535851937790883648493 < pow2 255 - 19); (pow2 252 + 27742317777372353535851937790883648493) // Group order let max_input_length_sha512 = Some?.v (Spec.Hash.Definitions.max_input_length Spec.Hash.Definitions.SHA2_512) let _: squash(max_input_length_sha512 > pow2 32 + 64) = assert_norm (max_input_length_sha512 > pow2 32 + 64) let sha512_modq (len:nat{len <= max_input_length_sha512}) (s:bytes{length s = len}) : n:nat{n < pow2 256} = nat_from_bytes_le (Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 s) % q /// Point Multiplication let aff_point_c = p:aff_point{is_on_curve p} let aff_point_add_c (p:aff_point_c) (q:aff_point_c) : aff_point_c = EL.aff_point_add_lemma p q; aff_point_add p q let mk_ed25519_comm_monoid: LE.comm_monoid aff_point_c = { LE.one = aff_point_at_infinity; LE.mul = aff_point_add_c; LE.lemma_one = EL.aff_point_at_infinity_lemma; LE.lemma_mul_assoc = EL.aff_point_add_assoc_lemma; LE.lemma_mul_comm = EL.aff_point_add_comm_lemma; } let ext_point_c = p:ext_point{point_inv p} let mk_to_ed25519_comm_monoid : SE.to_comm_monoid ext_point_c = { SE.a_spec = aff_point_c; SE.comm_monoid = mk_ed25519_comm_monoid; SE.refl = (fun (x:ext_point_c) -> to_aff_point x); } val point_at_inifinity_c: SE.one_st ext_point_c mk_to_ed25519_comm_monoid let point_at_inifinity_c _ = EL.to_aff_point_at_infinity_lemma (); point_at_infinity val point_add_c: SE.mul_st ext_point_c mk_to_ed25519_comm_monoid let point_add_c p q = EL.to_aff_point_add_lemma p q; point_add p q val point_double_c: SE.sqr_st ext_point_c mk_to_ed25519_comm_monoid let point_double_c p = EL.to_aff_point_double_lemma p; point_double p let mk_ed25519_concrete_ops : SE.concrete_ops ext_point_c = { SE.to = mk_to_ed25519_comm_monoid; SE.one = point_at_inifinity_c; SE.mul = point_add_c; SE.sqr = point_double_c; } // [a]P let point_mul (a:lbytes 32) (p:ext_point_c) : ext_point_c = SE.exp_fw mk_ed25519_concrete_ops p 256 (nat_from_bytes_le a) 4 // [a1]P1 + [a2]P2 let point_mul_double (a1:lbytes 32) (p1:ext_point_c) (a2:lbytes 32) (p2:ext_point_c) : ext_point_c = SE.exp_double_fw mk_ed25519_concrete_ops p1 256 (nat_from_bytes_le a1) p2 (nat_from_bytes_le a2) 5 // [a]G let point_mul_g (a:lbytes 32) : ext_point_c = EL.g_is_on_curve (); point_mul a g // [a1]G + [a2]P let point_mul_double_g (a1:lbytes 32) (a2:lbytes 32) (p:ext_point_c) : ext_point_c = EL.g_is_on_curve (); point_mul_double a1 g a2 p
false
false
Spec.Ed25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val point_negate_mul_double_g (a1 a2: lbytes 32) (p: ext_point_c) : ext_point_c
[]
Spec.Ed25519.point_negate_mul_double_g
{ "file_name": "specs/Spec.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a1: Lib.ByteSequence.lbytes 32 -> a2: Lib.ByteSequence.lbytes 32 -> p: Spec.Ed25519.ext_point_c -> Spec.Ed25519.ext_point_c
{ "end_col": 29, "end_line": 98, "start_col": 91, "start_line": 95 }
Prims.Tot
val sign: secret:lbytes 32 -> msg:bytes{length msg <= max_size_t} -> lbytes 64
[ { "abbrev": false, "full_module": "Spec.Ed25519.PointOps", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519.Lemmas", "short_module": "EL" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sign secret msg = let pub, s, prefix = expand_keys secret in sign_expanded pub s prefix msg
val sign: secret:lbytes 32 -> msg:bytes{length msg <= max_size_t} -> lbytes 64 let sign secret msg =
false
null
false
let pub, s, prefix = expand_keys secret in sign_expanded pub s prefix msg
{ "checked_file": "Spec.Ed25519.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Exponentiation.fsti.checked", "Spec.Ed25519.PointOps.fst.checked", "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Curve25519.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Ed25519.fst" }
[ "total" ]
[ "Lib.ByteSequence.lbytes", "Lib.ByteSequence.bytes", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.IntTypes.max_size_t", "Spec.Ed25519.sign_expanded", "FStar.Pervasives.Native.tuple3", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Spec.Ed25519.expand_keys" ]
[]
module Spec.Ed25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519 module LE = Lib.Exponentiation module SE = Spec.Exponentiation module EL = Spec.Ed25519.Lemmas include Spec.Ed25519.PointOps #reset-options "--fuel 0 --ifuel 0 --z3rlimit 100" inline_for_extraction let size_signature: size_nat = 64 let q: n:nat{n < pow2 256} = assert_norm(pow2 252 + 27742317777372353535851937790883648493 < pow2 255 - 19); (pow2 252 + 27742317777372353535851937790883648493) // Group order let max_input_length_sha512 = Some?.v (Spec.Hash.Definitions.max_input_length Spec.Hash.Definitions.SHA2_512) let _: squash(max_input_length_sha512 > pow2 32 + 64) = assert_norm (max_input_length_sha512 > pow2 32 + 64) let sha512_modq (len:nat{len <= max_input_length_sha512}) (s:bytes{length s = len}) : n:nat{n < pow2 256} = nat_from_bytes_le (Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 s) % q /// Point Multiplication let aff_point_c = p:aff_point{is_on_curve p} let aff_point_add_c (p:aff_point_c) (q:aff_point_c) : aff_point_c = EL.aff_point_add_lemma p q; aff_point_add p q let mk_ed25519_comm_monoid: LE.comm_monoid aff_point_c = { LE.one = aff_point_at_infinity; LE.mul = aff_point_add_c; LE.lemma_one = EL.aff_point_at_infinity_lemma; LE.lemma_mul_assoc = EL.aff_point_add_assoc_lemma; LE.lemma_mul_comm = EL.aff_point_add_comm_lemma; } let ext_point_c = p:ext_point{point_inv p} let mk_to_ed25519_comm_monoid : SE.to_comm_monoid ext_point_c = { SE.a_spec = aff_point_c; SE.comm_monoid = mk_ed25519_comm_monoid; SE.refl = (fun (x:ext_point_c) -> to_aff_point x); } val point_at_inifinity_c: SE.one_st ext_point_c mk_to_ed25519_comm_monoid let point_at_inifinity_c _ = EL.to_aff_point_at_infinity_lemma (); point_at_infinity val point_add_c: SE.mul_st ext_point_c mk_to_ed25519_comm_monoid let point_add_c p q = EL.to_aff_point_add_lemma p q; point_add p q val point_double_c: SE.sqr_st ext_point_c mk_to_ed25519_comm_monoid let point_double_c p = EL.to_aff_point_double_lemma p; point_double p let mk_ed25519_concrete_ops : SE.concrete_ops ext_point_c = { SE.to = mk_to_ed25519_comm_monoid; SE.one = point_at_inifinity_c; SE.mul = point_add_c; SE.sqr = point_double_c; } // [a]P let point_mul (a:lbytes 32) (p:ext_point_c) : ext_point_c = SE.exp_fw mk_ed25519_concrete_ops p 256 (nat_from_bytes_le a) 4 // [a1]P1 + [a2]P2 let point_mul_double (a1:lbytes 32) (p1:ext_point_c) (a2:lbytes 32) (p2:ext_point_c) : ext_point_c = SE.exp_double_fw mk_ed25519_concrete_ops p1 256 (nat_from_bytes_le a1) p2 (nat_from_bytes_le a2) 5 // [a]G let point_mul_g (a:lbytes 32) : ext_point_c = EL.g_is_on_curve (); point_mul a g // [a1]G + [a2]P let point_mul_double_g (a1:lbytes 32) (a2:lbytes 32) (p:ext_point_c) : ext_point_c = EL.g_is_on_curve (); point_mul_double a1 g a2 p // [a1]G - [a2]P let point_negate_mul_double_g (a1:lbytes 32) (a2:lbytes 32) (p:ext_point_c) : ext_point_c = let p1 = point_negate p in EL.to_aff_point_negate p; point_mul_double_g a1 a2 p1 /// Ed25519 API let secret_expand (secret:lbytes 32) : (lbytes 32 & lbytes 32) = let h = Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 secret in let h_low : lbytes 32 = slice h 0 32 in let h_high : lbytes 32 = slice h 32 64 in let h_low = h_low.[ 0] <- h_low.[0] &. u8 0xf8 in let h_low = h_low.[31] <- (h_low.[31] &. u8 127) |. u8 64 in h_low, h_high let secret_to_public (secret:lbytes 32) : lbytes 32 = let a, dummy = secret_expand secret in point_compress (point_mul_g a) let expand_keys (secret:lbytes 32) : (lbytes 32 & lbytes 32 & lbytes 32) = let s, prefix = secret_expand secret in let pub = point_compress (point_mul_g s) in pub, s, prefix val sign_expanded (pub s prefix:lbytes 32) (msg:bytes{length msg <= max_size_t}) : lbytes 64 let sign_expanded pub s prefix msg = let len = length msg in let r = sha512_modq (32 + len) (Seq.append prefix msg) in let r' = point_mul_g (nat_to_bytes_le 32 r) in let rs = point_compress r' in let h = sha512_modq (64 + len) (Seq.append (concat rs pub) msg) in let s = (r + (h * nat_from_bytes_le s) % q) % q in concat #_ #32 #32 rs (nat_to_bytes_le 32 s)
false
false
Spec.Ed25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sign: secret:lbytes 32 -> msg:bytes{length msg <= max_size_t} -> lbytes 64
[]
Spec.Ed25519.sign
{ "file_name": "specs/Spec.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
secret: Lib.ByteSequence.lbytes 32 -> msg: Lib.ByteSequence.bytes{Lib.Sequence.length msg <= Lib.IntTypes.max_size_t} -> Lib.ByteSequence.lbytes 64
{ "end_col": 32, "end_line": 136, "start_col": 21, "start_line": 134 }
Prims.Tot
val expand_keys (secret: lbytes 32) : (lbytes 32 & lbytes 32 & lbytes 32)
[ { "abbrev": false, "full_module": "Spec.Ed25519.PointOps", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519.Lemmas", "short_module": "EL" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let expand_keys (secret:lbytes 32) : (lbytes 32 & lbytes 32 & lbytes 32) = let s, prefix = secret_expand secret in let pub = point_compress (point_mul_g s) in pub, s, prefix
val expand_keys (secret: lbytes 32) : (lbytes 32 & lbytes 32 & lbytes 32) let expand_keys (secret: lbytes 32) : (lbytes 32 & lbytes 32 & lbytes 32) =
false
null
false
let s, prefix = secret_expand secret in let pub = point_compress (point_mul_g s) in pub, s, prefix
{ "checked_file": "Spec.Ed25519.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Exponentiation.fsti.checked", "Spec.Ed25519.PointOps.fst.checked", "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Curve25519.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Ed25519.fst" }
[ "total" ]
[ "Lib.ByteSequence.lbytes", "FStar.Pervasives.Native.Mktuple3", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.Ed25519.PointOps.point_compress", "Spec.Ed25519.point_mul_g", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Spec.Ed25519.secret_expand" ]
[]
module Spec.Ed25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519 module LE = Lib.Exponentiation module SE = Spec.Exponentiation module EL = Spec.Ed25519.Lemmas include Spec.Ed25519.PointOps #reset-options "--fuel 0 --ifuel 0 --z3rlimit 100" inline_for_extraction let size_signature: size_nat = 64 let q: n:nat{n < pow2 256} = assert_norm(pow2 252 + 27742317777372353535851937790883648493 < pow2 255 - 19); (pow2 252 + 27742317777372353535851937790883648493) // Group order let max_input_length_sha512 = Some?.v (Spec.Hash.Definitions.max_input_length Spec.Hash.Definitions.SHA2_512) let _: squash(max_input_length_sha512 > pow2 32 + 64) = assert_norm (max_input_length_sha512 > pow2 32 + 64) let sha512_modq (len:nat{len <= max_input_length_sha512}) (s:bytes{length s = len}) : n:nat{n < pow2 256} = nat_from_bytes_le (Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 s) % q /// Point Multiplication let aff_point_c = p:aff_point{is_on_curve p} let aff_point_add_c (p:aff_point_c) (q:aff_point_c) : aff_point_c = EL.aff_point_add_lemma p q; aff_point_add p q let mk_ed25519_comm_monoid: LE.comm_monoid aff_point_c = { LE.one = aff_point_at_infinity; LE.mul = aff_point_add_c; LE.lemma_one = EL.aff_point_at_infinity_lemma; LE.lemma_mul_assoc = EL.aff_point_add_assoc_lemma; LE.lemma_mul_comm = EL.aff_point_add_comm_lemma; } let ext_point_c = p:ext_point{point_inv p} let mk_to_ed25519_comm_monoid : SE.to_comm_monoid ext_point_c = { SE.a_spec = aff_point_c; SE.comm_monoid = mk_ed25519_comm_monoid; SE.refl = (fun (x:ext_point_c) -> to_aff_point x); } val point_at_inifinity_c: SE.one_st ext_point_c mk_to_ed25519_comm_monoid let point_at_inifinity_c _ = EL.to_aff_point_at_infinity_lemma (); point_at_infinity val point_add_c: SE.mul_st ext_point_c mk_to_ed25519_comm_monoid let point_add_c p q = EL.to_aff_point_add_lemma p q; point_add p q val point_double_c: SE.sqr_st ext_point_c mk_to_ed25519_comm_monoid let point_double_c p = EL.to_aff_point_double_lemma p; point_double p let mk_ed25519_concrete_ops : SE.concrete_ops ext_point_c = { SE.to = mk_to_ed25519_comm_monoid; SE.one = point_at_inifinity_c; SE.mul = point_add_c; SE.sqr = point_double_c; } // [a]P let point_mul (a:lbytes 32) (p:ext_point_c) : ext_point_c = SE.exp_fw mk_ed25519_concrete_ops p 256 (nat_from_bytes_le a) 4 // [a1]P1 + [a2]P2 let point_mul_double (a1:lbytes 32) (p1:ext_point_c) (a2:lbytes 32) (p2:ext_point_c) : ext_point_c = SE.exp_double_fw mk_ed25519_concrete_ops p1 256 (nat_from_bytes_le a1) p2 (nat_from_bytes_le a2) 5 // [a]G let point_mul_g (a:lbytes 32) : ext_point_c = EL.g_is_on_curve (); point_mul a g // [a1]G + [a2]P let point_mul_double_g (a1:lbytes 32) (a2:lbytes 32) (p:ext_point_c) : ext_point_c = EL.g_is_on_curve (); point_mul_double a1 g a2 p // [a1]G - [a2]P let point_negate_mul_double_g (a1:lbytes 32) (a2:lbytes 32) (p:ext_point_c) : ext_point_c = let p1 = point_negate p in EL.to_aff_point_negate p; point_mul_double_g a1 a2 p1 /// Ed25519 API let secret_expand (secret:lbytes 32) : (lbytes 32 & lbytes 32) = let h = Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 secret in let h_low : lbytes 32 = slice h 0 32 in let h_high : lbytes 32 = slice h 32 64 in let h_low = h_low.[ 0] <- h_low.[0] &. u8 0xf8 in let h_low = h_low.[31] <- (h_low.[31] &. u8 127) |. u8 64 in h_low, h_high let secret_to_public (secret:lbytes 32) : lbytes 32 = let a, dummy = secret_expand secret in point_compress (point_mul_g a)
false
false
Spec.Ed25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val expand_keys (secret: lbytes 32) : (lbytes 32 & lbytes 32 & lbytes 32)
[]
Spec.Ed25519.expand_keys
{ "file_name": "specs/Spec.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
secret: Lib.ByteSequence.lbytes 32 -> (Lib.ByteSequence.lbytes 32 * Lib.ByteSequence.lbytes 32) * Lib.ByteSequence.lbytes 32
{ "end_col": 16, "end_line": 119, "start_col": 74, "start_line": 116 }
Prims.Tot
val sign_expanded (pub s prefix:lbytes 32) (msg:bytes{length msg <= max_size_t}) : lbytes 64
[ { "abbrev": false, "full_module": "Spec.Ed25519.PointOps", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519.Lemmas", "short_module": "EL" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sign_expanded pub s prefix msg = let len = length msg in let r = sha512_modq (32 + len) (Seq.append prefix msg) in let r' = point_mul_g (nat_to_bytes_le 32 r) in let rs = point_compress r' in let h = sha512_modq (64 + len) (Seq.append (concat rs pub) msg) in let s = (r + (h * nat_from_bytes_le s) % q) % q in concat #_ #32 #32 rs (nat_to_bytes_le 32 s)
val sign_expanded (pub s prefix:lbytes 32) (msg:bytes{length msg <= max_size_t}) : lbytes 64 let sign_expanded pub s prefix msg =
false
null
false
let len = length msg in let r = sha512_modq (32 + len) (Seq.append prefix msg) in let r' = point_mul_g (nat_to_bytes_le 32 r) in let rs = point_compress r' in let h = sha512_modq (64 + len) (Seq.append (concat rs pub) msg) in let s = (r + (h * nat_from_bytes_le s) % q) % q in concat #_ #32 #32 rs (nat_to_bytes_le 32 s)
{ "checked_file": "Spec.Ed25519.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Exponentiation.fsti.checked", "Spec.Ed25519.PointOps.fst.checked", "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Curve25519.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Ed25519.fst" }
[ "total" ]
[ "Lib.ByteSequence.lbytes", "Lib.ByteSequence.bytes", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.IntTypes.max_size_t", "Lib.Sequence.concat", "Lib.ByteSequence.nat_to_bytes_le", "Prims.int", "Prims.op_Modulus", "Prims.op_Addition", "FStar.Mul.op_Star", "Lib.ByteSequence.nat_from_bytes_le", "Spec.Ed25519.q", "Prims.nat", "Prims.op_LessThan", "Prims.pow2", "Spec.Ed25519.sha512_modq", "FStar.Seq.Base.append", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Spec.Ed25519.PointOps.point_compress", "Spec.Ed25519.ext_point_c", "Spec.Ed25519.point_mul_g" ]
[]
module Spec.Ed25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519 module LE = Lib.Exponentiation module SE = Spec.Exponentiation module EL = Spec.Ed25519.Lemmas include Spec.Ed25519.PointOps #reset-options "--fuel 0 --ifuel 0 --z3rlimit 100" inline_for_extraction let size_signature: size_nat = 64 let q: n:nat{n < pow2 256} = assert_norm(pow2 252 + 27742317777372353535851937790883648493 < pow2 255 - 19); (pow2 252 + 27742317777372353535851937790883648493) // Group order let max_input_length_sha512 = Some?.v (Spec.Hash.Definitions.max_input_length Spec.Hash.Definitions.SHA2_512) let _: squash(max_input_length_sha512 > pow2 32 + 64) = assert_norm (max_input_length_sha512 > pow2 32 + 64) let sha512_modq (len:nat{len <= max_input_length_sha512}) (s:bytes{length s = len}) : n:nat{n < pow2 256} = nat_from_bytes_le (Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 s) % q /// Point Multiplication let aff_point_c = p:aff_point{is_on_curve p} let aff_point_add_c (p:aff_point_c) (q:aff_point_c) : aff_point_c = EL.aff_point_add_lemma p q; aff_point_add p q let mk_ed25519_comm_monoid: LE.comm_monoid aff_point_c = { LE.one = aff_point_at_infinity; LE.mul = aff_point_add_c; LE.lemma_one = EL.aff_point_at_infinity_lemma; LE.lemma_mul_assoc = EL.aff_point_add_assoc_lemma; LE.lemma_mul_comm = EL.aff_point_add_comm_lemma; } let ext_point_c = p:ext_point{point_inv p} let mk_to_ed25519_comm_monoid : SE.to_comm_monoid ext_point_c = { SE.a_spec = aff_point_c; SE.comm_monoid = mk_ed25519_comm_monoid; SE.refl = (fun (x:ext_point_c) -> to_aff_point x); } val point_at_inifinity_c: SE.one_st ext_point_c mk_to_ed25519_comm_monoid let point_at_inifinity_c _ = EL.to_aff_point_at_infinity_lemma (); point_at_infinity val point_add_c: SE.mul_st ext_point_c mk_to_ed25519_comm_monoid let point_add_c p q = EL.to_aff_point_add_lemma p q; point_add p q val point_double_c: SE.sqr_st ext_point_c mk_to_ed25519_comm_monoid let point_double_c p = EL.to_aff_point_double_lemma p; point_double p let mk_ed25519_concrete_ops : SE.concrete_ops ext_point_c = { SE.to = mk_to_ed25519_comm_monoid; SE.one = point_at_inifinity_c; SE.mul = point_add_c; SE.sqr = point_double_c; } // [a]P let point_mul (a:lbytes 32) (p:ext_point_c) : ext_point_c = SE.exp_fw mk_ed25519_concrete_ops p 256 (nat_from_bytes_le a) 4 // [a1]P1 + [a2]P2 let point_mul_double (a1:lbytes 32) (p1:ext_point_c) (a2:lbytes 32) (p2:ext_point_c) : ext_point_c = SE.exp_double_fw mk_ed25519_concrete_ops p1 256 (nat_from_bytes_le a1) p2 (nat_from_bytes_le a2) 5 // [a]G let point_mul_g (a:lbytes 32) : ext_point_c = EL.g_is_on_curve (); point_mul a g // [a1]G + [a2]P let point_mul_double_g (a1:lbytes 32) (a2:lbytes 32) (p:ext_point_c) : ext_point_c = EL.g_is_on_curve (); point_mul_double a1 g a2 p // [a1]G - [a2]P let point_negate_mul_double_g (a1:lbytes 32) (a2:lbytes 32) (p:ext_point_c) : ext_point_c = let p1 = point_negate p in EL.to_aff_point_negate p; point_mul_double_g a1 a2 p1 /// Ed25519 API let secret_expand (secret:lbytes 32) : (lbytes 32 & lbytes 32) = let h = Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 secret in let h_low : lbytes 32 = slice h 0 32 in let h_high : lbytes 32 = slice h 32 64 in let h_low = h_low.[ 0] <- h_low.[0] &. u8 0xf8 in let h_low = h_low.[31] <- (h_low.[31] &. u8 127) |. u8 64 in h_low, h_high let secret_to_public (secret:lbytes 32) : lbytes 32 = let a, dummy = secret_expand secret in point_compress (point_mul_g a) let expand_keys (secret:lbytes 32) : (lbytes 32 & lbytes 32 & lbytes 32) = let s, prefix = secret_expand secret in let pub = point_compress (point_mul_g s) in pub, s, prefix
false
false
Spec.Ed25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sign_expanded (pub s prefix:lbytes 32) (msg:bytes{length msg <= max_size_t}) : lbytes 64
[]
Spec.Ed25519.sign_expanded
{ "file_name": "specs/Spec.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
pub: Lib.ByteSequence.lbytes 32 -> s: Lib.ByteSequence.lbytes 32 -> prefix: Lib.ByteSequence.lbytes 32 -> msg: Lib.ByteSequence.bytes{Lib.Sequence.length msg <= Lib.IntTypes.max_size_t} -> Lib.ByteSequence.lbytes 64
{ "end_col": 45, "end_line": 130, "start_col": 36, "start_line": 123 }
Prims.Tot
val secret_expand (secret: lbytes 32) : (lbytes 32 & lbytes 32)
[ { "abbrev": false, "full_module": "Spec.Ed25519.PointOps", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519.Lemmas", "short_module": "EL" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let secret_expand (secret:lbytes 32) : (lbytes 32 & lbytes 32) = let h = Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 secret in let h_low : lbytes 32 = slice h 0 32 in let h_high : lbytes 32 = slice h 32 64 in let h_low = h_low.[ 0] <- h_low.[0] &. u8 0xf8 in let h_low = h_low.[31] <- (h_low.[31] &. u8 127) |. u8 64 in h_low, h_high
val secret_expand (secret: lbytes 32) : (lbytes 32 & lbytes 32) let secret_expand (secret: lbytes 32) : (lbytes 32 & lbytes 32) =
false
null
false
let h = Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 secret in let h_low:lbytes 32 = slice h 0 32 in let h_high:lbytes 32 = slice h 32 64 in let h_low = h_low.[ 0 ] <- h_low.[ 0 ] &. u8 0xf8 in let h_low = h_low.[ 31 ] <- (h_low.[ 31 ] &. u8 127) |. u8 64 in h_low, h_high
{ "checked_file": "Spec.Ed25519.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Exponentiation.fsti.checked", "Spec.Ed25519.PointOps.fst.checked", "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Curve25519.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Ed25519.fst" }
[ "total" ]
[ "Lib.ByteSequence.lbytes", "FStar.Pervasives.Native.Mktuple2", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.l_and", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.upd", "Lib.IntTypes.logor", "Lib.IntTypes.logand", "Lib.Sequence.index", "Lib.IntTypes.mk_int", "Prims.l_Forall", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Prims.l_imp", "Prims.op_LessThan", "Prims.op_disEquality", "Prims.l_or", "FStar.Seq.Base.index", "Lib.Sequence.op_String_Assignment", "Lib.IntTypes.op_Bar_Dot", "Lib.IntTypes.op_Amp_Dot", "Lib.Sequence.op_String_Access", "Lib.IntTypes.u8", "Lib.Sequence.slice", "Lib.IntTypes.uint_t", "Spec.Hash.Definitions.hash_length'", "Spec.Hash.Definitions.SHA2_512", "Spec.Agile.Hash.hash", "FStar.Pervasives.Native.tuple2" ]
[]
module Spec.Ed25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519 module LE = Lib.Exponentiation module SE = Spec.Exponentiation module EL = Spec.Ed25519.Lemmas include Spec.Ed25519.PointOps #reset-options "--fuel 0 --ifuel 0 --z3rlimit 100" inline_for_extraction let size_signature: size_nat = 64 let q: n:nat{n < pow2 256} = assert_norm(pow2 252 + 27742317777372353535851937790883648493 < pow2 255 - 19); (pow2 252 + 27742317777372353535851937790883648493) // Group order let max_input_length_sha512 = Some?.v (Spec.Hash.Definitions.max_input_length Spec.Hash.Definitions.SHA2_512) let _: squash(max_input_length_sha512 > pow2 32 + 64) = assert_norm (max_input_length_sha512 > pow2 32 + 64) let sha512_modq (len:nat{len <= max_input_length_sha512}) (s:bytes{length s = len}) : n:nat{n < pow2 256} = nat_from_bytes_le (Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 s) % q /// Point Multiplication let aff_point_c = p:aff_point{is_on_curve p} let aff_point_add_c (p:aff_point_c) (q:aff_point_c) : aff_point_c = EL.aff_point_add_lemma p q; aff_point_add p q let mk_ed25519_comm_monoid: LE.comm_monoid aff_point_c = { LE.one = aff_point_at_infinity; LE.mul = aff_point_add_c; LE.lemma_one = EL.aff_point_at_infinity_lemma; LE.lemma_mul_assoc = EL.aff_point_add_assoc_lemma; LE.lemma_mul_comm = EL.aff_point_add_comm_lemma; } let ext_point_c = p:ext_point{point_inv p} let mk_to_ed25519_comm_monoid : SE.to_comm_monoid ext_point_c = { SE.a_spec = aff_point_c; SE.comm_monoid = mk_ed25519_comm_monoid; SE.refl = (fun (x:ext_point_c) -> to_aff_point x); } val point_at_inifinity_c: SE.one_st ext_point_c mk_to_ed25519_comm_monoid let point_at_inifinity_c _ = EL.to_aff_point_at_infinity_lemma (); point_at_infinity val point_add_c: SE.mul_st ext_point_c mk_to_ed25519_comm_monoid let point_add_c p q = EL.to_aff_point_add_lemma p q; point_add p q val point_double_c: SE.sqr_st ext_point_c mk_to_ed25519_comm_monoid let point_double_c p = EL.to_aff_point_double_lemma p; point_double p let mk_ed25519_concrete_ops : SE.concrete_ops ext_point_c = { SE.to = mk_to_ed25519_comm_monoid; SE.one = point_at_inifinity_c; SE.mul = point_add_c; SE.sqr = point_double_c; } // [a]P let point_mul (a:lbytes 32) (p:ext_point_c) : ext_point_c = SE.exp_fw mk_ed25519_concrete_ops p 256 (nat_from_bytes_le a) 4 // [a1]P1 + [a2]P2 let point_mul_double (a1:lbytes 32) (p1:ext_point_c) (a2:lbytes 32) (p2:ext_point_c) : ext_point_c = SE.exp_double_fw mk_ed25519_concrete_ops p1 256 (nat_from_bytes_le a1) p2 (nat_from_bytes_le a2) 5 // [a]G let point_mul_g (a:lbytes 32) : ext_point_c = EL.g_is_on_curve (); point_mul a g // [a1]G + [a2]P let point_mul_double_g (a1:lbytes 32) (a2:lbytes 32) (p:ext_point_c) : ext_point_c = EL.g_is_on_curve (); point_mul_double a1 g a2 p // [a1]G - [a2]P let point_negate_mul_double_g (a1:lbytes 32) (a2:lbytes 32) (p:ext_point_c) : ext_point_c = let p1 = point_negate p in EL.to_aff_point_negate p; point_mul_double_g a1 a2 p1 /// Ed25519 API
false
false
Spec.Ed25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val secret_expand (secret: lbytes 32) : (lbytes 32 & lbytes 32)
[]
Spec.Ed25519.secret_expand
{ "file_name": "specs/Spec.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
secret: Lib.ByteSequence.lbytes 32 -> Lib.ByteSequence.lbytes 32 * Lib.ByteSequence.lbytes 32
{ "end_col": 15, "end_line": 108, "start_col": 64, "start_line": 102 }
Prims.Tot
val verify: public:lbytes 32 -> msg:bytes{length msg <= max_size_t} -> signature:lbytes 64 -> bool
[ { "abbrev": false, "full_module": "Spec.Ed25519.PointOps", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519.Lemmas", "short_module": "EL" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let verify public msg signature = let len = length msg in let a' = point_decompress public in match a' with | None -> false | Some a' -> ( let rs = slice signature 0 32 in let r' = point_decompress rs in match r' with | None -> false | Some r' -> ( let sb = slice signature 32 64 in if nat_from_bytes_le sb >= q then false else ( let h = sha512_modq (64 + len) (Seq.append (concat rs public) msg) in let hb = nat_to_bytes_le 32 h in EL.point_decompress_lemma public; let exp_d = point_negate_mul_double_g sb hb a' in point_equal exp_d r' ) ) )
val verify: public:lbytes 32 -> msg:bytes{length msg <= max_size_t} -> signature:lbytes 64 -> bool let verify public msg signature =
false
null
false
let len = length msg in let a' = point_decompress public in match a' with | None -> false | Some a' -> (let rs = slice signature 0 32 in let r' = point_decompress rs in match r' with | None -> false | Some r' -> (let sb = slice signature 32 64 in if nat_from_bytes_le sb >= q then false else (let h = sha512_modq (64 + len) (Seq.append (concat rs public) msg) in let hb = nat_to_bytes_le 32 h in EL.point_decompress_lemma public; let exp_d = point_negate_mul_double_g sb hb a' in point_equal exp_d r')))
{ "checked_file": "Spec.Ed25519.fst.checked", "dependencies": [ "Spec.Hash.Definitions.fst.checked", "Spec.Exponentiation.fsti.checked", "Spec.Ed25519.PointOps.fst.checked", "Spec.Ed25519.Lemmas.fsti.checked", "Spec.Curve25519.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Ed25519.fst" }
[ "total" ]
[ "Lib.ByteSequence.lbytes", "Lib.ByteSequence.bytes", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.IntTypes.max_size_t", "Spec.Ed25519.PointOps.ext_point", "Prims.op_GreaterThanOrEqual", "Lib.ByteSequence.nat_from_bytes_le", "Spec.Ed25519.q", "Prims.bool", "Spec.Ed25519.PointOps.point_equal", "Spec.Ed25519.ext_point_c", "Spec.Ed25519.point_negate_mul_double_g", "Prims.unit", "Spec.Ed25519.Lemmas.point_decompress_lemma", "Lib.Sequence.seq", "Lib.IntTypes.int_t", "Prims.l_and", "Prims.eq2", "Prims.nat", "Prims.l_or", "Prims.op_LessThan", "Prims.pow2", "Prims.op_Multiply", "Lib.ByteSequence.nat_from_intseq_le", "Lib.ByteSequence.nat_to_bytes_le", "Spec.Ed25519.sha512_modq", "Prims.op_Addition", "FStar.Seq.Base.append", "Lib.Sequence.concat", "Prims.op_Subtraction", "Lib.Sequence.lseq", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.slice", "Prims.l_Forall", "FStar.Seq.Base.index", "Lib.Sequence.index", "Lib.Sequence.slice", "FStar.Pervasives.Native.option", "Spec.Ed25519.PointOps.point_decompress" ]
[]
module Spec.Ed25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519 module LE = Lib.Exponentiation module SE = Spec.Exponentiation module EL = Spec.Ed25519.Lemmas include Spec.Ed25519.PointOps #reset-options "--fuel 0 --ifuel 0 --z3rlimit 100" inline_for_extraction let size_signature: size_nat = 64 let q: n:nat{n < pow2 256} = assert_norm(pow2 252 + 27742317777372353535851937790883648493 < pow2 255 - 19); (pow2 252 + 27742317777372353535851937790883648493) // Group order let max_input_length_sha512 = Some?.v (Spec.Hash.Definitions.max_input_length Spec.Hash.Definitions.SHA2_512) let _: squash(max_input_length_sha512 > pow2 32 + 64) = assert_norm (max_input_length_sha512 > pow2 32 + 64) let sha512_modq (len:nat{len <= max_input_length_sha512}) (s:bytes{length s = len}) : n:nat{n < pow2 256} = nat_from_bytes_le (Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 s) % q /// Point Multiplication let aff_point_c = p:aff_point{is_on_curve p} let aff_point_add_c (p:aff_point_c) (q:aff_point_c) : aff_point_c = EL.aff_point_add_lemma p q; aff_point_add p q let mk_ed25519_comm_monoid: LE.comm_monoid aff_point_c = { LE.one = aff_point_at_infinity; LE.mul = aff_point_add_c; LE.lemma_one = EL.aff_point_at_infinity_lemma; LE.lemma_mul_assoc = EL.aff_point_add_assoc_lemma; LE.lemma_mul_comm = EL.aff_point_add_comm_lemma; } let ext_point_c = p:ext_point{point_inv p} let mk_to_ed25519_comm_monoid : SE.to_comm_monoid ext_point_c = { SE.a_spec = aff_point_c; SE.comm_monoid = mk_ed25519_comm_monoid; SE.refl = (fun (x:ext_point_c) -> to_aff_point x); } val point_at_inifinity_c: SE.one_st ext_point_c mk_to_ed25519_comm_monoid let point_at_inifinity_c _ = EL.to_aff_point_at_infinity_lemma (); point_at_infinity val point_add_c: SE.mul_st ext_point_c mk_to_ed25519_comm_monoid let point_add_c p q = EL.to_aff_point_add_lemma p q; point_add p q val point_double_c: SE.sqr_st ext_point_c mk_to_ed25519_comm_monoid let point_double_c p = EL.to_aff_point_double_lemma p; point_double p let mk_ed25519_concrete_ops : SE.concrete_ops ext_point_c = { SE.to = mk_to_ed25519_comm_monoid; SE.one = point_at_inifinity_c; SE.mul = point_add_c; SE.sqr = point_double_c; } // [a]P let point_mul (a:lbytes 32) (p:ext_point_c) : ext_point_c = SE.exp_fw mk_ed25519_concrete_ops p 256 (nat_from_bytes_le a) 4 // [a1]P1 + [a2]P2 let point_mul_double (a1:lbytes 32) (p1:ext_point_c) (a2:lbytes 32) (p2:ext_point_c) : ext_point_c = SE.exp_double_fw mk_ed25519_concrete_ops p1 256 (nat_from_bytes_le a1) p2 (nat_from_bytes_le a2) 5 // [a]G let point_mul_g (a:lbytes 32) : ext_point_c = EL.g_is_on_curve (); point_mul a g // [a1]G + [a2]P let point_mul_double_g (a1:lbytes 32) (a2:lbytes 32) (p:ext_point_c) : ext_point_c = EL.g_is_on_curve (); point_mul_double a1 g a2 p // [a1]G - [a2]P let point_negate_mul_double_g (a1:lbytes 32) (a2:lbytes 32) (p:ext_point_c) : ext_point_c = let p1 = point_negate p in EL.to_aff_point_negate p; point_mul_double_g a1 a2 p1 /// Ed25519 API let secret_expand (secret:lbytes 32) : (lbytes 32 & lbytes 32) = let h = Spec.Agile.Hash.hash Spec.Hash.Definitions.SHA2_512 secret in let h_low : lbytes 32 = slice h 0 32 in let h_high : lbytes 32 = slice h 32 64 in let h_low = h_low.[ 0] <- h_low.[0] &. u8 0xf8 in let h_low = h_low.[31] <- (h_low.[31] &. u8 127) |. u8 64 in h_low, h_high let secret_to_public (secret:lbytes 32) : lbytes 32 = let a, dummy = secret_expand secret in point_compress (point_mul_g a) let expand_keys (secret:lbytes 32) : (lbytes 32 & lbytes 32 & lbytes 32) = let s, prefix = secret_expand secret in let pub = point_compress (point_mul_g s) in pub, s, prefix val sign_expanded (pub s prefix:lbytes 32) (msg:bytes{length msg <= max_size_t}) : lbytes 64 let sign_expanded pub s prefix msg = let len = length msg in let r = sha512_modq (32 + len) (Seq.append prefix msg) in let r' = point_mul_g (nat_to_bytes_le 32 r) in let rs = point_compress r' in let h = sha512_modq (64 + len) (Seq.append (concat rs pub) msg) in let s = (r + (h * nat_from_bytes_le s) % q) % q in concat #_ #32 #32 rs (nat_to_bytes_le 32 s) val sign: secret:lbytes 32 -> msg:bytes{length msg <= max_size_t} -> lbytes 64 let sign secret msg = let pub, s, prefix = expand_keys secret in sign_expanded pub s prefix msg
false
false
Spec.Ed25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val verify: public:lbytes 32 -> msg:bytes{length msg <= max_size_t} -> signature:lbytes 64 -> bool
[]
Spec.Ed25519.verify
{ "file_name": "specs/Spec.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
public: Lib.ByteSequence.lbytes 32 -> msg: Lib.ByteSequence.bytes{Lib.Sequence.length msg <= Lib.IntTypes.max_size_t} -> signature: Lib.ByteSequence.lbytes 64 -> Prims.bool
{ "end_col": 3, "end_line": 162, "start_col": 33, "start_line": 140 }
FStar.Tactics.Effect.Tac
val name_of_binder (b: binder) : Tac string
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let name_of_binder (b : binder) : Tac string = unseal b.ppname
val name_of_binder (b: binder) : Tac string let name_of_binder (b: binder) : Tac string =
true
null
false
unseal b.ppname
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "FStar.Tactics.NamedView.binder", "FStar.Tactics.Unseal.unseal", "Prims.string", "FStar.Tactics.NamedView.__proj__Mkbinder__item__ppname" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val name_of_binder (b: binder) : Tac string
[]
FStar.Tactics.V2.Derived.name_of_binder
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
b: FStar.Tactics.NamedView.binder -> FStar.Tactics.Effect.Tac Prims.string
{ "end_col": 17, "end_line": 42, "start_col": 2, "start_line": 42 }
FStar.Tactics.Effect.Tac
val binding_to_string (b: binding) : Tac string
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let binding_to_string (b : binding) : Tac string = unseal b.ppname
val binding_to_string (b: binding) : Tac string let binding_to_string (b: binding) : Tac string =
true
null
false
unseal b.ppname
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "FStar.Tactics.NamedView.binding", "FStar.Tactics.Unseal.unseal", "Prims.string", "FStar.Reflection.V2.Data.__proj__Mkbinding__item__ppname" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")"
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val binding_to_string (b: binding) : Tac string
[]
FStar.Tactics.V2.Derived.binding_to_string
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
b: FStar.Tactics.NamedView.binding -> FStar.Tactics.Effect.Tac Prims.string
{ "end_col": 17, "end_line": 49, "start_col": 2, "start_line": 49 }
FStar.Tactics.Effect.Tac
val apply (t: term) : Tac unit
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let apply (t : term) : Tac unit = t_apply true false false t
val apply (t: term) : Tac unit let apply (t: term) : Tac unit =
true
null
false
t_apply true false false t
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "FStar.Tactics.NamedView.term", "FStar.Tactics.V2.Builtins.t_apply", "Prims.unit" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *)
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val apply (t: term) : Tac unit
[]
FStar.Tactics.V2.Derived.apply
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t: FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 30, "end_line": 182, "start_col": 4, "start_line": 182 }
FStar.Tactics.Effect.Tac
val topdown_rewrite (ctrl: (term -> Tac (bool * int))) (rw: (unit -> Tac unit)) : Tac unit
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let topdown_rewrite (ctrl : term -> Tac (bool * int)) (rw:unit -> Tac unit) : Tac unit = let ctrl' (t:term) : Tac (bool & ctrl_flag) = let b, i = ctrl t in let f = match i with | 0 -> Continue | 1 -> Skip | 2 -> Abort | _ -> fail "topdown_rewrite: bad value from ctrl" in b, f in ctrl_rewrite TopDown ctrl' rw
val topdown_rewrite (ctrl: (term -> Tac (bool * int))) (rw: (unit -> Tac unit)) : Tac unit let topdown_rewrite (ctrl: (term -> Tac (bool * int))) (rw: (unit -> Tac unit)) : Tac unit =
true
null
false
let ctrl' (t: term) : Tac (bool & ctrl_flag) = let b, i = ctrl t in let f = match i with | 0 -> Continue | 1 -> Skip | 2 -> Abort | _ -> fail "topdown_rewrite: bad value from ctrl" in b, f in ctrl_rewrite TopDown ctrl' rw
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "FStar.Tactics.NamedView.term", "FStar.Pervasives.Native.tuple2", "Prims.bool", "Prims.int", "Prims.unit", "FStar.Tactics.V2.Builtins.ctrl_rewrite", "FStar.Tactics.Types.TopDown", "FStar.Tactics.Types.ctrl_flag", "FStar.Pervasives.Native.Mktuple2", "FStar.Tactics.Types.Continue", "FStar.Tactics.Types.Skip", "FStar.Tactics.Types.Abort", "FStar.Tactics.V2.Derived.fail" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *) let commute_applied_match () : Tac unit = t_commute_applied_match () (** Similar to [apply_lemma], but will not instantiate uvars in the goal while applying. *) let apply_lemma_noinst (t : term) : Tac unit = t_apply_lemma true false t let apply_lemma_rw (t : term) : Tac unit = t_apply_lemma false true t (** [apply_raw f] is like [apply], but will ask for all arguments regardless of whether they appear free in further goals. See the explanation in [t_apply]. *) let apply_raw (t : term) : Tac unit = t_apply false false false t (** Like [exact], but allows for the term [e] to have a type [t] only under some guard [g], adding the guard as a goal. *) let exact_guard (t : term) : Tac unit = with_policy Goal (fun () -> t_exact true false t) (** (TODO: explain better) When running [pointwise tau] For every subterm [t'] of the goal's type [t], the engine will build a goal [Gamma |= t' == ?u] and run [tau] on it. When the tactic proves the goal, the engine will rewrite [t'] for [?u] in the original goal type. This is done for every subterm, bottom-up. This allows to recurse over an unknown goal type. By inspecting the goal, the [tau] can then decide what to do (to not do anything, use [trefl]). *) let t_pointwise (d:direction) (tau : unit -> Tac unit) : Tac unit = let ctrl (t:term) : Tac (bool & ctrl_flag) = true, Continue in let rw () : Tac unit = tau () in ctrl_rewrite d ctrl rw (** [topdown_rewrite ctrl rw] is used to rewrite those sub-terms [t] of the goal on which [fst (ctrl t)] returns true. On each such sub-term, [rw] is presented with an equality of goal of the form [Gamma |= t == ?u]. When [rw] proves the goal, the engine will rewrite [t] for [?u] in the original goal type. The goal formula is traversed top-down and the traversal can be controlled by [snd (ctrl t)]: When [snd (ctrl t) = 0], the traversal continues down through the position in the goal term. When [snd (ctrl t) = 1], the traversal continues to the next sub-tree of the goal. When [snd (ctrl t) = 2], no more rewrites are performed in the goal. *) let topdown_rewrite (ctrl : term -> Tac (bool * int))
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val topdown_rewrite (ctrl: (term -> Tac (bool * int))) (rw: (unit -> Tac unit)) : Tac unit
[]
FStar.Tactics.V2.Derived.topdown_rewrite
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
ctrl: (_: FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac (Prims.bool * Prims.int)) -> rw: (_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit) -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 33, "end_line": 274, "start_col": 3, "start_line": 263 }
FStar.Tactics.Effect.Tac
val exact_with_ref (t: term) : Tac unit
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t)
val exact_with_ref (t: term) : Tac unit let exact_with_ref (t: term) : Tac unit =
true
null
false
with_policy SMT (fun () -> t_exact true true t)
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "FStar.Tactics.NamedView.term", "FStar.Tactics.V2.Derived.with_policy", "Prims.unit", "FStar.Tactics.Types.SMT", "FStar.Tactics.V2.Builtins.t_exact" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *)
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exact_with_ref (t: term) : Tac unit
[]
FStar.Tactics.V2.Derived.exact_with_ref
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t: FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 51, "end_line": 114, "start_col": 4, "start_line": 114 }
FStar.Tactics.Effect.Tac
val apply_lemma_noinst (t: term) : Tac unit
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let apply_lemma_noinst (t : term) : Tac unit = t_apply_lemma true false t
val apply_lemma_noinst (t: term) : Tac unit let apply_lemma_noinst (t: term) : Tac unit =
true
null
false
t_apply_lemma true false t
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "FStar.Tactics.NamedView.term", "FStar.Tactics.V2.Builtins.t_apply_lemma", "Prims.unit" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *) let commute_applied_match () : Tac unit = t_commute_applied_match () (** Similar to [apply_lemma], but will not instantiate uvars in the goal while applying. *)
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val apply_lemma_noinst (t: term) : Tac unit
[]
FStar.Tactics.V2.Derived.apply_lemma_noinst
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t: FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 30, "end_line": 209, "start_col": 4, "start_line": 209 }
FStar.Tactics.Effect.Tac
val cur_env: Prims.unit -> Tac env
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let cur_env () : Tac env = goal_env (_cur_goal ())
val cur_env: Prims.unit -> Tac env let cur_env () : Tac env =
true
null
false
goal_env (_cur_goal ())
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "Prims.unit", "FStar.Tactics.Types.goal_env", "FStar.Reflection.Types.env", "FStar.Tactics.Types.goal", "FStar.Tactics.V2.Derived._cur_goal" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val cur_env: Prims.unit -> Tac env
[]
FStar.Tactics.V2.Derived.cur_env
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Tactics.Effect.Tac FStar.Reflection.Types.env
{ "end_col": 50, "end_line": 78, "start_col": 27, "start_line": 78 }
FStar.Tactics.Effect.Tac
val unify (t1 t2: term) : Tac bool
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let unify (t1 t2 : term) : Tac bool = let e = cur_env () in unify_env e t1 t2
val unify (t1 t2: term) : Tac bool let unify (t1 t2: term) : Tac bool =
true
null
false
let e = cur_env () in unify_env e t1 t2
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "FStar.Tactics.NamedView.term", "FStar.Tactics.V2.Builtins.unify_env", "Prims.bool", "FStar.Reflection.Types.env", "FStar.Tactics.V2.Derived.cur_env" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *) let commute_applied_match () : Tac unit = t_commute_applied_match () (** Similar to [apply_lemma], but will not instantiate uvars in the goal while applying. *) let apply_lemma_noinst (t : term) : Tac unit = t_apply_lemma true false t let apply_lemma_rw (t : term) : Tac unit = t_apply_lemma false true t (** [apply_raw f] is like [apply], but will ask for all arguments regardless of whether they appear free in further goals. See the explanation in [t_apply]. *) let apply_raw (t : term) : Tac unit = t_apply false false false t (** Like [exact], but allows for the term [e] to have a type [t] only under some guard [g], adding the guard as a goal. *) let exact_guard (t : term) : Tac unit = with_policy Goal (fun () -> t_exact true false t) (** (TODO: explain better) When running [pointwise tau] For every subterm [t'] of the goal's type [t], the engine will build a goal [Gamma |= t' == ?u] and run [tau] on it. When the tactic proves the goal, the engine will rewrite [t'] for [?u] in the original goal type. This is done for every subterm, bottom-up. This allows to recurse over an unknown goal type. By inspecting the goal, the [tau] can then decide what to do (to not do anything, use [trefl]). *) let t_pointwise (d:direction) (tau : unit -> Tac unit) : Tac unit = let ctrl (t:term) : Tac (bool & ctrl_flag) = true, Continue in let rw () : Tac unit = tau () in ctrl_rewrite d ctrl rw (** [topdown_rewrite ctrl rw] is used to rewrite those sub-terms [t] of the goal on which [fst (ctrl t)] returns true. On each such sub-term, [rw] is presented with an equality of goal of the form [Gamma |= t == ?u]. When [rw] proves the goal, the engine will rewrite [t] for [?u] in the original goal type. The goal formula is traversed top-down and the traversal can be controlled by [snd (ctrl t)]: When [snd (ctrl t) = 0], the traversal continues down through the position in the goal term. When [snd (ctrl t) = 1], the traversal continues to the next sub-tree of the goal. When [snd (ctrl t) = 2], no more rewrites are performed in the goal. *) let topdown_rewrite (ctrl : term -> Tac (bool * int)) (rw:unit -> Tac unit) : Tac unit = let ctrl' (t:term) : Tac (bool & ctrl_flag) = let b, i = ctrl t in let f = match i with | 0 -> Continue | 1 -> Skip | 2 -> Abort | _ -> fail "topdown_rewrite: bad value from ctrl" in b, f in ctrl_rewrite TopDown ctrl' rw let pointwise (tau : unit -> Tac unit) : Tac unit = t_pointwise BottomUp tau let pointwise' (tau : unit -> Tac unit) : Tac unit = t_pointwise TopDown tau let cur_module () : Tac name = moduleof (top_env ()) let open_modules () : Tac (list name) = env_open_modules (top_env ()) let fresh_uvar (o : option typ) : Tac term = let e = cur_env () in uvar_env e o
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val unify (t1 t2: term) : Tac bool
[]
FStar.Tactics.V2.Derived.unify
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t1: FStar.Tactics.NamedView.term -> t2: FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac Prims.bool
{ "end_col": 21, "end_line": 291, "start_col": 37, "start_line": 289 }
FStar.Tactics.Effect.Tac
val ngoals: Prims.unit -> Tac int
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ngoals () : Tac int = List.Tot.Base.length (goals ())
val ngoals: Prims.unit -> Tac int let ngoals () : Tac int =
true
null
false
List.Tot.Base.length (goals ())
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "Prims.unit", "FStar.List.Tot.Base.length", "FStar.Tactics.Types.goal", "Prims.int", "Prims.list", "FStar.Tactics.V2.Derived.goals" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *) let commute_applied_match () : Tac unit = t_commute_applied_match () (** Similar to [apply_lemma], but will not instantiate uvars in the goal while applying. *) let apply_lemma_noinst (t : term) : Tac unit = t_apply_lemma true false t let apply_lemma_rw (t : term) : Tac unit = t_apply_lemma false true t (** [apply_raw f] is like [apply], but will ask for all arguments regardless of whether they appear free in further goals. See the explanation in [t_apply]. *) let apply_raw (t : term) : Tac unit = t_apply false false false t (** Like [exact], but allows for the term [e] to have a type [t] only under some guard [g], adding the guard as a goal. *) let exact_guard (t : term) : Tac unit = with_policy Goal (fun () -> t_exact true false t) (** (TODO: explain better) When running [pointwise tau] For every subterm [t'] of the goal's type [t], the engine will build a goal [Gamma |= t' == ?u] and run [tau] on it. When the tactic proves the goal, the engine will rewrite [t'] for [?u] in the original goal type. This is done for every subterm, bottom-up. This allows to recurse over an unknown goal type. By inspecting the goal, the [tau] can then decide what to do (to not do anything, use [trefl]). *) let t_pointwise (d:direction) (tau : unit -> Tac unit) : Tac unit = let ctrl (t:term) : Tac (bool & ctrl_flag) = true, Continue in let rw () : Tac unit = tau () in ctrl_rewrite d ctrl rw (** [topdown_rewrite ctrl rw] is used to rewrite those sub-terms [t] of the goal on which [fst (ctrl t)] returns true. On each such sub-term, [rw] is presented with an equality of goal of the form [Gamma |= t == ?u]. When [rw] proves the goal, the engine will rewrite [t] for [?u] in the original goal type. The goal formula is traversed top-down and the traversal can be controlled by [snd (ctrl t)]: When [snd (ctrl t) = 0], the traversal continues down through the position in the goal term. When [snd (ctrl t) = 1], the traversal continues to the next sub-tree of the goal. When [snd (ctrl t) = 2], no more rewrites are performed in the goal. *) let topdown_rewrite (ctrl : term -> Tac (bool * int)) (rw:unit -> Tac unit) : Tac unit = let ctrl' (t:term) : Tac (bool & ctrl_flag) = let b, i = ctrl t in let f = match i with | 0 -> Continue | 1 -> Skip | 2 -> Abort | _ -> fail "topdown_rewrite: bad value from ctrl" in b, f in ctrl_rewrite TopDown ctrl' rw let pointwise (tau : unit -> Tac unit) : Tac unit = t_pointwise BottomUp tau let pointwise' (tau : unit -> Tac unit) : Tac unit = t_pointwise TopDown tau let cur_module () : Tac name = moduleof (top_env ()) let open_modules () : Tac (list name) = env_open_modules (top_env ()) let fresh_uvar (o : option typ) : Tac term = let e = cur_env () in uvar_env e o let unify (t1 t2 : term) : Tac bool = let e = cur_env () in unify_env e t1 t2 let unify_guard (t1 t2 : term) : Tac bool = let e = cur_env () in unify_guard_env e t1 t2 let tmatch (t1 t2 : term) : Tac bool = let e = cur_env () in match_env e t1 t2 (** [divide n t1 t2] will split the current set of goals into the [n] first ones, and the rest. It then runs [t1] on the first set, and [t2] on the second, returning both results (and concatenating remaining goals). *) let divide (n:int) (l : unit -> Tac 'a) (r : unit -> Tac 'b) : Tac ('a * 'b) = if n < 0 then fail "divide: negative n"; let gs, sgs = goals (), smt_goals () in let gs1, gs2 = List.Tot.Base.splitAt n gs in set_goals gs1; set_smt_goals []; let x = l () in let gsl, sgsl = goals (), smt_goals () in set_goals gs2; set_smt_goals []; let y = r () in let gsr, sgsr = goals (), smt_goals () in set_goals (gsl @ gsr); set_smt_goals (sgs @ sgsl @ sgsr); (x, y) let rec iseq (ts : list (unit -> Tac unit)) : Tac unit = match ts with | t::ts -> let _ = divide 1 t (fun () -> iseq ts) in () | [] -> () (** [focus t] runs [t ()] on the current active goal, hiding all others and restoring them at the end. *) let focus (t : unit -> Tac 'a) : Tac 'a = match goals () with | [] -> fail "focus: no goals" | g::gs -> let sgs = smt_goals () in set_goals [g]; set_smt_goals []; let x = t () in set_goals (goals () @ gs); set_smt_goals (smt_goals () @ sgs); x (** Similar to [dump], but only dumping the current goal. *) let dump1 (m : string) = focus (fun () -> dump m) let rec mapAll (t : unit -> Tac 'a) : Tac (list 'a) = match goals () with | [] -> [] | _::_ -> let (h, t) = divide 1 t (fun () -> mapAll t) in h::t let rec iterAll (t : unit -> Tac unit) : Tac unit = (* Could use mapAll, but why even build that list *) match goals () with | [] -> () | _::_ -> let _ = divide 1 t (fun () -> iterAll t) in () let iterAllSMT (t : unit -> Tac unit) : Tac unit = let gs, sgs = goals (), smt_goals () in set_goals sgs; set_smt_goals []; iterAll t; let gs', sgs' = goals (), smt_goals () in set_goals gs; set_smt_goals (gs'@sgs') (** Runs tactic [t1] on the current goal, and then tactic [t2] on *each* subgoal produced by [t1]. Each invocation of [t2] runs on a proofstate with a single goal (they're "focused"). *) let seq (f : unit -> Tac unit) (g : unit -> Tac unit) : Tac unit = focus (fun () -> f (); iterAll g) let exact_args (qs : list aqualv) (t : term) : Tac unit = focus (fun () -> let n = List.Tot.Base.length qs in let uvs = repeatn n (fun () -> fresh_uvar None) in let t' = mk_app t (zip uvs qs) in exact t'; iter (fun uv -> if is_uvar uv then unshelve uv else ()) (L.rev uvs) ) let exact_n (n : int) (t : term) : Tac unit = exact_args (repeatn n (fun () -> Q_Explicit)) t
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ngoals: Prims.unit -> Tac int
[]
FStar.Tactics.V2.Derived.ngoals
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.int
{ "end_col": 57, "end_line": 382, "start_col": 26, "start_line": 382 }
FStar.Tactics.Effect.Tac
val guards_to_smt: Prims.unit -> Tac unit
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let guards_to_smt () : Tac unit = let _ = repeat skip_guard in ()
val guards_to_smt: Prims.unit -> Tac unit let guards_to_smt () : Tac unit =
true
null
false
let _ = repeat skip_guard in ()
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "Prims.unit", "Prims.list", "FStar.Tactics.V2.Derived.repeat", "FStar.Tactics.V2.Derived.skip_guard" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *) let commute_applied_match () : Tac unit = t_commute_applied_match () (** Similar to [apply_lemma], but will not instantiate uvars in the goal while applying. *) let apply_lemma_noinst (t : term) : Tac unit = t_apply_lemma true false t let apply_lemma_rw (t : term) : Tac unit = t_apply_lemma false true t (** [apply_raw f] is like [apply], but will ask for all arguments regardless of whether they appear free in further goals. See the explanation in [t_apply]. *) let apply_raw (t : term) : Tac unit = t_apply false false false t (** Like [exact], but allows for the term [e] to have a type [t] only under some guard [g], adding the guard as a goal. *) let exact_guard (t : term) : Tac unit = with_policy Goal (fun () -> t_exact true false t) (** (TODO: explain better) When running [pointwise tau] For every subterm [t'] of the goal's type [t], the engine will build a goal [Gamma |= t' == ?u] and run [tau] on it. When the tactic proves the goal, the engine will rewrite [t'] for [?u] in the original goal type. This is done for every subterm, bottom-up. This allows to recurse over an unknown goal type. By inspecting the goal, the [tau] can then decide what to do (to not do anything, use [trefl]). *) let t_pointwise (d:direction) (tau : unit -> Tac unit) : Tac unit = let ctrl (t:term) : Tac (bool & ctrl_flag) = true, Continue in let rw () : Tac unit = tau () in ctrl_rewrite d ctrl rw (** [topdown_rewrite ctrl rw] is used to rewrite those sub-terms [t] of the goal on which [fst (ctrl t)] returns true. On each such sub-term, [rw] is presented with an equality of goal of the form [Gamma |= t == ?u]. When [rw] proves the goal, the engine will rewrite [t] for [?u] in the original goal type. The goal formula is traversed top-down and the traversal can be controlled by [snd (ctrl t)]: When [snd (ctrl t) = 0], the traversal continues down through the position in the goal term. When [snd (ctrl t) = 1], the traversal continues to the next sub-tree of the goal. When [snd (ctrl t) = 2], no more rewrites are performed in the goal. *) let topdown_rewrite (ctrl : term -> Tac (bool * int)) (rw:unit -> Tac unit) : Tac unit = let ctrl' (t:term) : Tac (bool & ctrl_flag) = let b, i = ctrl t in let f = match i with | 0 -> Continue | 1 -> Skip | 2 -> Abort | _ -> fail "topdown_rewrite: bad value from ctrl" in b, f in ctrl_rewrite TopDown ctrl' rw let pointwise (tau : unit -> Tac unit) : Tac unit = t_pointwise BottomUp tau let pointwise' (tau : unit -> Tac unit) : Tac unit = t_pointwise TopDown tau let cur_module () : Tac name = moduleof (top_env ()) let open_modules () : Tac (list name) = env_open_modules (top_env ()) let fresh_uvar (o : option typ) : Tac term = let e = cur_env () in uvar_env e o let unify (t1 t2 : term) : Tac bool = let e = cur_env () in unify_env e t1 t2 let unify_guard (t1 t2 : term) : Tac bool = let e = cur_env () in unify_guard_env e t1 t2 let tmatch (t1 t2 : term) : Tac bool = let e = cur_env () in match_env e t1 t2 (** [divide n t1 t2] will split the current set of goals into the [n] first ones, and the rest. It then runs [t1] on the first set, and [t2] on the second, returning both results (and concatenating remaining goals). *) let divide (n:int) (l : unit -> Tac 'a) (r : unit -> Tac 'b) : Tac ('a * 'b) = if n < 0 then fail "divide: negative n"; let gs, sgs = goals (), smt_goals () in let gs1, gs2 = List.Tot.Base.splitAt n gs in set_goals gs1; set_smt_goals []; let x = l () in let gsl, sgsl = goals (), smt_goals () in set_goals gs2; set_smt_goals []; let y = r () in let gsr, sgsr = goals (), smt_goals () in set_goals (gsl @ gsr); set_smt_goals (sgs @ sgsl @ sgsr); (x, y) let rec iseq (ts : list (unit -> Tac unit)) : Tac unit = match ts with | t::ts -> let _ = divide 1 t (fun () -> iseq ts) in () | [] -> () (** [focus t] runs [t ()] on the current active goal, hiding all others and restoring them at the end. *) let focus (t : unit -> Tac 'a) : Tac 'a = match goals () with | [] -> fail "focus: no goals" | g::gs -> let sgs = smt_goals () in set_goals [g]; set_smt_goals []; let x = t () in set_goals (goals () @ gs); set_smt_goals (smt_goals () @ sgs); x (** Similar to [dump], but only dumping the current goal. *) let dump1 (m : string) = focus (fun () -> dump m) let rec mapAll (t : unit -> Tac 'a) : Tac (list 'a) = match goals () with | [] -> [] | _::_ -> let (h, t) = divide 1 t (fun () -> mapAll t) in h::t let rec iterAll (t : unit -> Tac unit) : Tac unit = (* Could use mapAll, but why even build that list *) match goals () with | [] -> () | _::_ -> let _ = divide 1 t (fun () -> iterAll t) in () let iterAllSMT (t : unit -> Tac unit) : Tac unit = let gs, sgs = goals (), smt_goals () in set_goals sgs; set_smt_goals []; iterAll t; let gs', sgs' = goals (), smt_goals () in set_goals gs; set_smt_goals (gs'@sgs') (** Runs tactic [t1] on the current goal, and then tactic [t2] on *each* subgoal produced by [t1]. Each invocation of [t2] runs on a proofstate with a single goal (they're "focused"). *) let seq (f : unit -> Tac unit) (g : unit -> Tac unit) : Tac unit = focus (fun () -> f (); iterAll g) let exact_args (qs : list aqualv) (t : term) : Tac unit = focus (fun () -> let n = List.Tot.Base.length qs in let uvs = repeatn n (fun () -> fresh_uvar None) in let t' = mk_app t (zip uvs qs) in exact t'; iter (fun uv -> if is_uvar uv then unshelve uv else ()) (L.rev uvs) ) let exact_n (n : int) (t : term) : Tac unit = exact_args (repeatn n (fun () -> Q_Explicit)) t (** [ngoals ()] returns the number of goals *) let ngoals () : Tac int = List.Tot.Base.length (goals ()) (** [ngoals_smt ()] returns the number of SMT goals *) let ngoals_smt () : Tac int = List.Tot.Base.length (smt_goals ()) (* sigh GGG fix names!! *) let fresh_namedv_named (s:string) : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal s; sort = seal (pack Tv_Unknown); uniq = n; }) (* Create a fresh bound variable (bv), using a generic name. See also [fresh_namedv_named]. *) let fresh_namedv () : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal ("x" ^ string_of_int n); sort = seal (pack Tv_Unknown); uniq = n; }) let fresh_binder_named (s : string) (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal s; sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_binder (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_implicit_binder (t : typ) : Tac binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Implicit; attrs = [] ; } let guard (b : bool) : TacH unit (requires (fun _ -> True)) (ensures (fun ps r -> if b then Success? r /\ Success?.ps r == ps else Failed? r)) (* ^ the proofstate on failure is not exactly equal (has the psc set) *) = if not b then fail "guard failed" else () let try_with (f : unit -> Tac 'a) (h : exn -> Tac 'a) : Tac 'a = match catch f with | Inl e -> h e | Inr x -> x let trytac (t : unit -> Tac 'a) : Tac (option 'a) = try Some (t ()) with | _ -> None let or_else (#a:Type) (t1 : unit -> Tac a) (t2 : unit -> Tac a) : Tac a = try t1 () with | _ -> t2 () val (<|>) : (unit -> Tac 'a) -> (unit -> Tac 'a) -> (unit -> Tac 'a) let (<|>) t1 t2 = fun () -> or_else t1 t2 let first (ts : list (unit -> Tac 'a)) : Tac 'a = L.fold_right (<|>) ts (fun () -> fail "no tactics to try") () let rec repeat (#a:Type) (t : unit -> Tac a) : Tac (list a) = match catch t with | Inl _ -> [] | Inr x -> x :: repeat t let repeat1 (#a:Type) (t : unit -> Tac a) : Tac (list a) = t () :: repeat t let repeat' (f : unit -> Tac 'a) : Tac unit = let _ = repeat f in () let norm_term (s : list norm_step) (t : term) : Tac term = let e = try cur_env () with | _ -> top_env () in norm_term_env e s t (** Join all of the SMT goals into one. This helps when all of them are expected to be similar, and therefore easier to prove at once by the SMT solver. TODO: would be nice to try to join them in a more meaningful way, as the order can matter. *) let join_all_smt_goals () = let gs, sgs = goals (), smt_goals () in set_smt_goals []; set_goals sgs; repeat' join; let sgs' = goals () in // should be a single one set_goals gs; set_smt_goals sgs' let discard (tau : unit -> Tac 'a) : unit -> Tac unit = fun () -> let _ = tau () in () // TODO: do we want some value out of this? let rec repeatseq (#a:Type) (t : unit -> Tac a) : Tac unit = let _ = trytac (fun () -> (discard t) `seq` (discard (fun () -> repeatseq t))) in () let tadmit () = tadmit_t (`()) let admit1 () : Tac unit = tadmit () let admit_all () : Tac unit = let _ = repeat tadmit in () (** [is_guard] returns whether the current goal arose from a typechecking guard *) let is_guard () : Tac bool = Tactics.Types.is_guard (_cur_goal ()) let skip_guard () : Tac unit = if is_guard () then smt () else fail ""
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val guards_to_smt: Prims.unit -> Tac unit
[]
FStar.Tactics.V2.Derived.guards_to_smt
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 6, "end_line": 526, "start_col": 33, "start_line": 524 }
FStar.Tactics.Effect.Tac
val apply_raw (t: term) : Tac unit
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let apply_raw (t : term) : Tac unit = t_apply false false false t
val apply_raw (t: term) : Tac unit let apply_raw (t: term) : Tac unit =
true
null
false
t_apply false false false t
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "FStar.Tactics.NamedView.term", "FStar.Tactics.V2.Builtins.t_apply", "Prims.unit" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *) let commute_applied_match () : Tac unit = t_commute_applied_match () (** Similar to [apply_lemma], but will not instantiate uvars in the goal while applying. *) let apply_lemma_noinst (t : term) : Tac unit = t_apply_lemma true false t let apply_lemma_rw (t : term) : Tac unit = t_apply_lemma false true t (** [apply_raw f] is like [apply], but will ask for all arguments regardless of whether they appear free in further goals. See the explanation in [t_apply]. *)
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val apply_raw (t: term) : Tac unit
[]
FStar.Tactics.V2.Derived.apply_raw
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t: FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 31, "end_line": 218, "start_col": 4, "start_line": 218 }
FStar.Tactics.Effect.Tac
val goals: Prims.unit -> Tac (list goal)
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let goals () : Tac (list goal) = goals_of (get ())
val goals: Prims.unit -> Tac (list goal) let goals () : Tac (list goal) =
true
null
false
goals_of (get ())
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "Prims.unit", "FStar.Tactics.Types.goals_of", "Prims.list", "FStar.Tactics.Types.goal", "FStar.Tactics.Types.proofstate", "FStar.Tactics.Effect.get" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val goals: Prims.unit -> Tac (list goal)
[]
FStar.Tactics.V2.Derived.goals
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Tactics.Effect.Tac (Prims.list FStar.Tactics.Types.goal)
{ "end_col": 50, "end_line": 59, "start_col": 33, "start_line": 59 }
FStar.Tactics.Effect.Tac
val whnf: Prims.unit -> Tac unit
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let whnf () : Tac unit = norm [weak; hnf; primops; delta]
val whnf: Prims.unit -> Tac unit let whnf () : Tac unit =
true
null
false
norm [weak; hnf; primops; delta]
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "Prims.unit", "FStar.Tactics.V2.Builtins.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.weak", "FStar.Pervasives.hnf", "FStar.Pervasives.primops", "FStar.Pervasives.delta", "Prims.Nil" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *) let commute_applied_match () : Tac unit = t_commute_applied_match () (** Similar to [apply_lemma], but will not instantiate uvars in the goal while applying. *) let apply_lemma_noinst (t : term) : Tac unit = t_apply_lemma true false t let apply_lemma_rw (t : term) : Tac unit = t_apply_lemma false true t (** [apply_raw f] is like [apply], but will ask for all arguments regardless of whether they appear free in further goals. See the explanation in [t_apply]. *) let apply_raw (t : term) : Tac unit = t_apply false false false t (** Like [exact], but allows for the term [e] to have a type [t] only under some guard [g], adding the guard as a goal. *) let exact_guard (t : term) : Tac unit = with_policy Goal (fun () -> t_exact true false t) (** (TODO: explain better) When running [pointwise tau] For every subterm [t'] of the goal's type [t], the engine will build a goal [Gamma |= t' == ?u] and run [tau] on it. When the tactic proves the goal, the engine will rewrite [t'] for [?u] in the original goal type. This is done for every subterm, bottom-up. This allows to recurse over an unknown goal type. By inspecting the goal, the [tau] can then decide what to do (to not do anything, use [trefl]). *) let t_pointwise (d:direction) (tau : unit -> Tac unit) : Tac unit = let ctrl (t:term) : Tac (bool & ctrl_flag) = true, Continue in let rw () : Tac unit = tau () in ctrl_rewrite d ctrl rw (** [topdown_rewrite ctrl rw] is used to rewrite those sub-terms [t] of the goal on which [fst (ctrl t)] returns true. On each such sub-term, [rw] is presented with an equality of goal of the form [Gamma |= t == ?u]. When [rw] proves the goal, the engine will rewrite [t] for [?u] in the original goal type. The goal formula is traversed top-down and the traversal can be controlled by [snd (ctrl t)]: When [snd (ctrl t) = 0], the traversal continues down through the position in the goal term. When [snd (ctrl t) = 1], the traversal continues to the next sub-tree of the goal. When [snd (ctrl t) = 2], no more rewrites are performed in the goal. *) let topdown_rewrite (ctrl : term -> Tac (bool * int)) (rw:unit -> Tac unit) : Tac unit = let ctrl' (t:term) : Tac (bool & ctrl_flag) = let b, i = ctrl t in let f = match i with | 0 -> Continue | 1 -> Skip | 2 -> Abort | _ -> fail "topdown_rewrite: bad value from ctrl" in b, f in ctrl_rewrite TopDown ctrl' rw let pointwise (tau : unit -> Tac unit) : Tac unit = t_pointwise BottomUp tau let pointwise' (tau : unit -> Tac unit) : Tac unit = t_pointwise TopDown tau let cur_module () : Tac name = moduleof (top_env ()) let open_modules () : Tac (list name) = env_open_modules (top_env ()) let fresh_uvar (o : option typ) : Tac term = let e = cur_env () in uvar_env e o let unify (t1 t2 : term) : Tac bool = let e = cur_env () in unify_env e t1 t2 let unify_guard (t1 t2 : term) : Tac bool = let e = cur_env () in unify_guard_env e t1 t2 let tmatch (t1 t2 : term) : Tac bool = let e = cur_env () in match_env e t1 t2 (** [divide n t1 t2] will split the current set of goals into the [n] first ones, and the rest. It then runs [t1] on the first set, and [t2] on the second, returning both results (and concatenating remaining goals). *) let divide (n:int) (l : unit -> Tac 'a) (r : unit -> Tac 'b) : Tac ('a * 'b) = if n < 0 then fail "divide: negative n"; let gs, sgs = goals (), smt_goals () in let gs1, gs2 = List.Tot.Base.splitAt n gs in set_goals gs1; set_smt_goals []; let x = l () in let gsl, sgsl = goals (), smt_goals () in set_goals gs2; set_smt_goals []; let y = r () in let gsr, sgsr = goals (), smt_goals () in set_goals (gsl @ gsr); set_smt_goals (sgs @ sgsl @ sgsr); (x, y) let rec iseq (ts : list (unit -> Tac unit)) : Tac unit = match ts with | t::ts -> let _ = divide 1 t (fun () -> iseq ts) in () | [] -> () (** [focus t] runs [t ()] on the current active goal, hiding all others and restoring them at the end. *) let focus (t : unit -> Tac 'a) : Tac 'a = match goals () with | [] -> fail "focus: no goals" | g::gs -> let sgs = smt_goals () in set_goals [g]; set_smt_goals []; let x = t () in set_goals (goals () @ gs); set_smt_goals (smt_goals () @ sgs); x (** Similar to [dump], but only dumping the current goal. *) let dump1 (m : string) = focus (fun () -> dump m) let rec mapAll (t : unit -> Tac 'a) : Tac (list 'a) = match goals () with | [] -> [] | _::_ -> let (h, t) = divide 1 t (fun () -> mapAll t) in h::t let rec iterAll (t : unit -> Tac unit) : Tac unit = (* Could use mapAll, but why even build that list *) match goals () with | [] -> () | _::_ -> let _ = divide 1 t (fun () -> iterAll t) in () let iterAllSMT (t : unit -> Tac unit) : Tac unit = let gs, sgs = goals (), smt_goals () in set_goals sgs; set_smt_goals []; iterAll t; let gs', sgs' = goals (), smt_goals () in set_goals gs; set_smt_goals (gs'@sgs') (** Runs tactic [t1] on the current goal, and then tactic [t2] on *each* subgoal produced by [t1]. Each invocation of [t2] runs on a proofstate with a single goal (they're "focused"). *) let seq (f : unit -> Tac unit) (g : unit -> Tac unit) : Tac unit = focus (fun () -> f (); iterAll g) let exact_args (qs : list aqualv) (t : term) : Tac unit = focus (fun () -> let n = List.Tot.Base.length qs in let uvs = repeatn n (fun () -> fresh_uvar None) in let t' = mk_app t (zip uvs qs) in exact t'; iter (fun uv -> if is_uvar uv then unshelve uv else ()) (L.rev uvs) ) let exact_n (n : int) (t : term) : Tac unit = exact_args (repeatn n (fun () -> Q_Explicit)) t (** [ngoals ()] returns the number of goals *) let ngoals () : Tac int = List.Tot.Base.length (goals ()) (** [ngoals_smt ()] returns the number of SMT goals *) let ngoals_smt () : Tac int = List.Tot.Base.length (smt_goals ()) (* sigh GGG fix names!! *) let fresh_namedv_named (s:string) : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal s; sort = seal (pack Tv_Unknown); uniq = n; }) (* Create a fresh bound variable (bv), using a generic name. See also [fresh_namedv_named]. *) let fresh_namedv () : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal ("x" ^ string_of_int n); sort = seal (pack Tv_Unknown); uniq = n; }) let fresh_binder_named (s : string) (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal s; sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_binder (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_implicit_binder (t : typ) : Tac binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Implicit; attrs = [] ; } let guard (b : bool) : TacH unit (requires (fun _ -> True)) (ensures (fun ps r -> if b then Success? r /\ Success?.ps r == ps else Failed? r)) (* ^ the proofstate on failure is not exactly equal (has the psc set) *) = if not b then fail "guard failed" else () let try_with (f : unit -> Tac 'a) (h : exn -> Tac 'a) : Tac 'a = match catch f with | Inl e -> h e | Inr x -> x let trytac (t : unit -> Tac 'a) : Tac (option 'a) = try Some (t ()) with | _ -> None let or_else (#a:Type) (t1 : unit -> Tac a) (t2 : unit -> Tac a) : Tac a = try t1 () with | _ -> t2 () val (<|>) : (unit -> Tac 'a) -> (unit -> Tac 'a) -> (unit -> Tac 'a) let (<|>) t1 t2 = fun () -> or_else t1 t2 let first (ts : list (unit -> Tac 'a)) : Tac 'a = L.fold_right (<|>) ts (fun () -> fail "no tactics to try") () let rec repeat (#a:Type) (t : unit -> Tac a) : Tac (list a) = match catch t with | Inl _ -> [] | Inr x -> x :: repeat t let repeat1 (#a:Type) (t : unit -> Tac a) : Tac (list a) = t () :: repeat t let repeat' (f : unit -> Tac 'a) : Tac unit = let _ = repeat f in () let norm_term (s : list norm_step) (t : term) : Tac term = let e = try cur_env () with | _ -> top_env () in norm_term_env e s t (** Join all of the SMT goals into one. This helps when all of them are expected to be similar, and therefore easier to prove at once by the SMT solver. TODO: would be nice to try to join them in a more meaningful way, as the order can matter. *) let join_all_smt_goals () = let gs, sgs = goals (), smt_goals () in set_smt_goals []; set_goals sgs; repeat' join; let sgs' = goals () in // should be a single one set_goals gs; set_smt_goals sgs' let discard (tau : unit -> Tac 'a) : unit -> Tac unit = fun () -> let _ = tau () in () // TODO: do we want some value out of this? let rec repeatseq (#a:Type) (t : unit -> Tac a) : Tac unit = let _ = trytac (fun () -> (discard t) `seq` (discard (fun () -> repeatseq t))) in () let tadmit () = tadmit_t (`()) let admit1 () : Tac unit = tadmit () let admit_all () : Tac unit = let _ = repeat tadmit in () (** [is_guard] returns whether the current goal arose from a typechecking guard *) let is_guard () : Tac bool = Tactics.Types.is_guard (_cur_goal ()) let skip_guard () : Tac unit = if is_guard () then smt () else fail "" let guards_to_smt () : Tac unit = let _ = repeat skip_guard in ()
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val whnf: Prims.unit -> Tac unit
[]
FStar.Tactics.V2.Derived.whnf
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 60, "end_line": 529, "start_col": 28, "start_line": 529 }
Prims.Tot
val mk_squash (t: term) : Tot term
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mk_squash (t : term) : Tot term = let sq : term = pack (Tv_FVar (pack_fv squash_qn)) in mk_e_app sq [t]
val mk_squash (t: term) : Tot term let mk_squash (t: term) : Tot term =
false
null
false
let sq:term = pack (Tv_FVar (pack_fv squash_qn)) in mk_e_app sq [t]
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[ "total" ]
[ "FStar.Tactics.NamedView.term", "FStar.Reflection.V2.Derived.mk_e_app", "Prims.Cons", "FStar.Reflection.Types.term", "Prims.Nil", "FStar.Tactics.NamedView.pack", "FStar.Tactics.NamedView.Tv_FVar", "FStar.Reflection.V2.Builtins.pack_fv", "FStar.Reflection.Const.squash_qn" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *) let commute_applied_match () : Tac unit = t_commute_applied_match () (** Similar to [apply_lemma], but will not instantiate uvars in the goal while applying. *) let apply_lemma_noinst (t : term) : Tac unit = t_apply_lemma true false t let apply_lemma_rw (t : term) : Tac unit = t_apply_lemma false true t (** [apply_raw f] is like [apply], but will ask for all arguments regardless of whether they appear free in further goals. See the explanation in [t_apply]. *) let apply_raw (t : term) : Tac unit = t_apply false false false t (** Like [exact], but allows for the term [e] to have a type [t] only under some guard [g], adding the guard as a goal. *) let exact_guard (t : term) : Tac unit = with_policy Goal (fun () -> t_exact true false t) (** (TODO: explain better) When running [pointwise tau] For every subterm [t'] of the goal's type [t], the engine will build a goal [Gamma |= t' == ?u] and run [tau] on it. When the tactic proves the goal, the engine will rewrite [t'] for [?u] in the original goal type. This is done for every subterm, bottom-up. This allows to recurse over an unknown goal type. By inspecting the goal, the [tau] can then decide what to do (to not do anything, use [trefl]). *) let t_pointwise (d:direction) (tau : unit -> Tac unit) : Tac unit = let ctrl (t:term) : Tac (bool & ctrl_flag) = true, Continue in let rw () : Tac unit = tau () in ctrl_rewrite d ctrl rw (** [topdown_rewrite ctrl rw] is used to rewrite those sub-terms [t] of the goal on which [fst (ctrl t)] returns true. On each such sub-term, [rw] is presented with an equality of goal of the form [Gamma |= t == ?u]. When [rw] proves the goal, the engine will rewrite [t] for [?u] in the original goal type. The goal formula is traversed top-down and the traversal can be controlled by [snd (ctrl t)]: When [snd (ctrl t) = 0], the traversal continues down through the position in the goal term. When [snd (ctrl t) = 1], the traversal continues to the next sub-tree of the goal. When [snd (ctrl t) = 2], no more rewrites are performed in the goal. *) let topdown_rewrite (ctrl : term -> Tac (bool * int)) (rw:unit -> Tac unit) : Tac unit = let ctrl' (t:term) : Tac (bool & ctrl_flag) = let b, i = ctrl t in let f = match i with | 0 -> Continue | 1 -> Skip | 2 -> Abort | _ -> fail "topdown_rewrite: bad value from ctrl" in b, f in ctrl_rewrite TopDown ctrl' rw let pointwise (tau : unit -> Tac unit) : Tac unit = t_pointwise BottomUp tau let pointwise' (tau : unit -> Tac unit) : Tac unit = t_pointwise TopDown tau let cur_module () : Tac name = moduleof (top_env ()) let open_modules () : Tac (list name) = env_open_modules (top_env ()) let fresh_uvar (o : option typ) : Tac term = let e = cur_env () in uvar_env e o let unify (t1 t2 : term) : Tac bool = let e = cur_env () in unify_env e t1 t2 let unify_guard (t1 t2 : term) : Tac bool = let e = cur_env () in unify_guard_env e t1 t2 let tmatch (t1 t2 : term) : Tac bool = let e = cur_env () in match_env e t1 t2 (** [divide n t1 t2] will split the current set of goals into the [n] first ones, and the rest. It then runs [t1] on the first set, and [t2] on the second, returning both results (and concatenating remaining goals). *) let divide (n:int) (l : unit -> Tac 'a) (r : unit -> Tac 'b) : Tac ('a * 'b) = if n < 0 then fail "divide: negative n"; let gs, sgs = goals (), smt_goals () in let gs1, gs2 = List.Tot.Base.splitAt n gs in set_goals gs1; set_smt_goals []; let x = l () in let gsl, sgsl = goals (), smt_goals () in set_goals gs2; set_smt_goals []; let y = r () in let gsr, sgsr = goals (), smt_goals () in set_goals (gsl @ gsr); set_smt_goals (sgs @ sgsl @ sgsr); (x, y) let rec iseq (ts : list (unit -> Tac unit)) : Tac unit = match ts with | t::ts -> let _ = divide 1 t (fun () -> iseq ts) in () | [] -> () (** [focus t] runs [t ()] on the current active goal, hiding all others and restoring them at the end. *) let focus (t : unit -> Tac 'a) : Tac 'a = match goals () with | [] -> fail "focus: no goals" | g::gs -> let sgs = smt_goals () in set_goals [g]; set_smt_goals []; let x = t () in set_goals (goals () @ gs); set_smt_goals (smt_goals () @ sgs); x (** Similar to [dump], but only dumping the current goal. *) let dump1 (m : string) = focus (fun () -> dump m) let rec mapAll (t : unit -> Tac 'a) : Tac (list 'a) = match goals () with | [] -> [] | _::_ -> let (h, t) = divide 1 t (fun () -> mapAll t) in h::t let rec iterAll (t : unit -> Tac unit) : Tac unit = (* Could use mapAll, but why even build that list *) match goals () with | [] -> () | _::_ -> let _ = divide 1 t (fun () -> iterAll t) in () let iterAllSMT (t : unit -> Tac unit) : Tac unit = let gs, sgs = goals (), smt_goals () in set_goals sgs; set_smt_goals []; iterAll t; let gs', sgs' = goals (), smt_goals () in set_goals gs; set_smt_goals (gs'@sgs') (** Runs tactic [t1] on the current goal, and then tactic [t2] on *each* subgoal produced by [t1]. Each invocation of [t2] runs on a proofstate with a single goal (they're "focused"). *) let seq (f : unit -> Tac unit) (g : unit -> Tac unit) : Tac unit = focus (fun () -> f (); iterAll g) let exact_args (qs : list aqualv) (t : term) : Tac unit = focus (fun () -> let n = List.Tot.Base.length qs in let uvs = repeatn n (fun () -> fresh_uvar None) in let t' = mk_app t (zip uvs qs) in exact t'; iter (fun uv -> if is_uvar uv then unshelve uv else ()) (L.rev uvs) ) let exact_n (n : int) (t : term) : Tac unit = exact_args (repeatn n (fun () -> Q_Explicit)) t (** [ngoals ()] returns the number of goals *) let ngoals () : Tac int = List.Tot.Base.length (goals ()) (** [ngoals_smt ()] returns the number of SMT goals *) let ngoals_smt () : Tac int = List.Tot.Base.length (smt_goals ()) (* sigh GGG fix names!! *) let fresh_namedv_named (s:string) : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal s; sort = seal (pack Tv_Unknown); uniq = n; }) (* Create a fresh bound variable (bv), using a generic name. See also [fresh_namedv_named]. *) let fresh_namedv () : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal ("x" ^ string_of_int n); sort = seal (pack Tv_Unknown); uniq = n; }) let fresh_binder_named (s : string) (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal s; sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_binder (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_implicit_binder (t : typ) : Tac binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Implicit; attrs = [] ; } let guard (b : bool) : TacH unit (requires (fun _ -> True)) (ensures (fun ps r -> if b then Success? r /\ Success?.ps r == ps else Failed? r)) (* ^ the proofstate on failure is not exactly equal (has the psc set) *) = if not b then fail "guard failed" else () let try_with (f : unit -> Tac 'a) (h : exn -> Tac 'a) : Tac 'a = match catch f with | Inl e -> h e | Inr x -> x let trytac (t : unit -> Tac 'a) : Tac (option 'a) = try Some (t ()) with | _ -> None let or_else (#a:Type) (t1 : unit -> Tac a) (t2 : unit -> Tac a) : Tac a = try t1 () with | _ -> t2 () val (<|>) : (unit -> Tac 'a) -> (unit -> Tac 'a) -> (unit -> Tac 'a) let (<|>) t1 t2 = fun () -> or_else t1 t2 let first (ts : list (unit -> Tac 'a)) : Tac 'a = L.fold_right (<|>) ts (fun () -> fail "no tactics to try") () let rec repeat (#a:Type) (t : unit -> Tac a) : Tac (list a) = match catch t with | Inl _ -> [] | Inr x -> x :: repeat t let repeat1 (#a:Type) (t : unit -> Tac a) : Tac (list a) = t () :: repeat t let repeat' (f : unit -> Tac 'a) : Tac unit = let _ = repeat f in () let norm_term (s : list norm_step) (t : term) : Tac term = let e = try cur_env () with | _ -> top_env () in norm_term_env e s t (** Join all of the SMT goals into one. This helps when all of them are expected to be similar, and therefore easier to prove at once by the SMT solver. TODO: would be nice to try to join them in a more meaningful way, as the order can matter. *) let join_all_smt_goals () = let gs, sgs = goals (), smt_goals () in set_smt_goals []; set_goals sgs; repeat' join; let sgs' = goals () in // should be a single one set_goals gs; set_smt_goals sgs' let discard (tau : unit -> Tac 'a) : unit -> Tac unit = fun () -> let _ = tau () in () // TODO: do we want some value out of this? let rec repeatseq (#a:Type) (t : unit -> Tac a) : Tac unit = let _ = trytac (fun () -> (discard t) `seq` (discard (fun () -> repeatseq t))) in () let tadmit () = tadmit_t (`()) let admit1 () : Tac unit = tadmit () let admit_all () : Tac unit = let _ = repeat tadmit in () (** [is_guard] returns whether the current goal arose from a typechecking guard *) let is_guard () : Tac bool = Tactics.Types.is_guard (_cur_goal ()) let skip_guard () : Tac unit = if is_guard () then smt () else fail "" let guards_to_smt () : Tac unit = let _ = repeat skip_guard in () let simpl () : Tac unit = norm [simplify; primops] let whnf () : Tac unit = norm [weak; hnf; primops; delta] let compute () : Tac unit = norm [primops; iota; delta; zeta] let intros () : Tac (list binding) = repeat intro let intros' () : Tac unit = let _ = intros () in () let destruct tm : Tac unit = let _ = t_destruct tm in () let destruct_intros tm : Tac unit = seq (fun () -> let _ = t_destruct tm in ()) intros' private val __cut : (a:Type) -> (b:Type) -> (a -> b) -> a -> b private let __cut a b f x = f x let tcut (t:term) : Tac binding = let g = cur_goal () in let tt = mk_e_app (`__cut) [t; g] in apply tt; intro () let pose (t:term) : Tac binding = apply (`__cut); flip (); exact t; intro () let intro_as (s:string) : Tac binding = let b = intro () in rename_to b s let pose_as (s:string) (t:term) : Tac binding = let b = pose t in rename_to b s let for_each_binding (f : binding -> Tac 'a) : Tac (list 'a) = map f (cur_vars ()) let rec revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> revert (); revert_all tl let binder_sort (b : binder) : Tot typ = b.sort // Cannot define this inside `assumption` due to #1091 private let rec __assumption_aux (xs : list binding) : Tac unit = match xs with | [] -> fail "no assumption matches goal" | b::bs -> try exact b with | _ -> try (apply (`FStar.Squash.return_squash); exact b) with | _ -> __assumption_aux bs let assumption () : Tac unit = __assumption_aux (cur_vars ()) let destruct_equality_implication (t:term) : Tac (option (formula * term)) = match term_as_formula t with | Implies lhs rhs -> let lhs = term_as_formula' lhs in begin match lhs with | Comp (Eq _) _ _ -> Some (lhs, rhs) | _ -> None end | _ -> None private let __eq_sym #t (a b : t) : Lemma ((a == b) == (b == a)) = FStar.PropositionalExtensionality.apply (a==b) (b==a) (** Like [rewrite], but works with equalities [v == e] and [e == v] *) let rewrite' (x:binding) : Tac unit = ((fun () -> rewrite x) <|> (fun () -> var_retype x; apply_lemma (`__eq_sym); rewrite x) <|> (fun () -> fail "rewrite' failed")) () let rec try_rewrite_equality (x:term) (bs:list binding) : Tac unit = match bs with | [] -> () | x_t::bs -> begin match term_as_formula (type_of_binding x_t) with | Comp (Eq _) y _ -> if term_eq x y then rewrite x_t else try_rewrite_equality x bs | _ -> try_rewrite_equality x bs end let rec rewrite_all_context_equalities (bs:list binding) : Tac unit = match bs with | [] -> () | x_t::bs -> begin (try rewrite x_t with | _ -> ()); rewrite_all_context_equalities bs end let rewrite_eqs_from_context () : Tac unit = rewrite_all_context_equalities (cur_vars ()) let rewrite_equality (t:term) : Tac unit = try_rewrite_equality t (cur_vars ()) let unfold_def (t:term) : Tac unit = match inspect t with | Tv_FVar fv -> let n = implode_qn (inspect_fv fv) in norm [delta_fully [n]] | _ -> fail "unfold_def: term is not a fv" (** Rewrites left-to-right, and bottom-up, given a set of lemmas stating equalities. The lemmas need to prove *propositional* equalities, that is, using [==]. *) let l_to_r (lems:list term) : Tac unit = let first_or_trefl () : Tac unit = fold_left (fun k l () -> (fun () -> apply_lemma_rw l) `or_else` k) trefl lems () in pointwise first_or_trefl
false
true
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mk_squash (t: term) : Tot term
[]
FStar.Tactics.V2.Derived.mk_squash
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t: FStar.Tactics.NamedView.term -> FStar.Tactics.NamedView.term
{ "end_col": 19, "end_line": 657, "start_col": 37, "start_line": 655 }
FStar.Tactics.Effect.Tac
val repeat1 (#a: Type) (t: (unit -> Tac a)) : Tac (list a)
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let repeat1 (#a:Type) (t : unit -> Tac a) : Tac (list a) = t () :: repeat t
val repeat1 (#a: Type) (t: (unit -> Tac a)) : Tac (list a) let repeat1 (#a: Type) (t: (unit -> Tac a)) : Tac (list a) =
true
null
false
t () :: repeat t
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "Prims.unit", "Prims.Cons", "Prims.list", "FStar.Tactics.V2.Derived.repeat" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *) let commute_applied_match () : Tac unit = t_commute_applied_match () (** Similar to [apply_lemma], but will not instantiate uvars in the goal while applying. *) let apply_lemma_noinst (t : term) : Tac unit = t_apply_lemma true false t let apply_lemma_rw (t : term) : Tac unit = t_apply_lemma false true t (** [apply_raw f] is like [apply], but will ask for all arguments regardless of whether they appear free in further goals. See the explanation in [t_apply]. *) let apply_raw (t : term) : Tac unit = t_apply false false false t (** Like [exact], but allows for the term [e] to have a type [t] only under some guard [g], adding the guard as a goal. *) let exact_guard (t : term) : Tac unit = with_policy Goal (fun () -> t_exact true false t) (** (TODO: explain better) When running [pointwise tau] For every subterm [t'] of the goal's type [t], the engine will build a goal [Gamma |= t' == ?u] and run [tau] on it. When the tactic proves the goal, the engine will rewrite [t'] for [?u] in the original goal type. This is done for every subterm, bottom-up. This allows to recurse over an unknown goal type. By inspecting the goal, the [tau] can then decide what to do (to not do anything, use [trefl]). *) let t_pointwise (d:direction) (tau : unit -> Tac unit) : Tac unit = let ctrl (t:term) : Tac (bool & ctrl_flag) = true, Continue in let rw () : Tac unit = tau () in ctrl_rewrite d ctrl rw (** [topdown_rewrite ctrl rw] is used to rewrite those sub-terms [t] of the goal on which [fst (ctrl t)] returns true. On each such sub-term, [rw] is presented with an equality of goal of the form [Gamma |= t == ?u]. When [rw] proves the goal, the engine will rewrite [t] for [?u] in the original goal type. The goal formula is traversed top-down and the traversal can be controlled by [snd (ctrl t)]: When [snd (ctrl t) = 0], the traversal continues down through the position in the goal term. When [snd (ctrl t) = 1], the traversal continues to the next sub-tree of the goal. When [snd (ctrl t) = 2], no more rewrites are performed in the goal. *) let topdown_rewrite (ctrl : term -> Tac (bool * int)) (rw:unit -> Tac unit) : Tac unit = let ctrl' (t:term) : Tac (bool & ctrl_flag) = let b, i = ctrl t in let f = match i with | 0 -> Continue | 1 -> Skip | 2 -> Abort | _ -> fail "topdown_rewrite: bad value from ctrl" in b, f in ctrl_rewrite TopDown ctrl' rw let pointwise (tau : unit -> Tac unit) : Tac unit = t_pointwise BottomUp tau let pointwise' (tau : unit -> Tac unit) : Tac unit = t_pointwise TopDown tau let cur_module () : Tac name = moduleof (top_env ()) let open_modules () : Tac (list name) = env_open_modules (top_env ()) let fresh_uvar (o : option typ) : Tac term = let e = cur_env () in uvar_env e o let unify (t1 t2 : term) : Tac bool = let e = cur_env () in unify_env e t1 t2 let unify_guard (t1 t2 : term) : Tac bool = let e = cur_env () in unify_guard_env e t1 t2 let tmatch (t1 t2 : term) : Tac bool = let e = cur_env () in match_env e t1 t2 (** [divide n t1 t2] will split the current set of goals into the [n] first ones, and the rest. It then runs [t1] on the first set, and [t2] on the second, returning both results (and concatenating remaining goals). *) let divide (n:int) (l : unit -> Tac 'a) (r : unit -> Tac 'b) : Tac ('a * 'b) = if n < 0 then fail "divide: negative n"; let gs, sgs = goals (), smt_goals () in let gs1, gs2 = List.Tot.Base.splitAt n gs in set_goals gs1; set_smt_goals []; let x = l () in let gsl, sgsl = goals (), smt_goals () in set_goals gs2; set_smt_goals []; let y = r () in let gsr, sgsr = goals (), smt_goals () in set_goals (gsl @ gsr); set_smt_goals (sgs @ sgsl @ sgsr); (x, y) let rec iseq (ts : list (unit -> Tac unit)) : Tac unit = match ts with | t::ts -> let _ = divide 1 t (fun () -> iseq ts) in () | [] -> () (** [focus t] runs [t ()] on the current active goal, hiding all others and restoring them at the end. *) let focus (t : unit -> Tac 'a) : Tac 'a = match goals () with | [] -> fail "focus: no goals" | g::gs -> let sgs = smt_goals () in set_goals [g]; set_smt_goals []; let x = t () in set_goals (goals () @ gs); set_smt_goals (smt_goals () @ sgs); x (** Similar to [dump], but only dumping the current goal. *) let dump1 (m : string) = focus (fun () -> dump m) let rec mapAll (t : unit -> Tac 'a) : Tac (list 'a) = match goals () with | [] -> [] | _::_ -> let (h, t) = divide 1 t (fun () -> mapAll t) in h::t let rec iterAll (t : unit -> Tac unit) : Tac unit = (* Could use mapAll, but why even build that list *) match goals () with | [] -> () | _::_ -> let _ = divide 1 t (fun () -> iterAll t) in () let iterAllSMT (t : unit -> Tac unit) : Tac unit = let gs, sgs = goals (), smt_goals () in set_goals sgs; set_smt_goals []; iterAll t; let gs', sgs' = goals (), smt_goals () in set_goals gs; set_smt_goals (gs'@sgs') (** Runs tactic [t1] on the current goal, and then tactic [t2] on *each* subgoal produced by [t1]. Each invocation of [t2] runs on a proofstate with a single goal (they're "focused"). *) let seq (f : unit -> Tac unit) (g : unit -> Tac unit) : Tac unit = focus (fun () -> f (); iterAll g) let exact_args (qs : list aqualv) (t : term) : Tac unit = focus (fun () -> let n = List.Tot.Base.length qs in let uvs = repeatn n (fun () -> fresh_uvar None) in let t' = mk_app t (zip uvs qs) in exact t'; iter (fun uv -> if is_uvar uv then unshelve uv else ()) (L.rev uvs) ) let exact_n (n : int) (t : term) : Tac unit = exact_args (repeatn n (fun () -> Q_Explicit)) t (** [ngoals ()] returns the number of goals *) let ngoals () : Tac int = List.Tot.Base.length (goals ()) (** [ngoals_smt ()] returns the number of SMT goals *) let ngoals_smt () : Tac int = List.Tot.Base.length (smt_goals ()) (* sigh GGG fix names!! *) let fresh_namedv_named (s:string) : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal s; sort = seal (pack Tv_Unknown); uniq = n; }) (* Create a fresh bound variable (bv), using a generic name. See also [fresh_namedv_named]. *) let fresh_namedv () : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal ("x" ^ string_of_int n); sort = seal (pack Tv_Unknown); uniq = n; }) let fresh_binder_named (s : string) (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal s; sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_binder (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_implicit_binder (t : typ) : Tac binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Implicit; attrs = [] ; } let guard (b : bool) : TacH unit (requires (fun _ -> True)) (ensures (fun ps r -> if b then Success? r /\ Success?.ps r == ps else Failed? r)) (* ^ the proofstate on failure is not exactly equal (has the psc set) *) = if not b then fail "guard failed" else () let try_with (f : unit -> Tac 'a) (h : exn -> Tac 'a) : Tac 'a = match catch f with | Inl e -> h e | Inr x -> x let trytac (t : unit -> Tac 'a) : Tac (option 'a) = try Some (t ()) with | _ -> None let or_else (#a:Type) (t1 : unit -> Tac a) (t2 : unit -> Tac a) : Tac a = try t1 () with | _ -> t2 () val (<|>) : (unit -> Tac 'a) -> (unit -> Tac 'a) -> (unit -> Tac 'a) let (<|>) t1 t2 = fun () -> or_else t1 t2 let first (ts : list (unit -> Tac 'a)) : Tac 'a = L.fold_right (<|>) ts (fun () -> fail "no tactics to try") () let rec repeat (#a:Type) (t : unit -> Tac a) : Tac (list a) = match catch t with | Inl _ -> [] | Inr x -> x :: repeat t
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val repeat1 (#a: Type) (t: (unit -> Tac a)) : Tac (list a)
[]
FStar.Tactics.V2.Derived.repeat1
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t: (_: Prims.unit -> FStar.Tactics.Effect.Tac a) -> FStar.Tactics.Effect.Tac (Prims.list a)
{ "end_col": 20, "end_line": 474, "start_col": 4, "start_line": 474 }
FStar.Tactics.Effect.Tac
val intro_as (s: string) : Tac binding
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let intro_as (s:string) : Tac binding = let b = intro () in rename_to b s
val intro_as (s: string) : Tac binding let intro_as (s: string) : Tac binding =
true
null
false
let b = intro () in rename_to b s
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "Prims.string", "FStar.Tactics.V2.Builtins.rename_to", "FStar.Reflection.V2.Data.binding", "FStar.Tactics.V2.Builtins.intro", "FStar.Tactics.NamedView.binding" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *) let commute_applied_match () : Tac unit = t_commute_applied_match () (** Similar to [apply_lemma], but will not instantiate uvars in the goal while applying. *) let apply_lemma_noinst (t : term) : Tac unit = t_apply_lemma true false t let apply_lemma_rw (t : term) : Tac unit = t_apply_lemma false true t (** [apply_raw f] is like [apply], but will ask for all arguments regardless of whether they appear free in further goals. See the explanation in [t_apply]. *) let apply_raw (t : term) : Tac unit = t_apply false false false t (** Like [exact], but allows for the term [e] to have a type [t] only under some guard [g], adding the guard as a goal. *) let exact_guard (t : term) : Tac unit = with_policy Goal (fun () -> t_exact true false t) (** (TODO: explain better) When running [pointwise tau] For every subterm [t'] of the goal's type [t], the engine will build a goal [Gamma |= t' == ?u] and run [tau] on it. When the tactic proves the goal, the engine will rewrite [t'] for [?u] in the original goal type. This is done for every subterm, bottom-up. This allows to recurse over an unknown goal type. By inspecting the goal, the [tau] can then decide what to do (to not do anything, use [trefl]). *) let t_pointwise (d:direction) (tau : unit -> Tac unit) : Tac unit = let ctrl (t:term) : Tac (bool & ctrl_flag) = true, Continue in let rw () : Tac unit = tau () in ctrl_rewrite d ctrl rw (** [topdown_rewrite ctrl rw] is used to rewrite those sub-terms [t] of the goal on which [fst (ctrl t)] returns true. On each such sub-term, [rw] is presented with an equality of goal of the form [Gamma |= t == ?u]. When [rw] proves the goal, the engine will rewrite [t] for [?u] in the original goal type. The goal formula is traversed top-down and the traversal can be controlled by [snd (ctrl t)]: When [snd (ctrl t) = 0], the traversal continues down through the position in the goal term. When [snd (ctrl t) = 1], the traversal continues to the next sub-tree of the goal. When [snd (ctrl t) = 2], no more rewrites are performed in the goal. *) let topdown_rewrite (ctrl : term -> Tac (bool * int)) (rw:unit -> Tac unit) : Tac unit = let ctrl' (t:term) : Tac (bool & ctrl_flag) = let b, i = ctrl t in let f = match i with | 0 -> Continue | 1 -> Skip | 2 -> Abort | _ -> fail "topdown_rewrite: bad value from ctrl" in b, f in ctrl_rewrite TopDown ctrl' rw let pointwise (tau : unit -> Tac unit) : Tac unit = t_pointwise BottomUp tau let pointwise' (tau : unit -> Tac unit) : Tac unit = t_pointwise TopDown tau let cur_module () : Tac name = moduleof (top_env ()) let open_modules () : Tac (list name) = env_open_modules (top_env ()) let fresh_uvar (o : option typ) : Tac term = let e = cur_env () in uvar_env e o let unify (t1 t2 : term) : Tac bool = let e = cur_env () in unify_env e t1 t2 let unify_guard (t1 t2 : term) : Tac bool = let e = cur_env () in unify_guard_env e t1 t2 let tmatch (t1 t2 : term) : Tac bool = let e = cur_env () in match_env e t1 t2 (** [divide n t1 t2] will split the current set of goals into the [n] first ones, and the rest. It then runs [t1] on the first set, and [t2] on the second, returning both results (and concatenating remaining goals). *) let divide (n:int) (l : unit -> Tac 'a) (r : unit -> Tac 'b) : Tac ('a * 'b) = if n < 0 then fail "divide: negative n"; let gs, sgs = goals (), smt_goals () in let gs1, gs2 = List.Tot.Base.splitAt n gs in set_goals gs1; set_smt_goals []; let x = l () in let gsl, sgsl = goals (), smt_goals () in set_goals gs2; set_smt_goals []; let y = r () in let gsr, sgsr = goals (), smt_goals () in set_goals (gsl @ gsr); set_smt_goals (sgs @ sgsl @ sgsr); (x, y) let rec iseq (ts : list (unit -> Tac unit)) : Tac unit = match ts with | t::ts -> let _ = divide 1 t (fun () -> iseq ts) in () | [] -> () (** [focus t] runs [t ()] on the current active goal, hiding all others and restoring them at the end. *) let focus (t : unit -> Tac 'a) : Tac 'a = match goals () with | [] -> fail "focus: no goals" | g::gs -> let sgs = smt_goals () in set_goals [g]; set_smt_goals []; let x = t () in set_goals (goals () @ gs); set_smt_goals (smt_goals () @ sgs); x (** Similar to [dump], but only dumping the current goal. *) let dump1 (m : string) = focus (fun () -> dump m) let rec mapAll (t : unit -> Tac 'a) : Tac (list 'a) = match goals () with | [] -> [] | _::_ -> let (h, t) = divide 1 t (fun () -> mapAll t) in h::t let rec iterAll (t : unit -> Tac unit) : Tac unit = (* Could use mapAll, but why even build that list *) match goals () with | [] -> () | _::_ -> let _ = divide 1 t (fun () -> iterAll t) in () let iterAllSMT (t : unit -> Tac unit) : Tac unit = let gs, sgs = goals (), smt_goals () in set_goals sgs; set_smt_goals []; iterAll t; let gs', sgs' = goals (), smt_goals () in set_goals gs; set_smt_goals (gs'@sgs') (** Runs tactic [t1] on the current goal, and then tactic [t2] on *each* subgoal produced by [t1]. Each invocation of [t2] runs on a proofstate with a single goal (they're "focused"). *) let seq (f : unit -> Tac unit) (g : unit -> Tac unit) : Tac unit = focus (fun () -> f (); iterAll g) let exact_args (qs : list aqualv) (t : term) : Tac unit = focus (fun () -> let n = List.Tot.Base.length qs in let uvs = repeatn n (fun () -> fresh_uvar None) in let t' = mk_app t (zip uvs qs) in exact t'; iter (fun uv -> if is_uvar uv then unshelve uv else ()) (L.rev uvs) ) let exact_n (n : int) (t : term) : Tac unit = exact_args (repeatn n (fun () -> Q_Explicit)) t (** [ngoals ()] returns the number of goals *) let ngoals () : Tac int = List.Tot.Base.length (goals ()) (** [ngoals_smt ()] returns the number of SMT goals *) let ngoals_smt () : Tac int = List.Tot.Base.length (smt_goals ()) (* sigh GGG fix names!! *) let fresh_namedv_named (s:string) : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal s; sort = seal (pack Tv_Unknown); uniq = n; }) (* Create a fresh bound variable (bv), using a generic name. See also [fresh_namedv_named]. *) let fresh_namedv () : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal ("x" ^ string_of_int n); sort = seal (pack Tv_Unknown); uniq = n; }) let fresh_binder_named (s : string) (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal s; sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_binder (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_implicit_binder (t : typ) : Tac binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Implicit; attrs = [] ; } let guard (b : bool) : TacH unit (requires (fun _ -> True)) (ensures (fun ps r -> if b then Success? r /\ Success?.ps r == ps else Failed? r)) (* ^ the proofstate on failure is not exactly equal (has the psc set) *) = if not b then fail "guard failed" else () let try_with (f : unit -> Tac 'a) (h : exn -> Tac 'a) : Tac 'a = match catch f with | Inl e -> h e | Inr x -> x let trytac (t : unit -> Tac 'a) : Tac (option 'a) = try Some (t ()) with | _ -> None let or_else (#a:Type) (t1 : unit -> Tac a) (t2 : unit -> Tac a) : Tac a = try t1 () with | _ -> t2 () val (<|>) : (unit -> Tac 'a) -> (unit -> Tac 'a) -> (unit -> Tac 'a) let (<|>) t1 t2 = fun () -> or_else t1 t2 let first (ts : list (unit -> Tac 'a)) : Tac 'a = L.fold_right (<|>) ts (fun () -> fail "no tactics to try") () let rec repeat (#a:Type) (t : unit -> Tac a) : Tac (list a) = match catch t with | Inl _ -> [] | Inr x -> x :: repeat t let repeat1 (#a:Type) (t : unit -> Tac a) : Tac (list a) = t () :: repeat t let repeat' (f : unit -> Tac 'a) : Tac unit = let _ = repeat f in () let norm_term (s : list norm_step) (t : term) : Tac term = let e = try cur_env () with | _ -> top_env () in norm_term_env e s t (** Join all of the SMT goals into one. This helps when all of them are expected to be similar, and therefore easier to prove at once by the SMT solver. TODO: would be nice to try to join them in a more meaningful way, as the order can matter. *) let join_all_smt_goals () = let gs, sgs = goals (), smt_goals () in set_smt_goals []; set_goals sgs; repeat' join; let sgs' = goals () in // should be a single one set_goals gs; set_smt_goals sgs' let discard (tau : unit -> Tac 'a) : unit -> Tac unit = fun () -> let _ = tau () in () // TODO: do we want some value out of this? let rec repeatseq (#a:Type) (t : unit -> Tac a) : Tac unit = let _ = trytac (fun () -> (discard t) `seq` (discard (fun () -> repeatseq t))) in () let tadmit () = tadmit_t (`()) let admit1 () : Tac unit = tadmit () let admit_all () : Tac unit = let _ = repeat tadmit in () (** [is_guard] returns whether the current goal arose from a typechecking guard *) let is_guard () : Tac bool = Tactics.Types.is_guard (_cur_goal ()) let skip_guard () : Tac unit = if is_guard () then smt () else fail "" let guards_to_smt () : Tac unit = let _ = repeat skip_guard in () let simpl () : Tac unit = norm [simplify; primops] let whnf () : Tac unit = norm [weak; hnf; primops; delta] let compute () : Tac unit = norm [primops; iota; delta; zeta] let intros () : Tac (list binding) = repeat intro let intros' () : Tac unit = let _ = intros () in () let destruct tm : Tac unit = let _ = t_destruct tm in () let destruct_intros tm : Tac unit = seq (fun () -> let _ = t_destruct tm in ()) intros' private val __cut : (a:Type) -> (b:Type) -> (a -> b) -> a -> b private let __cut a b f x = f x let tcut (t:term) : Tac binding = let g = cur_goal () in let tt = mk_e_app (`__cut) [t; g] in apply tt; intro () let pose (t:term) : Tac binding = apply (`__cut); flip (); exact t; intro ()
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val intro_as (s: string) : Tac binding
[]
FStar.Tactics.V2.Derived.intro_as
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s: Prims.string -> FStar.Tactics.Effect.Tac FStar.Tactics.NamedView.binding
{ "end_col": 17, "end_line": 555, "start_col": 39, "start_line": 553 }
FStar.Tactics.Effect.Tac
val is_guard: Prims.unit -> Tac bool
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let is_guard () : Tac bool = Tactics.Types.is_guard (_cur_goal ())
val is_guard: Prims.unit -> Tac bool let is_guard () : Tac bool =
true
null
false
Tactics.Types.is_guard (_cur_goal ())
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "Prims.unit", "FStar.Tactics.Types.is_guard", "Prims.bool", "FStar.Tactics.Types.goal", "FStar.Tactics.V2.Derived._cur_goal" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *) let commute_applied_match () : Tac unit = t_commute_applied_match () (** Similar to [apply_lemma], but will not instantiate uvars in the goal while applying. *) let apply_lemma_noinst (t : term) : Tac unit = t_apply_lemma true false t let apply_lemma_rw (t : term) : Tac unit = t_apply_lemma false true t (** [apply_raw f] is like [apply], but will ask for all arguments regardless of whether they appear free in further goals. See the explanation in [t_apply]. *) let apply_raw (t : term) : Tac unit = t_apply false false false t (** Like [exact], but allows for the term [e] to have a type [t] only under some guard [g], adding the guard as a goal. *) let exact_guard (t : term) : Tac unit = with_policy Goal (fun () -> t_exact true false t) (** (TODO: explain better) When running [pointwise tau] For every subterm [t'] of the goal's type [t], the engine will build a goal [Gamma |= t' == ?u] and run [tau] on it. When the tactic proves the goal, the engine will rewrite [t'] for [?u] in the original goal type. This is done for every subterm, bottom-up. This allows to recurse over an unknown goal type. By inspecting the goal, the [tau] can then decide what to do (to not do anything, use [trefl]). *) let t_pointwise (d:direction) (tau : unit -> Tac unit) : Tac unit = let ctrl (t:term) : Tac (bool & ctrl_flag) = true, Continue in let rw () : Tac unit = tau () in ctrl_rewrite d ctrl rw (** [topdown_rewrite ctrl rw] is used to rewrite those sub-terms [t] of the goal on which [fst (ctrl t)] returns true. On each such sub-term, [rw] is presented with an equality of goal of the form [Gamma |= t == ?u]. When [rw] proves the goal, the engine will rewrite [t] for [?u] in the original goal type. The goal formula is traversed top-down and the traversal can be controlled by [snd (ctrl t)]: When [snd (ctrl t) = 0], the traversal continues down through the position in the goal term. When [snd (ctrl t) = 1], the traversal continues to the next sub-tree of the goal. When [snd (ctrl t) = 2], no more rewrites are performed in the goal. *) let topdown_rewrite (ctrl : term -> Tac (bool * int)) (rw:unit -> Tac unit) : Tac unit = let ctrl' (t:term) : Tac (bool & ctrl_flag) = let b, i = ctrl t in let f = match i with | 0 -> Continue | 1 -> Skip | 2 -> Abort | _ -> fail "topdown_rewrite: bad value from ctrl" in b, f in ctrl_rewrite TopDown ctrl' rw let pointwise (tau : unit -> Tac unit) : Tac unit = t_pointwise BottomUp tau let pointwise' (tau : unit -> Tac unit) : Tac unit = t_pointwise TopDown tau let cur_module () : Tac name = moduleof (top_env ()) let open_modules () : Tac (list name) = env_open_modules (top_env ()) let fresh_uvar (o : option typ) : Tac term = let e = cur_env () in uvar_env e o let unify (t1 t2 : term) : Tac bool = let e = cur_env () in unify_env e t1 t2 let unify_guard (t1 t2 : term) : Tac bool = let e = cur_env () in unify_guard_env e t1 t2 let tmatch (t1 t2 : term) : Tac bool = let e = cur_env () in match_env e t1 t2 (** [divide n t1 t2] will split the current set of goals into the [n] first ones, and the rest. It then runs [t1] on the first set, and [t2] on the second, returning both results (and concatenating remaining goals). *) let divide (n:int) (l : unit -> Tac 'a) (r : unit -> Tac 'b) : Tac ('a * 'b) = if n < 0 then fail "divide: negative n"; let gs, sgs = goals (), smt_goals () in let gs1, gs2 = List.Tot.Base.splitAt n gs in set_goals gs1; set_smt_goals []; let x = l () in let gsl, sgsl = goals (), smt_goals () in set_goals gs2; set_smt_goals []; let y = r () in let gsr, sgsr = goals (), smt_goals () in set_goals (gsl @ gsr); set_smt_goals (sgs @ sgsl @ sgsr); (x, y) let rec iseq (ts : list (unit -> Tac unit)) : Tac unit = match ts with | t::ts -> let _ = divide 1 t (fun () -> iseq ts) in () | [] -> () (** [focus t] runs [t ()] on the current active goal, hiding all others and restoring them at the end. *) let focus (t : unit -> Tac 'a) : Tac 'a = match goals () with | [] -> fail "focus: no goals" | g::gs -> let sgs = smt_goals () in set_goals [g]; set_smt_goals []; let x = t () in set_goals (goals () @ gs); set_smt_goals (smt_goals () @ sgs); x (** Similar to [dump], but only dumping the current goal. *) let dump1 (m : string) = focus (fun () -> dump m) let rec mapAll (t : unit -> Tac 'a) : Tac (list 'a) = match goals () with | [] -> [] | _::_ -> let (h, t) = divide 1 t (fun () -> mapAll t) in h::t let rec iterAll (t : unit -> Tac unit) : Tac unit = (* Could use mapAll, but why even build that list *) match goals () with | [] -> () | _::_ -> let _ = divide 1 t (fun () -> iterAll t) in () let iterAllSMT (t : unit -> Tac unit) : Tac unit = let gs, sgs = goals (), smt_goals () in set_goals sgs; set_smt_goals []; iterAll t; let gs', sgs' = goals (), smt_goals () in set_goals gs; set_smt_goals (gs'@sgs') (** Runs tactic [t1] on the current goal, and then tactic [t2] on *each* subgoal produced by [t1]. Each invocation of [t2] runs on a proofstate with a single goal (they're "focused"). *) let seq (f : unit -> Tac unit) (g : unit -> Tac unit) : Tac unit = focus (fun () -> f (); iterAll g) let exact_args (qs : list aqualv) (t : term) : Tac unit = focus (fun () -> let n = List.Tot.Base.length qs in let uvs = repeatn n (fun () -> fresh_uvar None) in let t' = mk_app t (zip uvs qs) in exact t'; iter (fun uv -> if is_uvar uv then unshelve uv else ()) (L.rev uvs) ) let exact_n (n : int) (t : term) : Tac unit = exact_args (repeatn n (fun () -> Q_Explicit)) t (** [ngoals ()] returns the number of goals *) let ngoals () : Tac int = List.Tot.Base.length (goals ()) (** [ngoals_smt ()] returns the number of SMT goals *) let ngoals_smt () : Tac int = List.Tot.Base.length (smt_goals ()) (* sigh GGG fix names!! *) let fresh_namedv_named (s:string) : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal s; sort = seal (pack Tv_Unknown); uniq = n; }) (* Create a fresh bound variable (bv), using a generic name. See also [fresh_namedv_named]. *) let fresh_namedv () : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal ("x" ^ string_of_int n); sort = seal (pack Tv_Unknown); uniq = n; }) let fresh_binder_named (s : string) (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal s; sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_binder (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_implicit_binder (t : typ) : Tac binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Implicit; attrs = [] ; } let guard (b : bool) : TacH unit (requires (fun _ -> True)) (ensures (fun ps r -> if b then Success? r /\ Success?.ps r == ps else Failed? r)) (* ^ the proofstate on failure is not exactly equal (has the psc set) *) = if not b then fail "guard failed" else () let try_with (f : unit -> Tac 'a) (h : exn -> Tac 'a) : Tac 'a = match catch f with | Inl e -> h e | Inr x -> x let trytac (t : unit -> Tac 'a) : Tac (option 'a) = try Some (t ()) with | _ -> None let or_else (#a:Type) (t1 : unit -> Tac a) (t2 : unit -> Tac a) : Tac a = try t1 () with | _ -> t2 () val (<|>) : (unit -> Tac 'a) -> (unit -> Tac 'a) -> (unit -> Tac 'a) let (<|>) t1 t2 = fun () -> or_else t1 t2 let first (ts : list (unit -> Tac 'a)) : Tac 'a = L.fold_right (<|>) ts (fun () -> fail "no tactics to try") () let rec repeat (#a:Type) (t : unit -> Tac a) : Tac (list a) = match catch t with | Inl _ -> [] | Inr x -> x :: repeat t let repeat1 (#a:Type) (t : unit -> Tac a) : Tac (list a) = t () :: repeat t let repeat' (f : unit -> Tac 'a) : Tac unit = let _ = repeat f in () let norm_term (s : list norm_step) (t : term) : Tac term = let e = try cur_env () with | _ -> top_env () in norm_term_env e s t (** Join all of the SMT goals into one. This helps when all of them are expected to be similar, and therefore easier to prove at once by the SMT solver. TODO: would be nice to try to join them in a more meaningful way, as the order can matter. *) let join_all_smt_goals () = let gs, sgs = goals (), smt_goals () in set_smt_goals []; set_goals sgs; repeat' join; let sgs' = goals () in // should be a single one set_goals gs; set_smt_goals sgs' let discard (tau : unit -> Tac 'a) : unit -> Tac unit = fun () -> let _ = tau () in () // TODO: do we want some value out of this? let rec repeatseq (#a:Type) (t : unit -> Tac a) : Tac unit = let _ = trytac (fun () -> (discard t) `seq` (discard (fun () -> repeatseq t))) in () let tadmit () = tadmit_t (`()) let admit1 () : Tac unit = tadmit () let admit_all () : Tac unit = let _ = repeat tadmit in () (** [is_guard] returns whether the current goal arose from a typechecking guard *)
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val is_guard: Prims.unit -> Tac bool
[]
FStar.Tactics.V2.Derived.is_guard
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.bool
{ "end_col": 41, "end_line": 517, "start_col": 4, "start_line": 517 }
FStar.Tactics.Effect.Tac
val discard: tau: (unit -> Tac 'a) -> unit -> Tac unit
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let discard (tau : unit -> Tac 'a) : unit -> Tac unit = fun () -> let _ = tau () in ()
val discard: tau: (unit -> Tac 'a) -> unit -> Tac unit let discard (tau: (unit -> Tac 'a)) : unit -> Tac unit =
true
null
false
fun () -> let _ = tau () in ()
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "Prims.unit" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *) let commute_applied_match () : Tac unit = t_commute_applied_match () (** Similar to [apply_lemma], but will not instantiate uvars in the goal while applying. *) let apply_lemma_noinst (t : term) : Tac unit = t_apply_lemma true false t let apply_lemma_rw (t : term) : Tac unit = t_apply_lemma false true t (** [apply_raw f] is like [apply], but will ask for all arguments regardless of whether they appear free in further goals. See the explanation in [t_apply]. *) let apply_raw (t : term) : Tac unit = t_apply false false false t (** Like [exact], but allows for the term [e] to have a type [t] only under some guard [g], adding the guard as a goal. *) let exact_guard (t : term) : Tac unit = with_policy Goal (fun () -> t_exact true false t) (** (TODO: explain better) When running [pointwise tau] For every subterm [t'] of the goal's type [t], the engine will build a goal [Gamma |= t' == ?u] and run [tau] on it. When the tactic proves the goal, the engine will rewrite [t'] for [?u] in the original goal type. This is done for every subterm, bottom-up. This allows to recurse over an unknown goal type. By inspecting the goal, the [tau] can then decide what to do (to not do anything, use [trefl]). *) let t_pointwise (d:direction) (tau : unit -> Tac unit) : Tac unit = let ctrl (t:term) : Tac (bool & ctrl_flag) = true, Continue in let rw () : Tac unit = tau () in ctrl_rewrite d ctrl rw (** [topdown_rewrite ctrl rw] is used to rewrite those sub-terms [t] of the goal on which [fst (ctrl t)] returns true. On each such sub-term, [rw] is presented with an equality of goal of the form [Gamma |= t == ?u]. When [rw] proves the goal, the engine will rewrite [t] for [?u] in the original goal type. The goal formula is traversed top-down and the traversal can be controlled by [snd (ctrl t)]: When [snd (ctrl t) = 0], the traversal continues down through the position in the goal term. When [snd (ctrl t) = 1], the traversal continues to the next sub-tree of the goal. When [snd (ctrl t) = 2], no more rewrites are performed in the goal. *) let topdown_rewrite (ctrl : term -> Tac (bool * int)) (rw:unit -> Tac unit) : Tac unit = let ctrl' (t:term) : Tac (bool & ctrl_flag) = let b, i = ctrl t in let f = match i with | 0 -> Continue | 1 -> Skip | 2 -> Abort | _ -> fail "topdown_rewrite: bad value from ctrl" in b, f in ctrl_rewrite TopDown ctrl' rw let pointwise (tau : unit -> Tac unit) : Tac unit = t_pointwise BottomUp tau let pointwise' (tau : unit -> Tac unit) : Tac unit = t_pointwise TopDown tau let cur_module () : Tac name = moduleof (top_env ()) let open_modules () : Tac (list name) = env_open_modules (top_env ()) let fresh_uvar (o : option typ) : Tac term = let e = cur_env () in uvar_env e o let unify (t1 t2 : term) : Tac bool = let e = cur_env () in unify_env e t1 t2 let unify_guard (t1 t2 : term) : Tac bool = let e = cur_env () in unify_guard_env e t1 t2 let tmatch (t1 t2 : term) : Tac bool = let e = cur_env () in match_env e t1 t2 (** [divide n t1 t2] will split the current set of goals into the [n] first ones, and the rest. It then runs [t1] on the first set, and [t2] on the second, returning both results (and concatenating remaining goals). *) let divide (n:int) (l : unit -> Tac 'a) (r : unit -> Tac 'b) : Tac ('a * 'b) = if n < 0 then fail "divide: negative n"; let gs, sgs = goals (), smt_goals () in let gs1, gs2 = List.Tot.Base.splitAt n gs in set_goals gs1; set_smt_goals []; let x = l () in let gsl, sgsl = goals (), smt_goals () in set_goals gs2; set_smt_goals []; let y = r () in let gsr, sgsr = goals (), smt_goals () in set_goals (gsl @ gsr); set_smt_goals (sgs @ sgsl @ sgsr); (x, y) let rec iseq (ts : list (unit -> Tac unit)) : Tac unit = match ts with | t::ts -> let _ = divide 1 t (fun () -> iseq ts) in () | [] -> () (** [focus t] runs [t ()] on the current active goal, hiding all others and restoring them at the end. *) let focus (t : unit -> Tac 'a) : Tac 'a = match goals () with | [] -> fail "focus: no goals" | g::gs -> let sgs = smt_goals () in set_goals [g]; set_smt_goals []; let x = t () in set_goals (goals () @ gs); set_smt_goals (smt_goals () @ sgs); x (** Similar to [dump], but only dumping the current goal. *) let dump1 (m : string) = focus (fun () -> dump m) let rec mapAll (t : unit -> Tac 'a) : Tac (list 'a) = match goals () with | [] -> [] | _::_ -> let (h, t) = divide 1 t (fun () -> mapAll t) in h::t let rec iterAll (t : unit -> Tac unit) : Tac unit = (* Could use mapAll, but why even build that list *) match goals () with | [] -> () | _::_ -> let _ = divide 1 t (fun () -> iterAll t) in () let iterAllSMT (t : unit -> Tac unit) : Tac unit = let gs, sgs = goals (), smt_goals () in set_goals sgs; set_smt_goals []; iterAll t; let gs', sgs' = goals (), smt_goals () in set_goals gs; set_smt_goals (gs'@sgs') (** Runs tactic [t1] on the current goal, and then tactic [t2] on *each* subgoal produced by [t1]. Each invocation of [t2] runs on a proofstate with a single goal (they're "focused"). *) let seq (f : unit -> Tac unit) (g : unit -> Tac unit) : Tac unit = focus (fun () -> f (); iterAll g) let exact_args (qs : list aqualv) (t : term) : Tac unit = focus (fun () -> let n = List.Tot.Base.length qs in let uvs = repeatn n (fun () -> fresh_uvar None) in let t' = mk_app t (zip uvs qs) in exact t'; iter (fun uv -> if is_uvar uv then unshelve uv else ()) (L.rev uvs) ) let exact_n (n : int) (t : term) : Tac unit = exact_args (repeatn n (fun () -> Q_Explicit)) t (** [ngoals ()] returns the number of goals *) let ngoals () : Tac int = List.Tot.Base.length (goals ()) (** [ngoals_smt ()] returns the number of SMT goals *) let ngoals_smt () : Tac int = List.Tot.Base.length (smt_goals ()) (* sigh GGG fix names!! *) let fresh_namedv_named (s:string) : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal s; sort = seal (pack Tv_Unknown); uniq = n; }) (* Create a fresh bound variable (bv), using a generic name. See also [fresh_namedv_named]. *) let fresh_namedv () : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal ("x" ^ string_of_int n); sort = seal (pack Tv_Unknown); uniq = n; }) let fresh_binder_named (s : string) (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal s; sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_binder (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_implicit_binder (t : typ) : Tac binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Implicit; attrs = [] ; } let guard (b : bool) : TacH unit (requires (fun _ -> True)) (ensures (fun ps r -> if b then Success? r /\ Success?.ps r == ps else Failed? r)) (* ^ the proofstate on failure is not exactly equal (has the psc set) *) = if not b then fail "guard failed" else () let try_with (f : unit -> Tac 'a) (h : exn -> Tac 'a) : Tac 'a = match catch f with | Inl e -> h e | Inr x -> x let trytac (t : unit -> Tac 'a) : Tac (option 'a) = try Some (t ()) with | _ -> None let or_else (#a:Type) (t1 : unit -> Tac a) (t2 : unit -> Tac a) : Tac a = try t1 () with | _ -> t2 () val (<|>) : (unit -> Tac 'a) -> (unit -> Tac 'a) -> (unit -> Tac 'a) let (<|>) t1 t2 = fun () -> or_else t1 t2 let first (ts : list (unit -> Tac 'a)) : Tac 'a = L.fold_right (<|>) ts (fun () -> fail "no tactics to try") () let rec repeat (#a:Type) (t : unit -> Tac a) : Tac (list a) = match catch t with | Inl _ -> [] | Inr x -> x :: repeat t let repeat1 (#a:Type) (t : unit -> Tac a) : Tac (list a) = t () :: repeat t let repeat' (f : unit -> Tac 'a) : Tac unit = let _ = repeat f in () let norm_term (s : list norm_step) (t : term) : Tac term = let e = try cur_env () with | _ -> top_env () in norm_term_env e s t (** Join all of the SMT goals into one. This helps when all of them are expected to be similar, and therefore easier to prove at once by the SMT solver. TODO: would be nice to try to join them in a more meaningful way, as the order can matter. *) let join_all_smt_goals () = let gs, sgs = goals (), smt_goals () in set_smt_goals []; set_goals sgs; repeat' join; let sgs' = goals () in // should be a single one set_goals gs; set_smt_goals sgs'
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val discard: tau: (unit -> Tac 'a) -> unit -> Tac unit
[]
FStar.Tactics.V2.Derived.discard
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
tau: (_: Prims.unit -> FStar.Tactics.Effect.Tac 'a) -> _: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 34, "end_line": 500, "start_col": 4, "start_line": 500 }
Prims.Tot
val __cut : (a:Type) -> (b:Type) -> (a -> b) -> a -> b
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let __cut a b f x = f x
val __cut : (a:Type) -> (b:Type) -> (a -> b) -> a -> b let __cut a b f x =
false
null
false
f x
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[ "total" ]
[]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *) let commute_applied_match () : Tac unit = t_commute_applied_match () (** Similar to [apply_lemma], but will not instantiate uvars in the goal while applying. *) let apply_lemma_noinst (t : term) : Tac unit = t_apply_lemma true false t let apply_lemma_rw (t : term) : Tac unit = t_apply_lemma false true t (** [apply_raw f] is like [apply], but will ask for all arguments regardless of whether they appear free in further goals. See the explanation in [t_apply]. *) let apply_raw (t : term) : Tac unit = t_apply false false false t (** Like [exact], but allows for the term [e] to have a type [t] only under some guard [g], adding the guard as a goal. *) let exact_guard (t : term) : Tac unit = with_policy Goal (fun () -> t_exact true false t) (** (TODO: explain better) When running [pointwise tau] For every subterm [t'] of the goal's type [t], the engine will build a goal [Gamma |= t' == ?u] and run [tau] on it. When the tactic proves the goal, the engine will rewrite [t'] for [?u] in the original goal type. This is done for every subterm, bottom-up. This allows to recurse over an unknown goal type. By inspecting the goal, the [tau] can then decide what to do (to not do anything, use [trefl]). *) let t_pointwise (d:direction) (tau : unit -> Tac unit) : Tac unit = let ctrl (t:term) : Tac (bool & ctrl_flag) = true, Continue in let rw () : Tac unit = tau () in ctrl_rewrite d ctrl rw (** [topdown_rewrite ctrl rw] is used to rewrite those sub-terms [t] of the goal on which [fst (ctrl t)] returns true. On each such sub-term, [rw] is presented with an equality of goal of the form [Gamma |= t == ?u]. When [rw] proves the goal, the engine will rewrite [t] for [?u] in the original goal type. The goal formula is traversed top-down and the traversal can be controlled by [snd (ctrl t)]: When [snd (ctrl t) = 0], the traversal continues down through the position in the goal term. When [snd (ctrl t) = 1], the traversal continues to the next sub-tree of the goal. When [snd (ctrl t) = 2], no more rewrites are performed in the goal. *) let topdown_rewrite (ctrl : term -> Tac (bool * int)) (rw:unit -> Tac unit) : Tac unit = let ctrl' (t:term) : Tac (bool & ctrl_flag) = let b, i = ctrl t in let f = match i with | 0 -> Continue | 1 -> Skip | 2 -> Abort | _ -> fail "topdown_rewrite: bad value from ctrl" in b, f in ctrl_rewrite TopDown ctrl' rw let pointwise (tau : unit -> Tac unit) : Tac unit = t_pointwise BottomUp tau let pointwise' (tau : unit -> Tac unit) : Tac unit = t_pointwise TopDown tau let cur_module () : Tac name = moduleof (top_env ()) let open_modules () : Tac (list name) = env_open_modules (top_env ()) let fresh_uvar (o : option typ) : Tac term = let e = cur_env () in uvar_env e o let unify (t1 t2 : term) : Tac bool = let e = cur_env () in unify_env e t1 t2 let unify_guard (t1 t2 : term) : Tac bool = let e = cur_env () in unify_guard_env e t1 t2 let tmatch (t1 t2 : term) : Tac bool = let e = cur_env () in match_env e t1 t2 (** [divide n t1 t2] will split the current set of goals into the [n] first ones, and the rest. It then runs [t1] on the first set, and [t2] on the second, returning both results (and concatenating remaining goals). *) let divide (n:int) (l : unit -> Tac 'a) (r : unit -> Tac 'b) : Tac ('a * 'b) = if n < 0 then fail "divide: negative n"; let gs, sgs = goals (), smt_goals () in let gs1, gs2 = List.Tot.Base.splitAt n gs in set_goals gs1; set_smt_goals []; let x = l () in let gsl, sgsl = goals (), smt_goals () in set_goals gs2; set_smt_goals []; let y = r () in let gsr, sgsr = goals (), smt_goals () in set_goals (gsl @ gsr); set_smt_goals (sgs @ sgsl @ sgsr); (x, y) let rec iseq (ts : list (unit -> Tac unit)) : Tac unit = match ts with | t::ts -> let _ = divide 1 t (fun () -> iseq ts) in () | [] -> () (** [focus t] runs [t ()] on the current active goal, hiding all others and restoring them at the end. *) let focus (t : unit -> Tac 'a) : Tac 'a = match goals () with | [] -> fail "focus: no goals" | g::gs -> let sgs = smt_goals () in set_goals [g]; set_smt_goals []; let x = t () in set_goals (goals () @ gs); set_smt_goals (smt_goals () @ sgs); x (** Similar to [dump], but only dumping the current goal. *) let dump1 (m : string) = focus (fun () -> dump m) let rec mapAll (t : unit -> Tac 'a) : Tac (list 'a) = match goals () with | [] -> [] | _::_ -> let (h, t) = divide 1 t (fun () -> mapAll t) in h::t let rec iterAll (t : unit -> Tac unit) : Tac unit = (* Could use mapAll, but why even build that list *) match goals () with | [] -> () | _::_ -> let _ = divide 1 t (fun () -> iterAll t) in () let iterAllSMT (t : unit -> Tac unit) : Tac unit = let gs, sgs = goals (), smt_goals () in set_goals sgs; set_smt_goals []; iterAll t; let gs', sgs' = goals (), smt_goals () in set_goals gs; set_smt_goals (gs'@sgs') (** Runs tactic [t1] on the current goal, and then tactic [t2] on *each* subgoal produced by [t1]. Each invocation of [t2] runs on a proofstate with a single goal (they're "focused"). *) let seq (f : unit -> Tac unit) (g : unit -> Tac unit) : Tac unit = focus (fun () -> f (); iterAll g) let exact_args (qs : list aqualv) (t : term) : Tac unit = focus (fun () -> let n = List.Tot.Base.length qs in let uvs = repeatn n (fun () -> fresh_uvar None) in let t' = mk_app t (zip uvs qs) in exact t'; iter (fun uv -> if is_uvar uv then unshelve uv else ()) (L.rev uvs) ) let exact_n (n : int) (t : term) : Tac unit = exact_args (repeatn n (fun () -> Q_Explicit)) t (** [ngoals ()] returns the number of goals *) let ngoals () : Tac int = List.Tot.Base.length (goals ()) (** [ngoals_smt ()] returns the number of SMT goals *) let ngoals_smt () : Tac int = List.Tot.Base.length (smt_goals ()) (* sigh GGG fix names!! *) let fresh_namedv_named (s:string) : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal s; sort = seal (pack Tv_Unknown); uniq = n; }) (* Create a fresh bound variable (bv), using a generic name. See also [fresh_namedv_named]. *) let fresh_namedv () : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal ("x" ^ string_of_int n); sort = seal (pack Tv_Unknown); uniq = n; }) let fresh_binder_named (s : string) (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal s; sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_binder (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_implicit_binder (t : typ) : Tac binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Implicit; attrs = [] ; } let guard (b : bool) : TacH unit (requires (fun _ -> True)) (ensures (fun ps r -> if b then Success? r /\ Success?.ps r == ps else Failed? r)) (* ^ the proofstate on failure is not exactly equal (has the psc set) *) = if not b then fail "guard failed" else () let try_with (f : unit -> Tac 'a) (h : exn -> Tac 'a) : Tac 'a = match catch f with | Inl e -> h e | Inr x -> x let trytac (t : unit -> Tac 'a) : Tac (option 'a) = try Some (t ()) with | _ -> None let or_else (#a:Type) (t1 : unit -> Tac a) (t2 : unit -> Tac a) : Tac a = try t1 () with | _ -> t2 () val (<|>) : (unit -> Tac 'a) -> (unit -> Tac 'a) -> (unit -> Tac 'a) let (<|>) t1 t2 = fun () -> or_else t1 t2 let first (ts : list (unit -> Tac 'a)) : Tac 'a = L.fold_right (<|>) ts (fun () -> fail "no tactics to try") () let rec repeat (#a:Type) (t : unit -> Tac a) : Tac (list a) = match catch t with | Inl _ -> [] | Inr x -> x :: repeat t let repeat1 (#a:Type) (t : unit -> Tac a) : Tac (list a) = t () :: repeat t let repeat' (f : unit -> Tac 'a) : Tac unit = let _ = repeat f in () let norm_term (s : list norm_step) (t : term) : Tac term = let e = try cur_env () with | _ -> top_env () in norm_term_env e s t (** Join all of the SMT goals into one. This helps when all of them are expected to be similar, and therefore easier to prove at once by the SMT solver. TODO: would be nice to try to join them in a more meaningful way, as the order can matter. *) let join_all_smt_goals () = let gs, sgs = goals (), smt_goals () in set_smt_goals []; set_goals sgs; repeat' join; let sgs' = goals () in // should be a single one set_goals gs; set_smt_goals sgs' let discard (tau : unit -> Tac 'a) : unit -> Tac unit = fun () -> let _ = tau () in () // TODO: do we want some value out of this? let rec repeatseq (#a:Type) (t : unit -> Tac a) : Tac unit = let _ = trytac (fun () -> (discard t) `seq` (discard (fun () -> repeatseq t))) in () let tadmit () = tadmit_t (`()) let admit1 () : Tac unit = tadmit () let admit_all () : Tac unit = let _ = repeat tadmit in () (** [is_guard] returns whether the current goal arose from a typechecking guard *) let is_guard () : Tac bool = Tactics.Types.is_guard (_cur_goal ()) let skip_guard () : Tac unit = if is_guard () then smt () else fail "" let guards_to_smt () : Tac unit = let _ = repeat skip_guard in () let simpl () : Tac unit = norm [simplify; primops] let whnf () : Tac unit = norm [weak; hnf; primops; delta] let compute () : Tac unit = norm [primops; iota; delta; zeta] let intros () : Tac (list binding) = repeat intro let intros' () : Tac unit = let _ = intros () in () let destruct tm : Tac unit = let _ = t_destruct tm in () let destruct_intros tm : Tac unit = seq (fun () -> let _ = t_destruct tm in ()) intros'
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val __cut : (a:Type) -> (b:Type) -> (a -> b) -> a -> b
[]
FStar.Tactics.V2.Derived.__cut
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: Type -> b: Type -> f: (_: a -> b) -> x: a -> b
{ "end_col": 31, "end_line": 539, "start_col": 28, "start_line": 539 }
FStar.Tactics.Effect.Tac
val apply_noinst (t: term) : Tac unit
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let apply_noinst (t : term) : Tac unit = t_apply true true false t
val apply_noinst (t: term) : Tac unit let apply_noinst (t: term) : Tac unit =
true
null
false
t_apply true true false t
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "FStar.Tactics.NamedView.term", "FStar.Tactics.V2.Builtins.t_apply", "Prims.unit" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val apply_noinst (t: term) : Tac unit
[]
FStar.Tactics.V2.Derived.apply_noinst
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t: FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 29, "end_line": 185, "start_col": 4, "start_line": 185 }
FStar.Tactics.Effect.Tac
val commute_applied_match: Prims.unit -> Tac unit
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let commute_applied_match () : Tac unit = t_commute_applied_match ()
val commute_applied_match: Prims.unit -> Tac unit let commute_applied_match () : Tac unit =
true
null
false
t_commute_applied_match ()
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "Prims.unit", "FStar.Tactics.V2.Builtins.t_commute_applied_match" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *)
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val commute_applied_match: Prims.unit -> Tac unit
[]
FStar.Tactics.V2.Derived.commute_applied_match
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 28, "end_line": 204, "start_col": 2, "start_line": 204 }
FStar.Tactics.Effect.Tac
val l_to_r (lems: list term) : Tac unit
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let l_to_r (lems:list term) : Tac unit = let first_or_trefl () : Tac unit = fold_left (fun k l () -> (fun () -> apply_lemma_rw l) `or_else` k) trefl lems () in pointwise first_or_trefl
val l_to_r (lems: list term) : Tac unit let l_to_r (lems: list term) : Tac unit =
true
null
false
let first_or_trefl () : Tac unit = fold_left (fun k l () -> (fun () -> apply_lemma_rw l) `or_else` k) trefl lems () in pointwise first_or_trefl
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "Prims.list", "FStar.Tactics.NamedView.term", "FStar.Tactics.V2.Derived.pointwise", "Prims.unit", "FStar.Tactics.Util.fold_left", "FStar.Tactics.V2.Derived.or_else", "FStar.Tactics.V2.Derived.apply_lemma_rw", "FStar.Tactics.V2.Derived.trefl" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *) let commute_applied_match () : Tac unit = t_commute_applied_match () (** Similar to [apply_lemma], but will not instantiate uvars in the goal while applying. *) let apply_lemma_noinst (t : term) : Tac unit = t_apply_lemma true false t let apply_lemma_rw (t : term) : Tac unit = t_apply_lemma false true t (** [apply_raw f] is like [apply], but will ask for all arguments regardless of whether they appear free in further goals. See the explanation in [t_apply]. *) let apply_raw (t : term) : Tac unit = t_apply false false false t (** Like [exact], but allows for the term [e] to have a type [t] only under some guard [g], adding the guard as a goal. *) let exact_guard (t : term) : Tac unit = with_policy Goal (fun () -> t_exact true false t) (** (TODO: explain better) When running [pointwise tau] For every subterm [t'] of the goal's type [t], the engine will build a goal [Gamma |= t' == ?u] and run [tau] on it. When the tactic proves the goal, the engine will rewrite [t'] for [?u] in the original goal type. This is done for every subterm, bottom-up. This allows to recurse over an unknown goal type. By inspecting the goal, the [tau] can then decide what to do (to not do anything, use [trefl]). *) let t_pointwise (d:direction) (tau : unit -> Tac unit) : Tac unit = let ctrl (t:term) : Tac (bool & ctrl_flag) = true, Continue in let rw () : Tac unit = tau () in ctrl_rewrite d ctrl rw (** [topdown_rewrite ctrl rw] is used to rewrite those sub-terms [t] of the goal on which [fst (ctrl t)] returns true. On each such sub-term, [rw] is presented with an equality of goal of the form [Gamma |= t == ?u]. When [rw] proves the goal, the engine will rewrite [t] for [?u] in the original goal type. The goal formula is traversed top-down and the traversal can be controlled by [snd (ctrl t)]: When [snd (ctrl t) = 0], the traversal continues down through the position in the goal term. When [snd (ctrl t) = 1], the traversal continues to the next sub-tree of the goal. When [snd (ctrl t) = 2], no more rewrites are performed in the goal. *) let topdown_rewrite (ctrl : term -> Tac (bool * int)) (rw:unit -> Tac unit) : Tac unit = let ctrl' (t:term) : Tac (bool & ctrl_flag) = let b, i = ctrl t in let f = match i with | 0 -> Continue | 1 -> Skip | 2 -> Abort | _ -> fail "topdown_rewrite: bad value from ctrl" in b, f in ctrl_rewrite TopDown ctrl' rw let pointwise (tau : unit -> Tac unit) : Tac unit = t_pointwise BottomUp tau let pointwise' (tau : unit -> Tac unit) : Tac unit = t_pointwise TopDown tau let cur_module () : Tac name = moduleof (top_env ()) let open_modules () : Tac (list name) = env_open_modules (top_env ()) let fresh_uvar (o : option typ) : Tac term = let e = cur_env () in uvar_env e o let unify (t1 t2 : term) : Tac bool = let e = cur_env () in unify_env e t1 t2 let unify_guard (t1 t2 : term) : Tac bool = let e = cur_env () in unify_guard_env e t1 t2 let tmatch (t1 t2 : term) : Tac bool = let e = cur_env () in match_env e t1 t2 (** [divide n t1 t2] will split the current set of goals into the [n] first ones, and the rest. It then runs [t1] on the first set, and [t2] on the second, returning both results (and concatenating remaining goals). *) let divide (n:int) (l : unit -> Tac 'a) (r : unit -> Tac 'b) : Tac ('a * 'b) = if n < 0 then fail "divide: negative n"; let gs, sgs = goals (), smt_goals () in let gs1, gs2 = List.Tot.Base.splitAt n gs in set_goals gs1; set_smt_goals []; let x = l () in let gsl, sgsl = goals (), smt_goals () in set_goals gs2; set_smt_goals []; let y = r () in let gsr, sgsr = goals (), smt_goals () in set_goals (gsl @ gsr); set_smt_goals (sgs @ sgsl @ sgsr); (x, y) let rec iseq (ts : list (unit -> Tac unit)) : Tac unit = match ts with | t::ts -> let _ = divide 1 t (fun () -> iseq ts) in () | [] -> () (** [focus t] runs [t ()] on the current active goal, hiding all others and restoring them at the end. *) let focus (t : unit -> Tac 'a) : Tac 'a = match goals () with | [] -> fail "focus: no goals" | g::gs -> let sgs = smt_goals () in set_goals [g]; set_smt_goals []; let x = t () in set_goals (goals () @ gs); set_smt_goals (smt_goals () @ sgs); x (** Similar to [dump], but only dumping the current goal. *) let dump1 (m : string) = focus (fun () -> dump m) let rec mapAll (t : unit -> Tac 'a) : Tac (list 'a) = match goals () with | [] -> [] | _::_ -> let (h, t) = divide 1 t (fun () -> mapAll t) in h::t let rec iterAll (t : unit -> Tac unit) : Tac unit = (* Could use mapAll, but why even build that list *) match goals () with | [] -> () | _::_ -> let _ = divide 1 t (fun () -> iterAll t) in () let iterAllSMT (t : unit -> Tac unit) : Tac unit = let gs, sgs = goals (), smt_goals () in set_goals sgs; set_smt_goals []; iterAll t; let gs', sgs' = goals (), smt_goals () in set_goals gs; set_smt_goals (gs'@sgs') (** Runs tactic [t1] on the current goal, and then tactic [t2] on *each* subgoal produced by [t1]. Each invocation of [t2] runs on a proofstate with a single goal (they're "focused"). *) let seq (f : unit -> Tac unit) (g : unit -> Tac unit) : Tac unit = focus (fun () -> f (); iterAll g) let exact_args (qs : list aqualv) (t : term) : Tac unit = focus (fun () -> let n = List.Tot.Base.length qs in let uvs = repeatn n (fun () -> fresh_uvar None) in let t' = mk_app t (zip uvs qs) in exact t'; iter (fun uv -> if is_uvar uv then unshelve uv else ()) (L.rev uvs) ) let exact_n (n : int) (t : term) : Tac unit = exact_args (repeatn n (fun () -> Q_Explicit)) t (** [ngoals ()] returns the number of goals *) let ngoals () : Tac int = List.Tot.Base.length (goals ()) (** [ngoals_smt ()] returns the number of SMT goals *) let ngoals_smt () : Tac int = List.Tot.Base.length (smt_goals ()) (* sigh GGG fix names!! *) let fresh_namedv_named (s:string) : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal s; sort = seal (pack Tv_Unknown); uniq = n; }) (* Create a fresh bound variable (bv), using a generic name. See also [fresh_namedv_named]. *) let fresh_namedv () : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal ("x" ^ string_of_int n); sort = seal (pack Tv_Unknown); uniq = n; }) let fresh_binder_named (s : string) (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal s; sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_binder (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_implicit_binder (t : typ) : Tac binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Implicit; attrs = [] ; } let guard (b : bool) : TacH unit (requires (fun _ -> True)) (ensures (fun ps r -> if b then Success? r /\ Success?.ps r == ps else Failed? r)) (* ^ the proofstate on failure is not exactly equal (has the psc set) *) = if not b then fail "guard failed" else () let try_with (f : unit -> Tac 'a) (h : exn -> Tac 'a) : Tac 'a = match catch f with | Inl e -> h e | Inr x -> x let trytac (t : unit -> Tac 'a) : Tac (option 'a) = try Some (t ()) with | _ -> None let or_else (#a:Type) (t1 : unit -> Tac a) (t2 : unit -> Tac a) : Tac a = try t1 () with | _ -> t2 () val (<|>) : (unit -> Tac 'a) -> (unit -> Tac 'a) -> (unit -> Tac 'a) let (<|>) t1 t2 = fun () -> or_else t1 t2 let first (ts : list (unit -> Tac 'a)) : Tac 'a = L.fold_right (<|>) ts (fun () -> fail "no tactics to try") () let rec repeat (#a:Type) (t : unit -> Tac a) : Tac (list a) = match catch t with | Inl _ -> [] | Inr x -> x :: repeat t let repeat1 (#a:Type) (t : unit -> Tac a) : Tac (list a) = t () :: repeat t let repeat' (f : unit -> Tac 'a) : Tac unit = let _ = repeat f in () let norm_term (s : list norm_step) (t : term) : Tac term = let e = try cur_env () with | _ -> top_env () in norm_term_env e s t (** Join all of the SMT goals into one. This helps when all of them are expected to be similar, and therefore easier to prove at once by the SMT solver. TODO: would be nice to try to join them in a more meaningful way, as the order can matter. *) let join_all_smt_goals () = let gs, sgs = goals (), smt_goals () in set_smt_goals []; set_goals sgs; repeat' join; let sgs' = goals () in // should be a single one set_goals gs; set_smt_goals sgs' let discard (tau : unit -> Tac 'a) : unit -> Tac unit = fun () -> let _ = tau () in () // TODO: do we want some value out of this? let rec repeatseq (#a:Type) (t : unit -> Tac a) : Tac unit = let _ = trytac (fun () -> (discard t) `seq` (discard (fun () -> repeatseq t))) in () let tadmit () = tadmit_t (`()) let admit1 () : Tac unit = tadmit () let admit_all () : Tac unit = let _ = repeat tadmit in () (** [is_guard] returns whether the current goal arose from a typechecking guard *) let is_guard () : Tac bool = Tactics.Types.is_guard (_cur_goal ()) let skip_guard () : Tac unit = if is_guard () then smt () else fail "" let guards_to_smt () : Tac unit = let _ = repeat skip_guard in () let simpl () : Tac unit = norm [simplify; primops] let whnf () : Tac unit = norm [weak; hnf; primops; delta] let compute () : Tac unit = norm [primops; iota; delta; zeta] let intros () : Tac (list binding) = repeat intro let intros' () : Tac unit = let _ = intros () in () let destruct tm : Tac unit = let _ = t_destruct tm in () let destruct_intros tm : Tac unit = seq (fun () -> let _ = t_destruct tm in ()) intros' private val __cut : (a:Type) -> (b:Type) -> (a -> b) -> a -> b private let __cut a b f x = f x let tcut (t:term) : Tac binding = let g = cur_goal () in let tt = mk_e_app (`__cut) [t; g] in apply tt; intro () let pose (t:term) : Tac binding = apply (`__cut); flip (); exact t; intro () let intro_as (s:string) : Tac binding = let b = intro () in rename_to b s let pose_as (s:string) (t:term) : Tac binding = let b = pose t in rename_to b s let for_each_binding (f : binding -> Tac 'a) : Tac (list 'a) = map f (cur_vars ()) let rec revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> revert (); revert_all tl let binder_sort (b : binder) : Tot typ = b.sort // Cannot define this inside `assumption` due to #1091 private let rec __assumption_aux (xs : list binding) : Tac unit = match xs with | [] -> fail "no assumption matches goal" | b::bs -> try exact b with | _ -> try (apply (`FStar.Squash.return_squash); exact b) with | _ -> __assumption_aux bs let assumption () : Tac unit = __assumption_aux (cur_vars ()) let destruct_equality_implication (t:term) : Tac (option (formula * term)) = match term_as_formula t with | Implies lhs rhs -> let lhs = term_as_formula' lhs in begin match lhs with | Comp (Eq _) _ _ -> Some (lhs, rhs) | _ -> None end | _ -> None private let __eq_sym #t (a b : t) : Lemma ((a == b) == (b == a)) = FStar.PropositionalExtensionality.apply (a==b) (b==a) (** Like [rewrite], but works with equalities [v == e] and [e == v] *) let rewrite' (x:binding) : Tac unit = ((fun () -> rewrite x) <|> (fun () -> var_retype x; apply_lemma (`__eq_sym); rewrite x) <|> (fun () -> fail "rewrite' failed")) () let rec try_rewrite_equality (x:term) (bs:list binding) : Tac unit = match bs with | [] -> () | x_t::bs -> begin match term_as_formula (type_of_binding x_t) with | Comp (Eq _) y _ -> if term_eq x y then rewrite x_t else try_rewrite_equality x bs | _ -> try_rewrite_equality x bs end let rec rewrite_all_context_equalities (bs:list binding) : Tac unit = match bs with | [] -> () | x_t::bs -> begin (try rewrite x_t with | _ -> ()); rewrite_all_context_equalities bs end let rewrite_eqs_from_context () : Tac unit = rewrite_all_context_equalities (cur_vars ()) let rewrite_equality (t:term) : Tac unit = try_rewrite_equality t (cur_vars ()) let unfold_def (t:term) : Tac unit = match inspect t with | Tv_FVar fv -> let n = implode_qn (inspect_fv fv) in norm [delta_fully [n]] | _ -> fail "unfold_def: term is not a fv" (** Rewrites left-to-right, and bottom-up, given a set of lemmas stating equalities. The lemmas need to prove *propositional* equalities, that
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val l_to_r (lems: list term) : Tac unit
[]
FStar.Tactics.V2.Derived.l_to_r
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
lems: Prims.list FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 28, "end_line": 653, "start_col": 40, "start_line": 647 }
FStar.Tactics.Effect.Tac
val focus_all: Prims.unit -> Tac unit
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let focus_all () : Tac unit = set_goals (goals () @ smt_goals ()); set_smt_goals []
val focus_all: Prims.unit -> Tac unit let focus_all () : Tac unit =
true
null
false
set_goals (goals () @ smt_goals ()); set_smt_goals []
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "Prims.unit", "FStar.Tactics.V2.Builtins.set_smt_goals", "Prims.Nil", "FStar.Tactics.Types.goal", "FStar.Tactics.V2.Builtins.set_goals", "Prims.list", "FStar.Tactics.V2.Derived.op_At", "FStar.Tactics.V2.Derived.smt_goals", "FStar.Tactics.V2.Derived.goals" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *) let commute_applied_match () : Tac unit = t_commute_applied_match () (** Similar to [apply_lemma], but will not instantiate uvars in the goal while applying. *) let apply_lemma_noinst (t : term) : Tac unit = t_apply_lemma true false t let apply_lemma_rw (t : term) : Tac unit = t_apply_lemma false true t (** [apply_raw f] is like [apply], but will ask for all arguments regardless of whether they appear free in further goals. See the explanation in [t_apply]. *) let apply_raw (t : term) : Tac unit = t_apply false false false t (** Like [exact], but allows for the term [e] to have a type [t] only under some guard [g], adding the guard as a goal. *) let exact_guard (t : term) : Tac unit = with_policy Goal (fun () -> t_exact true false t) (** (TODO: explain better) When running [pointwise tau] For every subterm [t'] of the goal's type [t], the engine will build a goal [Gamma |= t' == ?u] and run [tau] on it. When the tactic proves the goal, the engine will rewrite [t'] for [?u] in the original goal type. This is done for every subterm, bottom-up. This allows to recurse over an unknown goal type. By inspecting the goal, the [tau] can then decide what to do (to not do anything, use [trefl]). *) let t_pointwise (d:direction) (tau : unit -> Tac unit) : Tac unit = let ctrl (t:term) : Tac (bool & ctrl_flag) = true, Continue in let rw () : Tac unit = tau () in ctrl_rewrite d ctrl rw (** [topdown_rewrite ctrl rw] is used to rewrite those sub-terms [t] of the goal on which [fst (ctrl t)] returns true. On each such sub-term, [rw] is presented with an equality of goal of the form [Gamma |= t == ?u]. When [rw] proves the goal, the engine will rewrite [t] for [?u] in the original goal type. The goal formula is traversed top-down and the traversal can be controlled by [snd (ctrl t)]: When [snd (ctrl t) = 0], the traversal continues down through the position in the goal term. When [snd (ctrl t) = 1], the traversal continues to the next sub-tree of the goal. When [snd (ctrl t) = 2], no more rewrites are performed in the goal. *) let topdown_rewrite (ctrl : term -> Tac (bool * int)) (rw:unit -> Tac unit) : Tac unit = let ctrl' (t:term) : Tac (bool & ctrl_flag) = let b, i = ctrl t in let f = match i with | 0 -> Continue | 1 -> Skip | 2 -> Abort | _ -> fail "topdown_rewrite: bad value from ctrl" in b, f in ctrl_rewrite TopDown ctrl' rw let pointwise (tau : unit -> Tac unit) : Tac unit = t_pointwise BottomUp tau let pointwise' (tau : unit -> Tac unit) : Tac unit = t_pointwise TopDown tau let cur_module () : Tac name = moduleof (top_env ()) let open_modules () : Tac (list name) = env_open_modules (top_env ()) let fresh_uvar (o : option typ) : Tac term = let e = cur_env () in uvar_env e o let unify (t1 t2 : term) : Tac bool = let e = cur_env () in unify_env e t1 t2 let unify_guard (t1 t2 : term) : Tac bool = let e = cur_env () in unify_guard_env e t1 t2 let tmatch (t1 t2 : term) : Tac bool = let e = cur_env () in match_env e t1 t2 (** [divide n t1 t2] will split the current set of goals into the [n] first ones, and the rest. It then runs [t1] on the first set, and [t2] on the second, returning both results (and concatenating remaining goals). *) let divide (n:int) (l : unit -> Tac 'a) (r : unit -> Tac 'b) : Tac ('a * 'b) = if n < 0 then fail "divide: negative n"; let gs, sgs = goals (), smt_goals () in let gs1, gs2 = List.Tot.Base.splitAt n gs in set_goals gs1; set_smt_goals []; let x = l () in let gsl, sgsl = goals (), smt_goals () in set_goals gs2; set_smt_goals []; let y = r () in let gsr, sgsr = goals (), smt_goals () in set_goals (gsl @ gsr); set_smt_goals (sgs @ sgsl @ sgsr); (x, y) let rec iseq (ts : list (unit -> Tac unit)) : Tac unit = match ts with | t::ts -> let _ = divide 1 t (fun () -> iseq ts) in () | [] -> () (** [focus t] runs [t ()] on the current active goal, hiding all others and restoring them at the end. *) let focus (t : unit -> Tac 'a) : Tac 'a = match goals () with | [] -> fail "focus: no goals" | g::gs -> let sgs = smt_goals () in set_goals [g]; set_smt_goals []; let x = t () in set_goals (goals () @ gs); set_smt_goals (smt_goals () @ sgs); x (** Similar to [dump], but only dumping the current goal. *) let dump1 (m : string) = focus (fun () -> dump m) let rec mapAll (t : unit -> Tac 'a) : Tac (list 'a) = match goals () with | [] -> [] | _::_ -> let (h, t) = divide 1 t (fun () -> mapAll t) in h::t let rec iterAll (t : unit -> Tac unit) : Tac unit = (* Could use mapAll, but why even build that list *) match goals () with | [] -> () | _::_ -> let _ = divide 1 t (fun () -> iterAll t) in () let iterAllSMT (t : unit -> Tac unit) : Tac unit = let gs, sgs = goals (), smt_goals () in set_goals sgs; set_smt_goals []; iterAll t; let gs', sgs' = goals (), smt_goals () in set_goals gs; set_smt_goals (gs'@sgs') (** Runs tactic [t1] on the current goal, and then tactic [t2] on *each* subgoal produced by [t1]. Each invocation of [t2] runs on a proofstate with a single goal (they're "focused"). *) let seq (f : unit -> Tac unit) (g : unit -> Tac unit) : Tac unit = focus (fun () -> f (); iterAll g) let exact_args (qs : list aqualv) (t : term) : Tac unit = focus (fun () -> let n = List.Tot.Base.length qs in let uvs = repeatn n (fun () -> fresh_uvar None) in let t' = mk_app t (zip uvs qs) in exact t'; iter (fun uv -> if is_uvar uv then unshelve uv else ()) (L.rev uvs) ) let exact_n (n : int) (t : term) : Tac unit = exact_args (repeatn n (fun () -> Q_Explicit)) t (** [ngoals ()] returns the number of goals *) let ngoals () : Tac int = List.Tot.Base.length (goals ()) (** [ngoals_smt ()] returns the number of SMT goals *) let ngoals_smt () : Tac int = List.Tot.Base.length (smt_goals ()) (* sigh GGG fix names!! *) let fresh_namedv_named (s:string) : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal s; sort = seal (pack Tv_Unknown); uniq = n; }) (* Create a fresh bound variable (bv), using a generic name. See also [fresh_namedv_named]. *) let fresh_namedv () : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal ("x" ^ string_of_int n); sort = seal (pack Tv_Unknown); uniq = n; }) let fresh_binder_named (s : string) (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal s; sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_binder (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_implicit_binder (t : typ) : Tac binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Implicit; attrs = [] ; } let guard (b : bool) : TacH unit (requires (fun _ -> True)) (ensures (fun ps r -> if b then Success? r /\ Success?.ps r == ps else Failed? r)) (* ^ the proofstate on failure is not exactly equal (has the psc set) *) = if not b then fail "guard failed" else () let try_with (f : unit -> Tac 'a) (h : exn -> Tac 'a) : Tac 'a = match catch f with | Inl e -> h e | Inr x -> x let trytac (t : unit -> Tac 'a) : Tac (option 'a) = try Some (t ()) with | _ -> None let or_else (#a:Type) (t1 : unit -> Tac a) (t2 : unit -> Tac a) : Tac a = try t1 () with | _ -> t2 () val (<|>) : (unit -> Tac 'a) -> (unit -> Tac 'a) -> (unit -> Tac 'a) let (<|>) t1 t2 = fun () -> or_else t1 t2 let first (ts : list (unit -> Tac 'a)) : Tac 'a = L.fold_right (<|>) ts (fun () -> fail "no tactics to try") () let rec repeat (#a:Type) (t : unit -> Tac a) : Tac (list a) = match catch t with | Inl _ -> [] | Inr x -> x :: repeat t let repeat1 (#a:Type) (t : unit -> Tac a) : Tac (list a) = t () :: repeat t let repeat' (f : unit -> Tac 'a) : Tac unit = let _ = repeat f in () let norm_term (s : list norm_step) (t : term) : Tac term = let e = try cur_env () with | _ -> top_env () in norm_term_env e s t (** Join all of the SMT goals into one. This helps when all of them are expected to be similar, and therefore easier to prove at once by the SMT solver. TODO: would be nice to try to join them in a more meaningful way, as the order can matter. *) let join_all_smt_goals () = let gs, sgs = goals (), smt_goals () in set_smt_goals []; set_goals sgs; repeat' join; let sgs' = goals () in // should be a single one set_goals gs; set_smt_goals sgs' let discard (tau : unit -> Tac 'a) : unit -> Tac unit = fun () -> let _ = tau () in () // TODO: do we want some value out of this? let rec repeatseq (#a:Type) (t : unit -> Tac a) : Tac unit = let _ = trytac (fun () -> (discard t) `seq` (discard (fun () -> repeatseq t))) in () let tadmit () = tadmit_t (`()) let admit1 () : Tac unit = tadmit () let admit_all () : Tac unit = let _ = repeat tadmit in () (** [is_guard] returns whether the current goal arose from a typechecking guard *) let is_guard () : Tac bool = Tactics.Types.is_guard (_cur_goal ()) let skip_guard () : Tac unit = if is_guard () then smt () else fail "" let guards_to_smt () : Tac unit = let _ = repeat skip_guard in () let simpl () : Tac unit = norm [simplify; primops] let whnf () : Tac unit = norm [weak; hnf; primops; delta] let compute () : Tac unit = norm [primops; iota; delta; zeta] let intros () : Tac (list binding) = repeat intro let intros' () : Tac unit = let _ = intros () in () let destruct tm : Tac unit = let _ = t_destruct tm in () let destruct_intros tm : Tac unit = seq (fun () -> let _ = t_destruct tm in ()) intros' private val __cut : (a:Type) -> (b:Type) -> (a -> b) -> a -> b private let __cut a b f x = f x let tcut (t:term) : Tac binding = let g = cur_goal () in let tt = mk_e_app (`__cut) [t; g] in apply tt; intro () let pose (t:term) : Tac binding = apply (`__cut); flip (); exact t; intro () let intro_as (s:string) : Tac binding = let b = intro () in rename_to b s let pose_as (s:string) (t:term) : Tac binding = let b = pose t in rename_to b s let for_each_binding (f : binding -> Tac 'a) : Tac (list 'a) = map f (cur_vars ()) let rec revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> revert (); revert_all tl let binder_sort (b : binder) : Tot typ = b.sort // Cannot define this inside `assumption` due to #1091 private let rec __assumption_aux (xs : list binding) : Tac unit = match xs with | [] -> fail "no assumption matches goal" | b::bs -> try exact b with | _ -> try (apply (`FStar.Squash.return_squash); exact b) with | _ -> __assumption_aux bs let assumption () : Tac unit = __assumption_aux (cur_vars ()) let destruct_equality_implication (t:term) : Tac (option (formula * term)) = match term_as_formula t with | Implies lhs rhs -> let lhs = term_as_formula' lhs in begin match lhs with | Comp (Eq _) _ _ -> Some (lhs, rhs) | _ -> None end | _ -> None private let __eq_sym #t (a b : t) : Lemma ((a == b) == (b == a)) = FStar.PropositionalExtensionality.apply (a==b) (b==a) (** Like [rewrite], but works with equalities [v == e] and [e == v] *) let rewrite' (x:binding) : Tac unit = ((fun () -> rewrite x) <|> (fun () -> var_retype x; apply_lemma (`__eq_sym); rewrite x) <|> (fun () -> fail "rewrite' failed")) () let rec try_rewrite_equality (x:term) (bs:list binding) : Tac unit = match bs with | [] -> () | x_t::bs -> begin match term_as_formula (type_of_binding x_t) with | Comp (Eq _) y _ -> if term_eq x y then rewrite x_t else try_rewrite_equality x bs | _ -> try_rewrite_equality x bs end let rec rewrite_all_context_equalities (bs:list binding) : Tac unit = match bs with | [] -> () | x_t::bs -> begin (try rewrite x_t with | _ -> ()); rewrite_all_context_equalities bs end let rewrite_eqs_from_context () : Tac unit = rewrite_all_context_equalities (cur_vars ()) let rewrite_equality (t:term) : Tac unit = try_rewrite_equality t (cur_vars ()) let unfold_def (t:term) : Tac unit = match inspect t with | Tv_FVar fv -> let n = implode_qn (inspect_fv fv) in norm [delta_fully [n]] | _ -> fail "unfold_def: term is not a fv" (** Rewrites left-to-right, and bottom-up, given a set of lemmas stating equalities. The lemmas need to prove *propositional* equalities, that is, using [==]. *) let l_to_r (lems:list term) : Tac unit = let first_or_trefl () : Tac unit = fold_left (fun k l () -> (fun () -> apply_lemma_rw l) `or_else` k) trefl lems () in pointwise first_or_trefl let mk_squash (t : term) : Tot term = let sq : term = pack (Tv_FVar (pack_fv squash_qn)) in mk_e_app sq [t] let mk_sq_eq (t1 t2 : term) : Tot term = let eq : term = pack (Tv_FVar (pack_fv eq2_qn)) in mk_squash (mk_e_app eq [t1; t2]) (** Rewrites all appearances of a term [t1] in the goal into [t2]. Creates a new goal for [t1 == t2]. *) let grewrite (t1 t2 : term) : Tac unit = let e = tcut (mk_sq_eq t1 t2) in let e = pack (Tv_Var e) in pointwise (fun () -> (* If the LHS is a uvar, do nothing, so we do not instantiate it. *) let is_uvar = match term_as_formula (cur_goal()) with | Comp (Eq _) lhs rhs -> (match inspect lhs with | Tv_Uvar _ _ -> true | _ -> false) | _ -> false in if is_uvar then trefl () else try exact e with | _ -> trefl ()) private let __un_sq_eq (#a:Type) (x y : a) (_ : (x == y)) : Lemma (x == y) = () (** A wrapper to [grewrite] which takes a binder of an equality type *) let grewrite_eq (b:binding) : Tac unit = match term_as_formula (type_of_binding b) with | Comp (Eq _) l r -> grewrite l r; iseq [idtac; (fun () -> exact b)] | _ -> begin match term_as_formula' (type_of_binding b) with | Comp (Eq _) l r -> grewrite l r; iseq [idtac; (fun () -> apply_lemma (`__un_sq_eq); exact b)] | _ -> fail "grewrite_eq: binder type is not an equality" end private let admit_dump_t () : Tac unit = dump "Admitting"; apply (`admit) val admit_dump : #a:Type -> (#[admit_dump_t ()] x : (unit -> Admit a)) -> unit -> Admit a let admit_dump #a #x () = x () private let magic_dump_t () : Tac unit = dump "Admitting"; apply (`magic); exact (`()); () val magic_dump : #a:Type -> (#[magic_dump_t ()] x : a) -> unit -> Tot a let magic_dump #a #x () = x let change_with t1 t2 : Tac unit = focus (fun () -> grewrite t1 t2; iseq [idtac; trivial] ) let change_sq (t1 : term) : Tac unit = change (mk_e_app (`squash) [t1]) let finish_by (t : unit -> Tac 'a) : Tac 'a = let x = t () in or_else qed (fun () -> fail "finish_by: not finished"); x let solve_then #a #b (t1 : unit -> Tac a) (t2 : a -> Tac b) : Tac b = dup (); let x = focus (fun () -> finish_by t1) in let y = t2 x in trefl (); y let add_elem (t : unit -> Tac 'a) : Tac 'a = focus (fun () -> apply (`Cons); focus (fun () -> let x = t () in qed (); x ) ) (* * Specialize a function by partially evaluating it * For example: * let rec foo (l:list int) (x:int) :St int = match l with | [] -> x | hd::tl -> x + foo tl x let f :int -> St int = synth_by_tactic (specialize (foo [1; 2]) [%`foo]) * would make the definition of f as x + x + x * * f is the term that needs to be specialized * l is the list of names to be delta-ed *) let specialize (#a:Type) (f:a) (l:list string) :unit -> Tac unit = fun () -> solve_then (fun () -> exact (quote f)) (fun () -> norm [delta_only l; iota; zeta]) let tlabel (l:string) = match goals () with | [] -> fail "tlabel: no goals" | h::t -> set_goals (set_label l h :: t) let tlabel' (l:string) = match goals () with | [] -> fail "tlabel': no goals" | h::t -> let h = set_label (l ^ get_label h) h in set_goals (h :: t)
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val focus_all: Prims.unit -> Tac unit
[]
FStar.Tactics.V2.Derived.focus_all
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 20, "end_line": 782, "start_col": 4, "start_line": 781 }
FStar.Tactics.Effect.Tac
val unify_guard (t1 t2: term) : Tac bool
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let unify_guard (t1 t2 : term) : Tac bool = let e = cur_env () in unify_guard_env e t1 t2
val unify_guard (t1 t2: term) : Tac bool let unify_guard (t1 t2: term) : Tac bool =
true
null
false
let e = cur_env () in unify_guard_env e t1 t2
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "FStar.Tactics.NamedView.term", "FStar.Tactics.V2.Builtins.unify_guard_env", "Prims.bool", "FStar.Reflection.Types.env", "FStar.Tactics.V2.Derived.cur_env" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *) let commute_applied_match () : Tac unit = t_commute_applied_match () (** Similar to [apply_lemma], but will not instantiate uvars in the goal while applying. *) let apply_lemma_noinst (t : term) : Tac unit = t_apply_lemma true false t let apply_lemma_rw (t : term) : Tac unit = t_apply_lemma false true t (** [apply_raw f] is like [apply], but will ask for all arguments regardless of whether they appear free in further goals. See the explanation in [t_apply]. *) let apply_raw (t : term) : Tac unit = t_apply false false false t (** Like [exact], but allows for the term [e] to have a type [t] only under some guard [g], adding the guard as a goal. *) let exact_guard (t : term) : Tac unit = with_policy Goal (fun () -> t_exact true false t) (** (TODO: explain better) When running [pointwise tau] For every subterm [t'] of the goal's type [t], the engine will build a goal [Gamma |= t' == ?u] and run [tau] on it. When the tactic proves the goal, the engine will rewrite [t'] for [?u] in the original goal type. This is done for every subterm, bottom-up. This allows to recurse over an unknown goal type. By inspecting the goal, the [tau] can then decide what to do (to not do anything, use [trefl]). *) let t_pointwise (d:direction) (tau : unit -> Tac unit) : Tac unit = let ctrl (t:term) : Tac (bool & ctrl_flag) = true, Continue in let rw () : Tac unit = tau () in ctrl_rewrite d ctrl rw (** [topdown_rewrite ctrl rw] is used to rewrite those sub-terms [t] of the goal on which [fst (ctrl t)] returns true. On each such sub-term, [rw] is presented with an equality of goal of the form [Gamma |= t == ?u]. When [rw] proves the goal, the engine will rewrite [t] for [?u] in the original goal type. The goal formula is traversed top-down and the traversal can be controlled by [snd (ctrl t)]: When [snd (ctrl t) = 0], the traversal continues down through the position in the goal term. When [snd (ctrl t) = 1], the traversal continues to the next sub-tree of the goal. When [snd (ctrl t) = 2], no more rewrites are performed in the goal. *) let topdown_rewrite (ctrl : term -> Tac (bool * int)) (rw:unit -> Tac unit) : Tac unit = let ctrl' (t:term) : Tac (bool & ctrl_flag) = let b, i = ctrl t in let f = match i with | 0 -> Continue | 1 -> Skip | 2 -> Abort | _ -> fail "topdown_rewrite: bad value from ctrl" in b, f in ctrl_rewrite TopDown ctrl' rw let pointwise (tau : unit -> Tac unit) : Tac unit = t_pointwise BottomUp tau let pointwise' (tau : unit -> Tac unit) : Tac unit = t_pointwise TopDown tau let cur_module () : Tac name = moduleof (top_env ()) let open_modules () : Tac (list name) = env_open_modules (top_env ()) let fresh_uvar (o : option typ) : Tac term = let e = cur_env () in uvar_env e o let unify (t1 t2 : term) : Tac bool = let e = cur_env () in unify_env e t1 t2
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val unify_guard (t1 t2: term) : Tac bool
[]
FStar.Tactics.V2.Derived.unify_guard
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t1: FStar.Tactics.NamedView.term -> t2: FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac Prims.bool
{ "end_col": 27, "end_line": 295, "start_col": 43, "start_line": 293 }
FStar.Tactics.Effect.Tac
val simpl: Prims.unit -> Tac unit
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let simpl () : Tac unit = norm [simplify; primops]
val simpl: Prims.unit -> Tac unit let simpl () : Tac unit =
true
null
false
norm [simplify; primops]
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "Prims.unit", "FStar.Tactics.V2.Builtins.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.simplify", "FStar.Pervasives.primops", "Prims.Nil" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *) let commute_applied_match () : Tac unit = t_commute_applied_match () (** Similar to [apply_lemma], but will not instantiate uvars in the goal while applying. *) let apply_lemma_noinst (t : term) : Tac unit = t_apply_lemma true false t let apply_lemma_rw (t : term) : Tac unit = t_apply_lemma false true t (** [apply_raw f] is like [apply], but will ask for all arguments regardless of whether they appear free in further goals. See the explanation in [t_apply]. *) let apply_raw (t : term) : Tac unit = t_apply false false false t (** Like [exact], but allows for the term [e] to have a type [t] only under some guard [g], adding the guard as a goal. *) let exact_guard (t : term) : Tac unit = with_policy Goal (fun () -> t_exact true false t) (** (TODO: explain better) When running [pointwise tau] For every subterm [t'] of the goal's type [t], the engine will build a goal [Gamma |= t' == ?u] and run [tau] on it. When the tactic proves the goal, the engine will rewrite [t'] for [?u] in the original goal type. This is done for every subterm, bottom-up. This allows to recurse over an unknown goal type. By inspecting the goal, the [tau] can then decide what to do (to not do anything, use [trefl]). *) let t_pointwise (d:direction) (tau : unit -> Tac unit) : Tac unit = let ctrl (t:term) : Tac (bool & ctrl_flag) = true, Continue in let rw () : Tac unit = tau () in ctrl_rewrite d ctrl rw (** [topdown_rewrite ctrl rw] is used to rewrite those sub-terms [t] of the goal on which [fst (ctrl t)] returns true. On each such sub-term, [rw] is presented with an equality of goal of the form [Gamma |= t == ?u]. When [rw] proves the goal, the engine will rewrite [t] for [?u] in the original goal type. The goal formula is traversed top-down and the traversal can be controlled by [snd (ctrl t)]: When [snd (ctrl t) = 0], the traversal continues down through the position in the goal term. When [snd (ctrl t) = 1], the traversal continues to the next sub-tree of the goal. When [snd (ctrl t) = 2], no more rewrites are performed in the goal. *) let topdown_rewrite (ctrl : term -> Tac (bool * int)) (rw:unit -> Tac unit) : Tac unit = let ctrl' (t:term) : Tac (bool & ctrl_flag) = let b, i = ctrl t in let f = match i with | 0 -> Continue | 1 -> Skip | 2 -> Abort | _ -> fail "topdown_rewrite: bad value from ctrl" in b, f in ctrl_rewrite TopDown ctrl' rw let pointwise (tau : unit -> Tac unit) : Tac unit = t_pointwise BottomUp tau let pointwise' (tau : unit -> Tac unit) : Tac unit = t_pointwise TopDown tau let cur_module () : Tac name = moduleof (top_env ()) let open_modules () : Tac (list name) = env_open_modules (top_env ()) let fresh_uvar (o : option typ) : Tac term = let e = cur_env () in uvar_env e o let unify (t1 t2 : term) : Tac bool = let e = cur_env () in unify_env e t1 t2 let unify_guard (t1 t2 : term) : Tac bool = let e = cur_env () in unify_guard_env e t1 t2 let tmatch (t1 t2 : term) : Tac bool = let e = cur_env () in match_env e t1 t2 (** [divide n t1 t2] will split the current set of goals into the [n] first ones, and the rest. It then runs [t1] on the first set, and [t2] on the second, returning both results (and concatenating remaining goals). *) let divide (n:int) (l : unit -> Tac 'a) (r : unit -> Tac 'b) : Tac ('a * 'b) = if n < 0 then fail "divide: negative n"; let gs, sgs = goals (), smt_goals () in let gs1, gs2 = List.Tot.Base.splitAt n gs in set_goals gs1; set_smt_goals []; let x = l () in let gsl, sgsl = goals (), smt_goals () in set_goals gs2; set_smt_goals []; let y = r () in let gsr, sgsr = goals (), smt_goals () in set_goals (gsl @ gsr); set_smt_goals (sgs @ sgsl @ sgsr); (x, y) let rec iseq (ts : list (unit -> Tac unit)) : Tac unit = match ts with | t::ts -> let _ = divide 1 t (fun () -> iseq ts) in () | [] -> () (** [focus t] runs [t ()] on the current active goal, hiding all others and restoring them at the end. *) let focus (t : unit -> Tac 'a) : Tac 'a = match goals () with | [] -> fail "focus: no goals" | g::gs -> let sgs = smt_goals () in set_goals [g]; set_smt_goals []; let x = t () in set_goals (goals () @ gs); set_smt_goals (smt_goals () @ sgs); x (** Similar to [dump], but only dumping the current goal. *) let dump1 (m : string) = focus (fun () -> dump m) let rec mapAll (t : unit -> Tac 'a) : Tac (list 'a) = match goals () with | [] -> [] | _::_ -> let (h, t) = divide 1 t (fun () -> mapAll t) in h::t let rec iterAll (t : unit -> Tac unit) : Tac unit = (* Could use mapAll, but why even build that list *) match goals () with | [] -> () | _::_ -> let _ = divide 1 t (fun () -> iterAll t) in () let iterAllSMT (t : unit -> Tac unit) : Tac unit = let gs, sgs = goals (), smt_goals () in set_goals sgs; set_smt_goals []; iterAll t; let gs', sgs' = goals (), smt_goals () in set_goals gs; set_smt_goals (gs'@sgs') (** Runs tactic [t1] on the current goal, and then tactic [t2] on *each* subgoal produced by [t1]. Each invocation of [t2] runs on a proofstate with a single goal (they're "focused"). *) let seq (f : unit -> Tac unit) (g : unit -> Tac unit) : Tac unit = focus (fun () -> f (); iterAll g) let exact_args (qs : list aqualv) (t : term) : Tac unit = focus (fun () -> let n = List.Tot.Base.length qs in let uvs = repeatn n (fun () -> fresh_uvar None) in let t' = mk_app t (zip uvs qs) in exact t'; iter (fun uv -> if is_uvar uv then unshelve uv else ()) (L.rev uvs) ) let exact_n (n : int) (t : term) : Tac unit = exact_args (repeatn n (fun () -> Q_Explicit)) t (** [ngoals ()] returns the number of goals *) let ngoals () : Tac int = List.Tot.Base.length (goals ()) (** [ngoals_smt ()] returns the number of SMT goals *) let ngoals_smt () : Tac int = List.Tot.Base.length (smt_goals ()) (* sigh GGG fix names!! *) let fresh_namedv_named (s:string) : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal s; sort = seal (pack Tv_Unknown); uniq = n; }) (* Create a fresh bound variable (bv), using a generic name. See also [fresh_namedv_named]. *) let fresh_namedv () : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal ("x" ^ string_of_int n); sort = seal (pack Tv_Unknown); uniq = n; }) let fresh_binder_named (s : string) (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal s; sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_binder (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_implicit_binder (t : typ) : Tac binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Implicit; attrs = [] ; } let guard (b : bool) : TacH unit (requires (fun _ -> True)) (ensures (fun ps r -> if b then Success? r /\ Success?.ps r == ps else Failed? r)) (* ^ the proofstate on failure is not exactly equal (has the psc set) *) = if not b then fail "guard failed" else () let try_with (f : unit -> Tac 'a) (h : exn -> Tac 'a) : Tac 'a = match catch f with | Inl e -> h e | Inr x -> x let trytac (t : unit -> Tac 'a) : Tac (option 'a) = try Some (t ()) with | _ -> None let or_else (#a:Type) (t1 : unit -> Tac a) (t2 : unit -> Tac a) : Tac a = try t1 () with | _ -> t2 () val (<|>) : (unit -> Tac 'a) -> (unit -> Tac 'a) -> (unit -> Tac 'a) let (<|>) t1 t2 = fun () -> or_else t1 t2 let first (ts : list (unit -> Tac 'a)) : Tac 'a = L.fold_right (<|>) ts (fun () -> fail "no tactics to try") () let rec repeat (#a:Type) (t : unit -> Tac a) : Tac (list a) = match catch t with | Inl _ -> [] | Inr x -> x :: repeat t let repeat1 (#a:Type) (t : unit -> Tac a) : Tac (list a) = t () :: repeat t let repeat' (f : unit -> Tac 'a) : Tac unit = let _ = repeat f in () let norm_term (s : list norm_step) (t : term) : Tac term = let e = try cur_env () with | _ -> top_env () in norm_term_env e s t (** Join all of the SMT goals into one. This helps when all of them are expected to be similar, and therefore easier to prove at once by the SMT solver. TODO: would be nice to try to join them in a more meaningful way, as the order can matter. *) let join_all_smt_goals () = let gs, sgs = goals (), smt_goals () in set_smt_goals []; set_goals sgs; repeat' join; let sgs' = goals () in // should be a single one set_goals gs; set_smt_goals sgs' let discard (tau : unit -> Tac 'a) : unit -> Tac unit = fun () -> let _ = tau () in () // TODO: do we want some value out of this? let rec repeatseq (#a:Type) (t : unit -> Tac a) : Tac unit = let _ = trytac (fun () -> (discard t) `seq` (discard (fun () -> repeatseq t))) in () let tadmit () = tadmit_t (`()) let admit1 () : Tac unit = tadmit () let admit_all () : Tac unit = let _ = repeat tadmit in () (** [is_guard] returns whether the current goal arose from a typechecking guard *) let is_guard () : Tac bool = Tactics.Types.is_guard (_cur_goal ()) let skip_guard () : Tac unit = if is_guard () then smt () else fail "" let guards_to_smt () : Tac unit = let _ = repeat skip_guard in ()
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val simpl: Prims.unit -> Tac unit
[]
FStar.Tactics.V2.Derived.simpl
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 52, "end_line": 528, "start_col": 28, "start_line": 528 }
FStar.Tactics.Effect.Tac
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let tadmit () = tadmit_t (`())
let tadmit () =
true
null
false
tadmit_t (`())
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "Prims.unit", "FStar.Tactics.V2.Builtins.tadmit_t" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *) let commute_applied_match () : Tac unit = t_commute_applied_match () (** Similar to [apply_lemma], but will not instantiate uvars in the goal while applying. *) let apply_lemma_noinst (t : term) : Tac unit = t_apply_lemma true false t let apply_lemma_rw (t : term) : Tac unit = t_apply_lemma false true t (** [apply_raw f] is like [apply], but will ask for all arguments regardless of whether they appear free in further goals. See the explanation in [t_apply]. *) let apply_raw (t : term) : Tac unit = t_apply false false false t (** Like [exact], but allows for the term [e] to have a type [t] only under some guard [g], adding the guard as a goal. *) let exact_guard (t : term) : Tac unit = with_policy Goal (fun () -> t_exact true false t) (** (TODO: explain better) When running [pointwise tau] For every subterm [t'] of the goal's type [t], the engine will build a goal [Gamma |= t' == ?u] and run [tau] on it. When the tactic proves the goal, the engine will rewrite [t'] for [?u] in the original goal type. This is done for every subterm, bottom-up. This allows to recurse over an unknown goal type. By inspecting the goal, the [tau] can then decide what to do (to not do anything, use [trefl]). *) let t_pointwise (d:direction) (tau : unit -> Tac unit) : Tac unit = let ctrl (t:term) : Tac (bool & ctrl_flag) = true, Continue in let rw () : Tac unit = tau () in ctrl_rewrite d ctrl rw (** [topdown_rewrite ctrl rw] is used to rewrite those sub-terms [t] of the goal on which [fst (ctrl t)] returns true. On each such sub-term, [rw] is presented with an equality of goal of the form [Gamma |= t == ?u]. When [rw] proves the goal, the engine will rewrite [t] for [?u] in the original goal type. The goal formula is traversed top-down and the traversal can be controlled by [snd (ctrl t)]: When [snd (ctrl t) = 0], the traversal continues down through the position in the goal term. When [snd (ctrl t) = 1], the traversal continues to the next sub-tree of the goal. When [snd (ctrl t) = 2], no more rewrites are performed in the goal. *) let topdown_rewrite (ctrl : term -> Tac (bool * int)) (rw:unit -> Tac unit) : Tac unit = let ctrl' (t:term) : Tac (bool & ctrl_flag) = let b, i = ctrl t in let f = match i with | 0 -> Continue | 1 -> Skip | 2 -> Abort | _ -> fail "topdown_rewrite: bad value from ctrl" in b, f in ctrl_rewrite TopDown ctrl' rw let pointwise (tau : unit -> Tac unit) : Tac unit = t_pointwise BottomUp tau let pointwise' (tau : unit -> Tac unit) : Tac unit = t_pointwise TopDown tau let cur_module () : Tac name = moduleof (top_env ()) let open_modules () : Tac (list name) = env_open_modules (top_env ()) let fresh_uvar (o : option typ) : Tac term = let e = cur_env () in uvar_env e o let unify (t1 t2 : term) : Tac bool = let e = cur_env () in unify_env e t1 t2 let unify_guard (t1 t2 : term) : Tac bool = let e = cur_env () in unify_guard_env e t1 t2 let tmatch (t1 t2 : term) : Tac bool = let e = cur_env () in match_env e t1 t2 (** [divide n t1 t2] will split the current set of goals into the [n] first ones, and the rest. It then runs [t1] on the first set, and [t2] on the second, returning both results (and concatenating remaining goals). *) let divide (n:int) (l : unit -> Tac 'a) (r : unit -> Tac 'b) : Tac ('a * 'b) = if n < 0 then fail "divide: negative n"; let gs, sgs = goals (), smt_goals () in let gs1, gs2 = List.Tot.Base.splitAt n gs in set_goals gs1; set_smt_goals []; let x = l () in let gsl, sgsl = goals (), smt_goals () in set_goals gs2; set_smt_goals []; let y = r () in let gsr, sgsr = goals (), smt_goals () in set_goals (gsl @ gsr); set_smt_goals (sgs @ sgsl @ sgsr); (x, y) let rec iseq (ts : list (unit -> Tac unit)) : Tac unit = match ts with | t::ts -> let _ = divide 1 t (fun () -> iseq ts) in () | [] -> () (** [focus t] runs [t ()] on the current active goal, hiding all others and restoring them at the end. *) let focus (t : unit -> Tac 'a) : Tac 'a = match goals () with | [] -> fail "focus: no goals" | g::gs -> let sgs = smt_goals () in set_goals [g]; set_smt_goals []; let x = t () in set_goals (goals () @ gs); set_smt_goals (smt_goals () @ sgs); x (** Similar to [dump], but only dumping the current goal. *) let dump1 (m : string) = focus (fun () -> dump m) let rec mapAll (t : unit -> Tac 'a) : Tac (list 'a) = match goals () with | [] -> [] | _::_ -> let (h, t) = divide 1 t (fun () -> mapAll t) in h::t let rec iterAll (t : unit -> Tac unit) : Tac unit = (* Could use mapAll, but why even build that list *) match goals () with | [] -> () | _::_ -> let _ = divide 1 t (fun () -> iterAll t) in () let iterAllSMT (t : unit -> Tac unit) : Tac unit = let gs, sgs = goals (), smt_goals () in set_goals sgs; set_smt_goals []; iterAll t; let gs', sgs' = goals (), smt_goals () in set_goals gs; set_smt_goals (gs'@sgs') (** Runs tactic [t1] on the current goal, and then tactic [t2] on *each* subgoal produced by [t1]. Each invocation of [t2] runs on a proofstate with a single goal (they're "focused"). *) let seq (f : unit -> Tac unit) (g : unit -> Tac unit) : Tac unit = focus (fun () -> f (); iterAll g) let exact_args (qs : list aqualv) (t : term) : Tac unit = focus (fun () -> let n = List.Tot.Base.length qs in let uvs = repeatn n (fun () -> fresh_uvar None) in let t' = mk_app t (zip uvs qs) in exact t'; iter (fun uv -> if is_uvar uv then unshelve uv else ()) (L.rev uvs) ) let exact_n (n : int) (t : term) : Tac unit = exact_args (repeatn n (fun () -> Q_Explicit)) t (** [ngoals ()] returns the number of goals *) let ngoals () : Tac int = List.Tot.Base.length (goals ()) (** [ngoals_smt ()] returns the number of SMT goals *) let ngoals_smt () : Tac int = List.Tot.Base.length (smt_goals ()) (* sigh GGG fix names!! *) let fresh_namedv_named (s:string) : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal s; sort = seal (pack Tv_Unknown); uniq = n; }) (* Create a fresh bound variable (bv), using a generic name. See also [fresh_namedv_named]. *) let fresh_namedv () : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal ("x" ^ string_of_int n); sort = seal (pack Tv_Unknown); uniq = n; }) let fresh_binder_named (s : string) (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal s; sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_binder (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_implicit_binder (t : typ) : Tac binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Implicit; attrs = [] ; } let guard (b : bool) : TacH unit (requires (fun _ -> True)) (ensures (fun ps r -> if b then Success? r /\ Success?.ps r == ps else Failed? r)) (* ^ the proofstate on failure is not exactly equal (has the psc set) *) = if not b then fail "guard failed" else () let try_with (f : unit -> Tac 'a) (h : exn -> Tac 'a) : Tac 'a = match catch f with | Inl e -> h e | Inr x -> x let trytac (t : unit -> Tac 'a) : Tac (option 'a) = try Some (t ()) with | _ -> None let or_else (#a:Type) (t1 : unit -> Tac a) (t2 : unit -> Tac a) : Tac a = try t1 () with | _ -> t2 () val (<|>) : (unit -> Tac 'a) -> (unit -> Tac 'a) -> (unit -> Tac 'a) let (<|>) t1 t2 = fun () -> or_else t1 t2 let first (ts : list (unit -> Tac 'a)) : Tac 'a = L.fold_right (<|>) ts (fun () -> fail "no tactics to try") () let rec repeat (#a:Type) (t : unit -> Tac a) : Tac (list a) = match catch t with | Inl _ -> [] | Inr x -> x :: repeat t let repeat1 (#a:Type) (t : unit -> Tac a) : Tac (list a) = t () :: repeat t let repeat' (f : unit -> Tac 'a) : Tac unit = let _ = repeat f in () let norm_term (s : list norm_step) (t : term) : Tac term = let e = try cur_env () with | _ -> top_env () in norm_term_env e s t (** Join all of the SMT goals into one. This helps when all of them are expected to be similar, and therefore easier to prove at once by the SMT solver. TODO: would be nice to try to join them in a more meaningful way, as the order can matter. *) let join_all_smt_goals () = let gs, sgs = goals (), smt_goals () in set_smt_goals []; set_goals sgs; repeat' join; let sgs' = goals () in // should be a single one set_goals gs; set_smt_goals sgs' let discard (tau : unit -> Tac 'a) : unit -> Tac unit = fun () -> let _ = tau () in () // TODO: do we want some value out of this? let rec repeatseq (#a:Type) (t : unit -> Tac a) : Tac unit = let _ = trytac (fun () -> (discard t) `seq` (discard (fun () -> repeatseq t))) in ()
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val tadmit : _: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
[]
FStar.Tactics.V2.Derived.tadmit
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 30, "end_line": 506, "start_col": 16, "start_line": 506 }
FStar.Tactics.Effect.Tac
val ngoals_smt: Prims.unit -> Tac int
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ngoals_smt () : Tac int = List.Tot.Base.length (smt_goals ())
val ngoals_smt: Prims.unit -> Tac int let ngoals_smt () : Tac int =
true
null
false
List.Tot.Base.length (smt_goals ())
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "Prims.unit", "FStar.List.Tot.Base.length", "FStar.Tactics.Types.goal", "Prims.int", "Prims.list", "FStar.Tactics.V2.Derived.smt_goals" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *) let commute_applied_match () : Tac unit = t_commute_applied_match () (** Similar to [apply_lemma], but will not instantiate uvars in the goal while applying. *) let apply_lemma_noinst (t : term) : Tac unit = t_apply_lemma true false t let apply_lemma_rw (t : term) : Tac unit = t_apply_lemma false true t (** [apply_raw f] is like [apply], but will ask for all arguments regardless of whether they appear free in further goals. See the explanation in [t_apply]. *) let apply_raw (t : term) : Tac unit = t_apply false false false t (** Like [exact], but allows for the term [e] to have a type [t] only under some guard [g], adding the guard as a goal. *) let exact_guard (t : term) : Tac unit = with_policy Goal (fun () -> t_exact true false t) (** (TODO: explain better) When running [pointwise tau] For every subterm [t'] of the goal's type [t], the engine will build a goal [Gamma |= t' == ?u] and run [tau] on it. When the tactic proves the goal, the engine will rewrite [t'] for [?u] in the original goal type. This is done for every subterm, bottom-up. This allows to recurse over an unknown goal type. By inspecting the goal, the [tau] can then decide what to do (to not do anything, use [trefl]). *) let t_pointwise (d:direction) (tau : unit -> Tac unit) : Tac unit = let ctrl (t:term) : Tac (bool & ctrl_flag) = true, Continue in let rw () : Tac unit = tau () in ctrl_rewrite d ctrl rw (** [topdown_rewrite ctrl rw] is used to rewrite those sub-terms [t] of the goal on which [fst (ctrl t)] returns true. On each such sub-term, [rw] is presented with an equality of goal of the form [Gamma |= t == ?u]. When [rw] proves the goal, the engine will rewrite [t] for [?u] in the original goal type. The goal formula is traversed top-down and the traversal can be controlled by [snd (ctrl t)]: When [snd (ctrl t) = 0], the traversal continues down through the position in the goal term. When [snd (ctrl t) = 1], the traversal continues to the next sub-tree of the goal. When [snd (ctrl t) = 2], no more rewrites are performed in the goal. *) let topdown_rewrite (ctrl : term -> Tac (bool * int)) (rw:unit -> Tac unit) : Tac unit = let ctrl' (t:term) : Tac (bool & ctrl_flag) = let b, i = ctrl t in let f = match i with | 0 -> Continue | 1 -> Skip | 2 -> Abort | _ -> fail "topdown_rewrite: bad value from ctrl" in b, f in ctrl_rewrite TopDown ctrl' rw let pointwise (tau : unit -> Tac unit) : Tac unit = t_pointwise BottomUp tau let pointwise' (tau : unit -> Tac unit) : Tac unit = t_pointwise TopDown tau let cur_module () : Tac name = moduleof (top_env ()) let open_modules () : Tac (list name) = env_open_modules (top_env ()) let fresh_uvar (o : option typ) : Tac term = let e = cur_env () in uvar_env e o let unify (t1 t2 : term) : Tac bool = let e = cur_env () in unify_env e t1 t2 let unify_guard (t1 t2 : term) : Tac bool = let e = cur_env () in unify_guard_env e t1 t2 let tmatch (t1 t2 : term) : Tac bool = let e = cur_env () in match_env e t1 t2 (** [divide n t1 t2] will split the current set of goals into the [n] first ones, and the rest. It then runs [t1] on the first set, and [t2] on the second, returning both results (and concatenating remaining goals). *) let divide (n:int) (l : unit -> Tac 'a) (r : unit -> Tac 'b) : Tac ('a * 'b) = if n < 0 then fail "divide: negative n"; let gs, sgs = goals (), smt_goals () in let gs1, gs2 = List.Tot.Base.splitAt n gs in set_goals gs1; set_smt_goals []; let x = l () in let gsl, sgsl = goals (), smt_goals () in set_goals gs2; set_smt_goals []; let y = r () in let gsr, sgsr = goals (), smt_goals () in set_goals (gsl @ gsr); set_smt_goals (sgs @ sgsl @ sgsr); (x, y) let rec iseq (ts : list (unit -> Tac unit)) : Tac unit = match ts with | t::ts -> let _ = divide 1 t (fun () -> iseq ts) in () | [] -> () (** [focus t] runs [t ()] on the current active goal, hiding all others and restoring them at the end. *) let focus (t : unit -> Tac 'a) : Tac 'a = match goals () with | [] -> fail "focus: no goals" | g::gs -> let sgs = smt_goals () in set_goals [g]; set_smt_goals []; let x = t () in set_goals (goals () @ gs); set_smt_goals (smt_goals () @ sgs); x (** Similar to [dump], but only dumping the current goal. *) let dump1 (m : string) = focus (fun () -> dump m) let rec mapAll (t : unit -> Tac 'a) : Tac (list 'a) = match goals () with | [] -> [] | _::_ -> let (h, t) = divide 1 t (fun () -> mapAll t) in h::t let rec iterAll (t : unit -> Tac unit) : Tac unit = (* Could use mapAll, but why even build that list *) match goals () with | [] -> () | _::_ -> let _ = divide 1 t (fun () -> iterAll t) in () let iterAllSMT (t : unit -> Tac unit) : Tac unit = let gs, sgs = goals (), smt_goals () in set_goals sgs; set_smt_goals []; iterAll t; let gs', sgs' = goals (), smt_goals () in set_goals gs; set_smt_goals (gs'@sgs') (** Runs tactic [t1] on the current goal, and then tactic [t2] on *each* subgoal produced by [t1]. Each invocation of [t2] runs on a proofstate with a single goal (they're "focused"). *) let seq (f : unit -> Tac unit) (g : unit -> Tac unit) : Tac unit = focus (fun () -> f (); iterAll g) let exact_args (qs : list aqualv) (t : term) : Tac unit = focus (fun () -> let n = List.Tot.Base.length qs in let uvs = repeatn n (fun () -> fresh_uvar None) in let t' = mk_app t (zip uvs qs) in exact t'; iter (fun uv -> if is_uvar uv then unshelve uv else ()) (L.rev uvs) ) let exact_n (n : int) (t : term) : Tac unit = exact_args (repeatn n (fun () -> Q_Explicit)) t (** [ngoals ()] returns the number of goals *) let ngoals () : Tac int = List.Tot.Base.length (goals ())
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ngoals_smt: Prims.unit -> Tac int
[]
FStar.Tactics.V2.Derived.ngoals_smt
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.int
{ "end_col": 65, "end_line": 385, "start_col": 30, "start_line": 385 }
FStar.Tactics.Effect.Tac
val repeatseq (#a: Type) (t: (unit -> Tac a)) : Tac unit
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec repeatseq (#a:Type) (t : unit -> Tac a) : Tac unit = let _ = trytac (fun () -> (discard t) `seq` (discard (fun () -> repeatseq t))) in ()
val repeatseq (#a: Type) (t: (unit -> Tac a)) : Tac unit let rec repeatseq (#a: Type) (t: (unit -> Tac a)) : Tac unit =
true
null
false
let _ = trytac (fun () -> (discard t) `seq` (discard (fun () -> repeatseq t))) in ()
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "Prims.unit", "FStar.Pervasives.Native.option", "FStar.Tactics.V2.Derived.trytac", "FStar.Tactics.V2.Derived.seq", "FStar.Tactics.V2.Derived.discard", "FStar.Tactics.V2.Derived.repeatseq" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *) let commute_applied_match () : Tac unit = t_commute_applied_match () (** Similar to [apply_lemma], but will not instantiate uvars in the goal while applying. *) let apply_lemma_noinst (t : term) : Tac unit = t_apply_lemma true false t let apply_lemma_rw (t : term) : Tac unit = t_apply_lemma false true t (** [apply_raw f] is like [apply], but will ask for all arguments regardless of whether they appear free in further goals. See the explanation in [t_apply]. *) let apply_raw (t : term) : Tac unit = t_apply false false false t (** Like [exact], but allows for the term [e] to have a type [t] only under some guard [g], adding the guard as a goal. *) let exact_guard (t : term) : Tac unit = with_policy Goal (fun () -> t_exact true false t) (** (TODO: explain better) When running [pointwise tau] For every subterm [t'] of the goal's type [t], the engine will build a goal [Gamma |= t' == ?u] and run [tau] on it. When the tactic proves the goal, the engine will rewrite [t'] for [?u] in the original goal type. This is done for every subterm, bottom-up. This allows to recurse over an unknown goal type. By inspecting the goal, the [tau] can then decide what to do (to not do anything, use [trefl]). *) let t_pointwise (d:direction) (tau : unit -> Tac unit) : Tac unit = let ctrl (t:term) : Tac (bool & ctrl_flag) = true, Continue in let rw () : Tac unit = tau () in ctrl_rewrite d ctrl rw (** [topdown_rewrite ctrl rw] is used to rewrite those sub-terms [t] of the goal on which [fst (ctrl t)] returns true. On each such sub-term, [rw] is presented with an equality of goal of the form [Gamma |= t == ?u]. When [rw] proves the goal, the engine will rewrite [t] for [?u] in the original goal type. The goal formula is traversed top-down and the traversal can be controlled by [snd (ctrl t)]: When [snd (ctrl t) = 0], the traversal continues down through the position in the goal term. When [snd (ctrl t) = 1], the traversal continues to the next sub-tree of the goal. When [snd (ctrl t) = 2], no more rewrites are performed in the goal. *) let topdown_rewrite (ctrl : term -> Tac (bool * int)) (rw:unit -> Tac unit) : Tac unit = let ctrl' (t:term) : Tac (bool & ctrl_flag) = let b, i = ctrl t in let f = match i with | 0 -> Continue | 1 -> Skip | 2 -> Abort | _ -> fail "topdown_rewrite: bad value from ctrl" in b, f in ctrl_rewrite TopDown ctrl' rw let pointwise (tau : unit -> Tac unit) : Tac unit = t_pointwise BottomUp tau let pointwise' (tau : unit -> Tac unit) : Tac unit = t_pointwise TopDown tau let cur_module () : Tac name = moduleof (top_env ()) let open_modules () : Tac (list name) = env_open_modules (top_env ()) let fresh_uvar (o : option typ) : Tac term = let e = cur_env () in uvar_env e o let unify (t1 t2 : term) : Tac bool = let e = cur_env () in unify_env e t1 t2 let unify_guard (t1 t2 : term) : Tac bool = let e = cur_env () in unify_guard_env e t1 t2 let tmatch (t1 t2 : term) : Tac bool = let e = cur_env () in match_env e t1 t2 (** [divide n t1 t2] will split the current set of goals into the [n] first ones, and the rest. It then runs [t1] on the first set, and [t2] on the second, returning both results (and concatenating remaining goals). *) let divide (n:int) (l : unit -> Tac 'a) (r : unit -> Tac 'b) : Tac ('a * 'b) = if n < 0 then fail "divide: negative n"; let gs, sgs = goals (), smt_goals () in let gs1, gs2 = List.Tot.Base.splitAt n gs in set_goals gs1; set_smt_goals []; let x = l () in let gsl, sgsl = goals (), smt_goals () in set_goals gs2; set_smt_goals []; let y = r () in let gsr, sgsr = goals (), smt_goals () in set_goals (gsl @ gsr); set_smt_goals (sgs @ sgsl @ sgsr); (x, y) let rec iseq (ts : list (unit -> Tac unit)) : Tac unit = match ts with | t::ts -> let _ = divide 1 t (fun () -> iseq ts) in () | [] -> () (** [focus t] runs [t ()] on the current active goal, hiding all others and restoring them at the end. *) let focus (t : unit -> Tac 'a) : Tac 'a = match goals () with | [] -> fail "focus: no goals" | g::gs -> let sgs = smt_goals () in set_goals [g]; set_smt_goals []; let x = t () in set_goals (goals () @ gs); set_smt_goals (smt_goals () @ sgs); x (** Similar to [dump], but only dumping the current goal. *) let dump1 (m : string) = focus (fun () -> dump m) let rec mapAll (t : unit -> Tac 'a) : Tac (list 'a) = match goals () with | [] -> [] | _::_ -> let (h, t) = divide 1 t (fun () -> mapAll t) in h::t let rec iterAll (t : unit -> Tac unit) : Tac unit = (* Could use mapAll, but why even build that list *) match goals () with | [] -> () | _::_ -> let _ = divide 1 t (fun () -> iterAll t) in () let iterAllSMT (t : unit -> Tac unit) : Tac unit = let gs, sgs = goals (), smt_goals () in set_goals sgs; set_smt_goals []; iterAll t; let gs', sgs' = goals (), smt_goals () in set_goals gs; set_smt_goals (gs'@sgs') (** Runs tactic [t1] on the current goal, and then tactic [t2] on *each* subgoal produced by [t1]. Each invocation of [t2] runs on a proofstate with a single goal (they're "focused"). *) let seq (f : unit -> Tac unit) (g : unit -> Tac unit) : Tac unit = focus (fun () -> f (); iterAll g) let exact_args (qs : list aqualv) (t : term) : Tac unit = focus (fun () -> let n = List.Tot.Base.length qs in let uvs = repeatn n (fun () -> fresh_uvar None) in let t' = mk_app t (zip uvs qs) in exact t'; iter (fun uv -> if is_uvar uv then unshelve uv else ()) (L.rev uvs) ) let exact_n (n : int) (t : term) : Tac unit = exact_args (repeatn n (fun () -> Q_Explicit)) t (** [ngoals ()] returns the number of goals *) let ngoals () : Tac int = List.Tot.Base.length (goals ()) (** [ngoals_smt ()] returns the number of SMT goals *) let ngoals_smt () : Tac int = List.Tot.Base.length (smt_goals ()) (* sigh GGG fix names!! *) let fresh_namedv_named (s:string) : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal s; sort = seal (pack Tv_Unknown); uniq = n; }) (* Create a fresh bound variable (bv), using a generic name. See also [fresh_namedv_named]. *) let fresh_namedv () : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal ("x" ^ string_of_int n); sort = seal (pack Tv_Unknown); uniq = n; }) let fresh_binder_named (s : string) (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal s; sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_binder (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_implicit_binder (t : typ) : Tac binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Implicit; attrs = [] ; } let guard (b : bool) : TacH unit (requires (fun _ -> True)) (ensures (fun ps r -> if b then Success? r /\ Success?.ps r == ps else Failed? r)) (* ^ the proofstate on failure is not exactly equal (has the psc set) *) = if not b then fail "guard failed" else () let try_with (f : unit -> Tac 'a) (h : exn -> Tac 'a) : Tac 'a = match catch f with | Inl e -> h e | Inr x -> x let trytac (t : unit -> Tac 'a) : Tac (option 'a) = try Some (t ()) with | _ -> None let or_else (#a:Type) (t1 : unit -> Tac a) (t2 : unit -> Tac a) : Tac a = try t1 () with | _ -> t2 () val (<|>) : (unit -> Tac 'a) -> (unit -> Tac 'a) -> (unit -> Tac 'a) let (<|>) t1 t2 = fun () -> or_else t1 t2 let first (ts : list (unit -> Tac 'a)) : Tac 'a = L.fold_right (<|>) ts (fun () -> fail "no tactics to try") () let rec repeat (#a:Type) (t : unit -> Tac a) : Tac (list a) = match catch t with | Inl _ -> [] | Inr x -> x :: repeat t let repeat1 (#a:Type) (t : unit -> Tac a) : Tac (list a) = t () :: repeat t let repeat' (f : unit -> Tac 'a) : Tac unit = let _ = repeat f in () let norm_term (s : list norm_step) (t : term) : Tac term = let e = try cur_env () with | _ -> top_env () in norm_term_env e s t (** Join all of the SMT goals into one. This helps when all of them are expected to be similar, and therefore easier to prove at once by the SMT solver. TODO: would be nice to try to join them in a more meaningful way, as the order can matter. *) let join_all_smt_goals () = let gs, sgs = goals (), smt_goals () in set_smt_goals []; set_goals sgs; repeat' join; let sgs' = goals () in // should be a single one set_goals gs; set_smt_goals sgs' let discard (tau : unit -> Tac 'a) : unit -> Tac unit = fun () -> let _ = tau () in ()
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val repeatseq (#a: Type) (t: (unit -> Tac a)) : Tac unit
[ "recursion" ]
FStar.Tactics.V2.Derived.repeatseq
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t: (_: Prims.unit -> FStar.Tactics.Effect.Tac a) -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 88, "end_line": 504, "start_col": 60, "start_line": 503 }
FStar.Tactics.Effect.Tac
val assumption: Prims.unit -> Tac unit
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let assumption () : Tac unit = __assumption_aux (cur_vars ())
val assumption: Prims.unit -> Tac unit let assumption () : Tac unit =
true
null
false
__assumption_aux (cur_vars ())
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "Prims.unit", "FStar.Tactics.V2.Derived.__assumption_aux", "Prims.list", "FStar.Tactics.NamedView.binding", "FStar.Tactics.V2.Derived.cur_vars" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *) let commute_applied_match () : Tac unit = t_commute_applied_match () (** Similar to [apply_lemma], but will not instantiate uvars in the goal while applying. *) let apply_lemma_noinst (t : term) : Tac unit = t_apply_lemma true false t let apply_lemma_rw (t : term) : Tac unit = t_apply_lemma false true t (** [apply_raw f] is like [apply], but will ask for all arguments regardless of whether they appear free in further goals. See the explanation in [t_apply]. *) let apply_raw (t : term) : Tac unit = t_apply false false false t (** Like [exact], but allows for the term [e] to have a type [t] only under some guard [g], adding the guard as a goal. *) let exact_guard (t : term) : Tac unit = with_policy Goal (fun () -> t_exact true false t) (** (TODO: explain better) When running [pointwise tau] For every subterm [t'] of the goal's type [t], the engine will build a goal [Gamma |= t' == ?u] and run [tau] on it. When the tactic proves the goal, the engine will rewrite [t'] for [?u] in the original goal type. This is done for every subterm, bottom-up. This allows to recurse over an unknown goal type. By inspecting the goal, the [tau] can then decide what to do (to not do anything, use [trefl]). *) let t_pointwise (d:direction) (tau : unit -> Tac unit) : Tac unit = let ctrl (t:term) : Tac (bool & ctrl_flag) = true, Continue in let rw () : Tac unit = tau () in ctrl_rewrite d ctrl rw (** [topdown_rewrite ctrl rw] is used to rewrite those sub-terms [t] of the goal on which [fst (ctrl t)] returns true. On each such sub-term, [rw] is presented with an equality of goal of the form [Gamma |= t == ?u]. When [rw] proves the goal, the engine will rewrite [t] for [?u] in the original goal type. The goal formula is traversed top-down and the traversal can be controlled by [snd (ctrl t)]: When [snd (ctrl t) = 0], the traversal continues down through the position in the goal term. When [snd (ctrl t) = 1], the traversal continues to the next sub-tree of the goal. When [snd (ctrl t) = 2], no more rewrites are performed in the goal. *) let topdown_rewrite (ctrl : term -> Tac (bool * int)) (rw:unit -> Tac unit) : Tac unit = let ctrl' (t:term) : Tac (bool & ctrl_flag) = let b, i = ctrl t in let f = match i with | 0 -> Continue | 1 -> Skip | 2 -> Abort | _ -> fail "topdown_rewrite: bad value from ctrl" in b, f in ctrl_rewrite TopDown ctrl' rw let pointwise (tau : unit -> Tac unit) : Tac unit = t_pointwise BottomUp tau let pointwise' (tau : unit -> Tac unit) : Tac unit = t_pointwise TopDown tau let cur_module () : Tac name = moduleof (top_env ()) let open_modules () : Tac (list name) = env_open_modules (top_env ()) let fresh_uvar (o : option typ) : Tac term = let e = cur_env () in uvar_env e o let unify (t1 t2 : term) : Tac bool = let e = cur_env () in unify_env e t1 t2 let unify_guard (t1 t2 : term) : Tac bool = let e = cur_env () in unify_guard_env e t1 t2 let tmatch (t1 t2 : term) : Tac bool = let e = cur_env () in match_env e t1 t2 (** [divide n t1 t2] will split the current set of goals into the [n] first ones, and the rest. It then runs [t1] on the first set, and [t2] on the second, returning both results (and concatenating remaining goals). *) let divide (n:int) (l : unit -> Tac 'a) (r : unit -> Tac 'b) : Tac ('a * 'b) = if n < 0 then fail "divide: negative n"; let gs, sgs = goals (), smt_goals () in let gs1, gs2 = List.Tot.Base.splitAt n gs in set_goals gs1; set_smt_goals []; let x = l () in let gsl, sgsl = goals (), smt_goals () in set_goals gs2; set_smt_goals []; let y = r () in let gsr, sgsr = goals (), smt_goals () in set_goals (gsl @ gsr); set_smt_goals (sgs @ sgsl @ sgsr); (x, y) let rec iseq (ts : list (unit -> Tac unit)) : Tac unit = match ts with | t::ts -> let _ = divide 1 t (fun () -> iseq ts) in () | [] -> () (** [focus t] runs [t ()] on the current active goal, hiding all others and restoring them at the end. *) let focus (t : unit -> Tac 'a) : Tac 'a = match goals () with | [] -> fail "focus: no goals" | g::gs -> let sgs = smt_goals () in set_goals [g]; set_smt_goals []; let x = t () in set_goals (goals () @ gs); set_smt_goals (smt_goals () @ sgs); x (** Similar to [dump], but only dumping the current goal. *) let dump1 (m : string) = focus (fun () -> dump m) let rec mapAll (t : unit -> Tac 'a) : Tac (list 'a) = match goals () with | [] -> [] | _::_ -> let (h, t) = divide 1 t (fun () -> mapAll t) in h::t let rec iterAll (t : unit -> Tac unit) : Tac unit = (* Could use mapAll, but why even build that list *) match goals () with | [] -> () | _::_ -> let _ = divide 1 t (fun () -> iterAll t) in () let iterAllSMT (t : unit -> Tac unit) : Tac unit = let gs, sgs = goals (), smt_goals () in set_goals sgs; set_smt_goals []; iterAll t; let gs', sgs' = goals (), smt_goals () in set_goals gs; set_smt_goals (gs'@sgs') (** Runs tactic [t1] on the current goal, and then tactic [t2] on *each* subgoal produced by [t1]. Each invocation of [t2] runs on a proofstate with a single goal (they're "focused"). *) let seq (f : unit -> Tac unit) (g : unit -> Tac unit) : Tac unit = focus (fun () -> f (); iterAll g) let exact_args (qs : list aqualv) (t : term) : Tac unit = focus (fun () -> let n = List.Tot.Base.length qs in let uvs = repeatn n (fun () -> fresh_uvar None) in let t' = mk_app t (zip uvs qs) in exact t'; iter (fun uv -> if is_uvar uv then unshelve uv else ()) (L.rev uvs) ) let exact_n (n : int) (t : term) : Tac unit = exact_args (repeatn n (fun () -> Q_Explicit)) t (** [ngoals ()] returns the number of goals *) let ngoals () : Tac int = List.Tot.Base.length (goals ()) (** [ngoals_smt ()] returns the number of SMT goals *) let ngoals_smt () : Tac int = List.Tot.Base.length (smt_goals ()) (* sigh GGG fix names!! *) let fresh_namedv_named (s:string) : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal s; sort = seal (pack Tv_Unknown); uniq = n; }) (* Create a fresh bound variable (bv), using a generic name. See also [fresh_namedv_named]. *) let fresh_namedv () : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal ("x" ^ string_of_int n); sort = seal (pack Tv_Unknown); uniq = n; }) let fresh_binder_named (s : string) (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal s; sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_binder (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_implicit_binder (t : typ) : Tac binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Implicit; attrs = [] ; } let guard (b : bool) : TacH unit (requires (fun _ -> True)) (ensures (fun ps r -> if b then Success? r /\ Success?.ps r == ps else Failed? r)) (* ^ the proofstate on failure is not exactly equal (has the psc set) *) = if not b then fail "guard failed" else () let try_with (f : unit -> Tac 'a) (h : exn -> Tac 'a) : Tac 'a = match catch f with | Inl e -> h e | Inr x -> x let trytac (t : unit -> Tac 'a) : Tac (option 'a) = try Some (t ()) with | _ -> None let or_else (#a:Type) (t1 : unit -> Tac a) (t2 : unit -> Tac a) : Tac a = try t1 () with | _ -> t2 () val (<|>) : (unit -> Tac 'a) -> (unit -> Tac 'a) -> (unit -> Tac 'a) let (<|>) t1 t2 = fun () -> or_else t1 t2 let first (ts : list (unit -> Tac 'a)) : Tac 'a = L.fold_right (<|>) ts (fun () -> fail "no tactics to try") () let rec repeat (#a:Type) (t : unit -> Tac a) : Tac (list a) = match catch t with | Inl _ -> [] | Inr x -> x :: repeat t let repeat1 (#a:Type) (t : unit -> Tac a) : Tac (list a) = t () :: repeat t let repeat' (f : unit -> Tac 'a) : Tac unit = let _ = repeat f in () let norm_term (s : list norm_step) (t : term) : Tac term = let e = try cur_env () with | _ -> top_env () in norm_term_env e s t (** Join all of the SMT goals into one. This helps when all of them are expected to be similar, and therefore easier to prove at once by the SMT solver. TODO: would be nice to try to join them in a more meaningful way, as the order can matter. *) let join_all_smt_goals () = let gs, sgs = goals (), smt_goals () in set_smt_goals []; set_goals sgs; repeat' join; let sgs' = goals () in // should be a single one set_goals gs; set_smt_goals sgs' let discard (tau : unit -> Tac 'a) : unit -> Tac unit = fun () -> let _ = tau () in () // TODO: do we want some value out of this? let rec repeatseq (#a:Type) (t : unit -> Tac a) : Tac unit = let _ = trytac (fun () -> (discard t) `seq` (discard (fun () -> repeatseq t))) in () let tadmit () = tadmit_t (`()) let admit1 () : Tac unit = tadmit () let admit_all () : Tac unit = let _ = repeat tadmit in () (** [is_guard] returns whether the current goal arose from a typechecking guard *) let is_guard () : Tac bool = Tactics.Types.is_guard (_cur_goal ()) let skip_guard () : Tac unit = if is_guard () then smt () else fail "" let guards_to_smt () : Tac unit = let _ = repeat skip_guard in () let simpl () : Tac unit = norm [simplify; primops] let whnf () : Tac unit = norm [weak; hnf; primops; delta] let compute () : Tac unit = norm [primops; iota; delta; zeta] let intros () : Tac (list binding) = repeat intro let intros' () : Tac unit = let _ = intros () in () let destruct tm : Tac unit = let _ = t_destruct tm in () let destruct_intros tm : Tac unit = seq (fun () -> let _ = t_destruct tm in ()) intros' private val __cut : (a:Type) -> (b:Type) -> (a -> b) -> a -> b private let __cut a b f x = f x let tcut (t:term) : Tac binding = let g = cur_goal () in let tt = mk_e_app (`__cut) [t; g] in apply tt; intro () let pose (t:term) : Tac binding = apply (`__cut); flip (); exact t; intro () let intro_as (s:string) : Tac binding = let b = intro () in rename_to b s let pose_as (s:string) (t:term) : Tac binding = let b = pose t in rename_to b s let for_each_binding (f : binding -> Tac 'a) : Tac (list 'a) = map f (cur_vars ()) let rec revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> revert (); revert_all tl let binder_sort (b : binder) : Tot typ = b.sort // Cannot define this inside `assumption` due to #1091 private let rec __assumption_aux (xs : list binding) : Tac unit = match xs with | [] -> fail "no assumption matches goal" | b::bs -> try exact b with | _ -> try (apply (`FStar.Squash.return_squash); exact b) with | _ -> __assumption_aux bs
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val assumption: Prims.unit -> Tac unit
[]
FStar.Tactics.V2.Derived.assumption
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 34, "end_line": 585, "start_col": 4, "start_line": 585 }
FStar.Tactics.Effect.Tac
val admit_dump_t: Prims.unit -> Tac unit
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let admit_dump_t () : Tac unit = dump "Admitting"; apply (`admit)
val admit_dump_t: Prims.unit -> Tac unit let admit_dump_t () : Tac unit =
true
null
false
dump "Admitting"; apply (`admit)
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "Prims.unit", "FStar.Tactics.V2.Derived.apply", "FStar.Tactics.V2.Builtins.dump" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *) let commute_applied_match () : Tac unit = t_commute_applied_match () (** Similar to [apply_lemma], but will not instantiate uvars in the goal while applying. *) let apply_lemma_noinst (t : term) : Tac unit = t_apply_lemma true false t let apply_lemma_rw (t : term) : Tac unit = t_apply_lemma false true t (** [apply_raw f] is like [apply], but will ask for all arguments regardless of whether they appear free in further goals. See the explanation in [t_apply]. *) let apply_raw (t : term) : Tac unit = t_apply false false false t (** Like [exact], but allows for the term [e] to have a type [t] only under some guard [g], adding the guard as a goal. *) let exact_guard (t : term) : Tac unit = with_policy Goal (fun () -> t_exact true false t) (** (TODO: explain better) When running [pointwise tau] For every subterm [t'] of the goal's type [t], the engine will build a goal [Gamma |= t' == ?u] and run [tau] on it. When the tactic proves the goal, the engine will rewrite [t'] for [?u] in the original goal type. This is done for every subterm, bottom-up. This allows to recurse over an unknown goal type. By inspecting the goal, the [tau] can then decide what to do (to not do anything, use [trefl]). *) let t_pointwise (d:direction) (tau : unit -> Tac unit) : Tac unit = let ctrl (t:term) : Tac (bool & ctrl_flag) = true, Continue in let rw () : Tac unit = tau () in ctrl_rewrite d ctrl rw (** [topdown_rewrite ctrl rw] is used to rewrite those sub-terms [t] of the goal on which [fst (ctrl t)] returns true. On each such sub-term, [rw] is presented with an equality of goal of the form [Gamma |= t == ?u]. When [rw] proves the goal, the engine will rewrite [t] for [?u] in the original goal type. The goal formula is traversed top-down and the traversal can be controlled by [snd (ctrl t)]: When [snd (ctrl t) = 0], the traversal continues down through the position in the goal term. When [snd (ctrl t) = 1], the traversal continues to the next sub-tree of the goal. When [snd (ctrl t) = 2], no more rewrites are performed in the goal. *) let topdown_rewrite (ctrl : term -> Tac (bool * int)) (rw:unit -> Tac unit) : Tac unit = let ctrl' (t:term) : Tac (bool & ctrl_flag) = let b, i = ctrl t in let f = match i with | 0 -> Continue | 1 -> Skip | 2 -> Abort | _ -> fail "topdown_rewrite: bad value from ctrl" in b, f in ctrl_rewrite TopDown ctrl' rw let pointwise (tau : unit -> Tac unit) : Tac unit = t_pointwise BottomUp tau let pointwise' (tau : unit -> Tac unit) : Tac unit = t_pointwise TopDown tau let cur_module () : Tac name = moduleof (top_env ()) let open_modules () : Tac (list name) = env_open_modules (top_env ()) let fresh_uvar (o : option typ) : Tac term = let e = cur_env () in uvar_env e o let unify (t1 t2 : term) : Tac bool = let e = cur_env () in unify_env e t1 t2 let unify_guard (t1 t2 : term) : Tac bool = let e = cur_env () in unify_guard_env e t1 t2 let tmatch (t1 t2 : term) : Tac bool = let e = cur_env () in match_env e t1 t2 (** [divide n t1 t2] will split the current set of goals into the [n] first ones, and the rest. It then runs [t1] on the first set, and [t2] on the second, returning both results (and concatenating remaining goals). *) let divide (n:int) (l : unit -> Tac 'a) (r : unit -> Tac 'b) : Tac ('a * 'b) = if n < 0 then fail "divide: negative n"; let gs, sgs = goals (), smt_goals () in let gs1, gs2 = List.Tot.Base.splitAt n gs in set_goals gs1; set_smt_goals []; let x = l () in let gsl, sgsl = goals (), smt_goals () in set_goals gs2; set_smt_goals []; let y = r () in let gsr, sgsr = goals (), smt_goals () in set_goals (gsl @ gsr); set_smt_goals (sgs @ sgsl @ sgsr); (x, y) let rec iseq (ts : list (unit -> Tac unit)) : Tac unit = match ts with | t::ts -> let _ = divide 1 t (fun () -> iseq ts) in () | [] -> () (** [focus t] runs [t ()] on the current active goal, hiding all others and restoring them at the end. *) let focus (t : unit -> Tac 'a) : Tac 'a = match goals () with | [] -> fail "focus: no goals" | g::gs -> let sgs = smt_goals () in set_goals [g]; set_smt_goals []; let x = t () in set_goals (goals () @ gs); set_smt_goals (smt_goals () @ sgs); x (** Similar to [dump], but only dumping the current goal. *) let dump1 (m : string) = focus (fun () -> dump m) let rec mapAll (t : unit -> Tac 'a) : Tac (list 'a) = match goals () with | [] -> [] | _::_ -> let (h, t) = divide 1 t (fun () -> mapAll t) in h::t let rec iterAll (t : unit -> Tac unit) : Tac unit = (* Could use mapAll, but why even build that list *) match goals () with | [] -> () | _::_ -> let _ = divide 1 t (fun () -> iterAll t) in () let iterAllSMT (t : unit -> Tac unit) : Tac unit = let gs, sgs = goals (), smt_goals () in set_goals sgs; set_smt_goals []; iterAll t; let gs', sgs' = goals (), smt_goals () in set_goals gs; set_smt_goals (gs'@sgs') (** Runs tactic [t1] on the current goal, and then tactic [t2] on *each* subgoal produced by [t1]. Each invocation of [t2] runs on a proofstate with a single goal (they're "focused"). *) let seq (f : unit -> Tac unit) (g : unit -> Tac unit) : Tac unit = focus (fun () -> f (); iterAll g) let exact_args (qs : list aqualv) (t : term) : Tac unit = focus (fun () -> let n = List.Tot.Base.length qs in let uvs = repeatn n (fun () -> fresh_uvar None) in let t' = mk_app t (zip uvs qs) in exact t'; iter (fun uv -> if is_uvar uv then unshelve uv else ()) (L.rev uvs) ) let exact_n (n : int) (t : term) : Tac unit = exact_args (repeatn n (fun () -> Q_Explicit)) t (** [ngoals ()] returns the number of goals *) let ngoals () : Tac int = List.Tot.Base.length (goals ()) (** [ngoals_smt ()] returns the number of SMT goals *) let ngoals_smt () : Tac int = List.Tot.Base.length (smt_goals ()) (* sigh GGG fix names!! *) let fresh_namedv_named (s:string) : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal s; sort = seal (pack Tv_Unknown); uniq = n; }) (* Create a fresh bound variable (bv), using a generic name. See also [fresh_namedv_named]. *) let fresh_namedv () : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal ("x" ^ string_of_int n); sort = seal (pack Tv_Unknown); uniq = n; }) let fresh_binder_named (s : string) (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal s; sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_binder (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_implicit_binder (t : typ) : Tac binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Implicit; attrs = [] ; } let guard (b : bool) : TacH unit (requires (fun _ -> True)) (ensures (fun ps r -> if b then Success? r /\ Success?.ps r == ps else Failed? r)) (* ^ the proofstate on failure is not exactly equal (has the psc set) *) = if not b then fail "guard failed" else () let try_with (f : unit -> Tac 'a) (h : exn -> Tac 'a) : Tac 'a = match catch f with | Inl e -> h e | Inr x -> x let trytac (t : unit -> Tac 'a) : Tac (option 'a) = try Some (t ()) with | _ -> None let or_else (#a:Type) (t1 : unit -> Tac a) (t2 : unit -> Tac a) : Tac a = try t1 () with | _ -> t2 () val (<|>) : (unit -> Tac 'a) -> (unit -> Tac 'a) -> (unit -> Tac 'a) let (<|>) t1 t2 = fun () -> or_else t1 t2 let first (ts : list (unit -> Tac 'a)) : Tac 'a = L.fold_right (<|>) ts (fun () -> fail "no tactics to try") () let rec repeat (#a:Type) (t : unit -> Tac a) : Tac (list a) = match catch t with | Inl _ -> [] | Inr x -> x :: repeat t let repeat1 (#a:Type) (t : unit -> Tac a) : Tac (list a) = t () :: repeat t let repeat' (f : unit -> Tac 'a) : Tac unit = let _ = repeat f in () let norm_term (s : list norm_step) (t : term) : Tac term = let e = try cur_env () with | _ -> top_env () in norm_term_env e s t (** Join all of the SMT goals into one. This helps when all of them are expected to be similar, and therefore easier to prove at once by the SMT solver. TODO: would be nice to try to join them in a more meaningful way, as the order can matter. *) let join_all_smt_goals () = let gs, sgs = goals (), smt_goals () in set_smt_goals []; set_goals sgs; repeat' join; let sgs' = goals () in // should be a single one set_goals gs; set_smt_goals sgs' let discard (tau : unit -> Tac 'a) : unit -> Tac unit = fun () -> let _ = tau () in () // TODO: do we want some value out of this? let rec repeatseq (#a:Type) (t : unit -> Tac a) : Tac unit = let _ = trytac (fun () -> (discard t) `seq` (discard (fun () -> repeatseq t))) in () let tadmit () = tadmit_t (`()) let admit1 () : Tac unit = tadmit () let admit_all () : Tac unit = let _ = repeat tadmit in () (** [is_guard] returns whether the current goal arose from a typechecking guard *) let is_guard () : Tac bool = Tactics.Types.is_guard (_cur_goal ()) let skip_guard () : Tac unit = if is_guard () then smt () else fail "" let guards_to_smt () : Tac unit = let _ = repeat skip_guard in () let simpl () : Tac unit = norm [simplify; primops] let whnf () : Tac unit = norm [weak; hnf; primops; delta] let compute () : Tac unit = norm [primops; iota; delta; zeta] let intros () : Tac (list binding) = repeat intro let intros' () : Tac unit = let _ = intros () in () let destruct tm : Tac unit = let _ = t_destruct tm in () let destruct_intros tm : Tac unit = seq (fun () -> let _ = t_destruct tm in ()) intros' private val __cut : (a:Type) -> (b:Type) -> (a -> b) -> a -> b private let __cut a b f x = f x let tcut (t:term) : Tac binding = let g = cur_goal () in let tt = mk_e_app (`__cut) [t; g] in apply tt; intro () let pose (t:term) : Tac binding = apply (`__cut); flip (); exact t; intro () let intro_as (s:string) : Tac binding = let b = intro () in rename_to b s let pose_as (s:string) (t:term) : Tac binding = let b = pose t in rename_to b s let for_each_binding (f : binding -> Tac 'a) : Tac (list 'a) = map f (cur_vars ()) let rec revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> revert (); revert_all tl let binder_sort (b : binder) : Tot typ = b.sort // Cannot define this inside `assumption` due to #1091 private let rec __assumption_aux (xs : list binding) : Tac unit = match xs with | [] -> fail "no assumption matches goal" | b::bs -> try exact b with | _ -> try (apply (`FStar.Squash.return_squash); exact b) with | _ -> __assumption_aux bs let assumption () : Tac unit = __assumption_aux (cur_vars ()) let destruct_equality_implication (t:term) : Tac (option (formula * term)) = match term_as_formula t with | Implies lhs rhs -> let lhs = term_as_formula' lhs in begin match lhs with | Comp (Eq _) _ _ -> Some (lhs, rhs) | _ -> None end | _ -> None private let __eq_sym #t (a b : t) : Lemma ((a == b) == (b == a)) = FStar.PropositionalExtensionality.apply (a==b) (b==a) (** Like [rewrite], but works with equalities [v == e] and [e == v] *) let rewrite' (x:binding) : Tac unit = ((fun () -> rewrite x) <|> (fun () -> var_retype x; apply_lemma (`__eq_sym); rewrite x) <|> (fun () -> fail "rewrite' failed")) () let rec try_rewrite_equality (x:term) (bs:list binding) : Tac unit = match bs with | [] -> () | x_t::bs -> begin match term_as_formula (type_of_binding x_t) with | Comp (Eq _) y _ -> if term_eq x y then rewrite x_t else try_rewrite_equality x bs | _ -> try_rewrite_equality x bs end let rec rewrite_all_context_equalities (bs:list binding) : Tac unit = match bs with | [] -> () | x_t::bs -> begin (try rewrite x_t with | _ -> ()); rewrite_all_context_equalities bs end let rewrite_eqs_from_context () : Tac unit = rewrite_all_context_equalities (cur_vars ()) let rewrite_equality (t:term) : Tac unit = try_rewrite_equality t (cur_vars ()) let unfold_def (t:term) : Tac unit = match inspect t with | Tv_FVar fv -> let n = implode_qn (inspect_fv fv) in norm [delta_fully [n]] | _ -> fail "unfold_def: term is not a fv" (** Rewrites left-to-right, and bottom-up, given a set of lemmas stating equalities. The lemmas need to prove *propositional* equalities, that is, using [==]. *) let l_to_r (lems:list term) : Tac unit = let first_or_trefl () : Tac unit = fold_left (fun k l () -> (fun () -> apply_lemma_rw l) `or_else` k) trefl lems () in pointwise first_or_trefl let mk_squash (t : term) : Tot term = let sq : term = pack (Tv_FVar (pack_fv squash_qn)) in mk_e_app sq [t] let mk_sq_eq (t1 t2 : term) : Tot term = let eq : term = pack (Tv_FVar (pack_fv eq2_qn)) in mk_squash (mk_e_app eq [t1; t2]) (** Rewrites all appearances of a term [t1] in the goal into [t2]. Creates a new goal for [t1 == t2]. *) let grewrite (t1 t2 : term) : Tac unit = let e = tcut (mk_sq_eq t1 t2) in let e = pack (Tv_Var e) in pointwise (fun () -> (* If the LHS is a uvar, do nothing, so we do not instantiate it. *) let is_uvar = match term_as_formula (cur_goal()) with | Comp (Eq _) lhs rhs -> (match inspect lhs with | Tv_Uvar _ _ -> true | _ -> false) | _ -> false in if is_uvar then trefl () else try exact e with | _ -> trefl ()) private let __un_sq_eq (#a:Type) (x y : a) (_ : (x == y)) : Lemma (x == y) = () (** A wrapper to [grewrite] which takes a binder of an equality type *) let grewrite_eq (b:binding) : Tac unit = match term_as_formula (type_of_binding b) with | Comp (Eq _) l r -> grewrite l r; iseq [idtac; (fun () -> exact b)] | _ -> begin match term_as_formula' (type_of_binding b) with | Comp (Eq _) l r -> grewrite l r; iseq [idtac; (fun () -> apply_lemma (`__un_sq_eq); exact b)] | _ -> fail "grewrite_eq: binder type is not an equality" end private
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val admit_dump_t: Prims.unit -> Tac unit
[]
FStar.Tactics.V2.Derived.admit_dump_t
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 16, "end_line": 704, "start_col": 2, "start_line": 703 }
FStar.Tactics.Effect.Tac
val trytac (t: (unit -> Tac 'a)) : Tac (option 'a)
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let trytac (t : unit -> Tac 'a) : Tac (option 'a) = try Some (t ()) with | _ -> None
val trytac (t: (unit -> Tac 'a)) : Tac (option 'a) let trytac (t: (unit -> Tac 'a)) : Tac (option 'a) =
true
null
false
try Some (t ()) with | _ -> None
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "Prims.unit", "FStar.Tactics.V2.Derived.try_with", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.Some", "Prims.exn", "FStar.Pervasives.Native.None" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *) let commute_applied_match () : Tac unit = t_commute_applied_match () (** Similar to [apply_lemma], but will not instantiate uvars in the goal while applying. *) let apply_lemma_noinst (t : term) : Tac unit = t_apply_lemma true false t let apply_lemma_rw (t : term) : Tac unit = t_apply_lemma false true t (** [apply_raw f] is like [apply], but will ask for all arguments regardless of whether they appear free in further goals. See the explanation in [t_apply]. *) let apply_raw (t : term) : Tac unit = t_apply false false false t (** Like [exact], but allows for the term [e] to have a type [t] only under some guard [g], adding the guard as a goal. *) let exact_guard (t : term) : Tac unit = with_policy Goal (fun () -> t_exact true false t) (** (TODO: explain better) When running [pointwise tau] For every subterm [t'] of the goal's type [t], the engine will build a goal [Gamma |= t' == ?u] and run [tau] on it. When the tactic proves the goal, the engine will rewrite [t'] for [?u] in the original goal type. This is done for every subterm, bottom-up. This allows to recurse over an unknown goal type. By inspecting the goal, the [tau] can then decide what to do (to not do anything, use [trefl]). *) let t_pointwise (d:direction) (tau : unit -> Tac unit) : Tac unit = let ctrl (t:term) : Tac (bool & ctrl_flag) = true, Continue in let rw () : Tac unit = tau () in ctrl_rewrite d ctrl rw (** [topdown_rewrite ctrl rw] is used to rewrite those sub-terms [t] of the goal on which [fst (ctrl t)] returns true. On each such sub-term, [rw] is presented with an equality of goal of the form [Gamma |= t == ?u]. When [rw] proves the goal, the engine will rewrite [t] for [?u] in the original goal type. The goal formula is traversed top-down and the traversal can be controlled by [snd (ctrl t)]: When [snd (ctrl t) = 0], the traversal continues down through the position in the goal term. When [snd (ctrl t) = 1], the traversal continues to the next sub-tree of the goal. When [snd (ctrl t) = 2], no more rewrites are performed in the goal. *) let topdown_rewrite (ctrl : term -> Tac (bool * int)) (rw:unit -> Tac unit) : Tac unit = let ctrl' (t:term) : Tac (bool & ctrl_flag) = let b, i = ctrl t in let f = match i with | 0 -> Continue | 1 -> Skip | 2 -> Abort | _ -> fail "topdown_rewrite: bad value from ctrl" in b, f in ctrl_rewrite TopDown ctrl' rw let pointwise (tau : unit -> Tac unit) : Tac unit = t_pointwise BottomUp tau let pointwise' (tau : unit -> Tac unit) : Tac unit = t_pointwise TopDown tau let cur_module () : Tac name = moduleof (top_env ()) let open_modules () : Tac (list name) = env_open_modules (top_env ()) let fresh_uvar (o : option typ) : Tac term = let e = cur_env () in uvar_env e o let unify (t1 t2 : term) : Tac bool = let e = cur_env () in unify_env e t1 t2 let unify_guard (t1 t2 : term) : Tac bool = let e = cur_env () in unify_guard_env e t1 t2 let tmatch (t1 t2 : term) : Tac bool = let e = cur_env () in match_env e t1 t2 (** [divide n t1 t2] will split the current set of goals into the [n] first ones, and the rest. It then runs [t1] on the first set, and [t2] on the second, returning both results (and concatenating remaining goals). *) let divide (n:int) (l : unit -> Tac 'a) (r : unit -> Tac 'b) : Tac ('a * 'b) = if n < 0 then fail "divide: negative n"; let gs, sgs = goals (), smt_goals () in let gs1, gs2 = List.Tot.Base.splitAt n gs in set_goals gs1; set_smt_goals []; let x = l () in let gsl, sgsl = goals (), smt_goals () in set_goals gs2; set_smt_goals []; let y = r () in let gsr, sgsr = goals (), smt_goals () in set_goals (gsl @ gsr); set_smt_goals (sgs @ sgsl @ sgsr); (x, y) let rec iseq (ts : list (unit -> Tac unit)) : Tac unit = match ts with | t::ts -> let _ = divide 1 t (fun () -> iseq ts) in () | [] -> () (** [focus t] runs [t ()] on the current active goal, hiding all others and restoring them at the end. *) let focus (t : unit -> Tac 'a) : Tac 'a = match goals () with | [] -> fail "focus: no goals" | g::gs -> let sgs = smt_goals () in set_goals [g]; set_smt_goals []; let x = t () in set_goals (goals () @ gs); set_smt_goals (smt_goals () @ sgs); x (** Similar to [dump], but only dumping the current goal. *) let dump1 (m : string) = focus (fun () -> dump m) let rec mapAll (t : unit -> Tac 'a) : Tac (list 'a) = match goals () with | [] -> [] | _::_ -> let (h, t) = divide 1 t (fun () -> mapAll t) in h::t let rec iterAll (t : unit -> Tac unit) : Tac unit = (* Could use mapAll, but why even build that list *) match goals () with | [] -> () | _::_ -> let _ = divide 1 t (fun () -> iterAll t) in () let iterAllSMT (t : unit -> Tac unit) : Tac unit = let gs, sgs = goals (), smt_goals () in set_goals sgs; set_smt_goals []; iterAll t; let gs', sgs' = goals (), smt_goals () in set_goals gs; set_smt_goals (gs'@sgs') (** Runs tactic [t1] on the current goal, and then tactic [t2] on *each* subgoal produced by [t1]. Each invocation of [t2] runs on a proofstate with a single goal (they're "focused"). *) let seq (f : unit -> Tac unit) (g : unit -> Tac unit) : Tac unit = focus (fun () -> f (); iterAll g) let exact_args (qs : list aqualv) (t : term) : Tac unit = focus (fun () -> let n = List.Tot.Base.length qs in let uvs = repeatn n (fun () -> fresh_uvar None) in let t' = mk_app t (zip uvs qs) in exact t'; iter (fun uv -> if is_uvar uv then unshelve uv else ()) (L.rev uvs) ) let exact_n (n : int) (t : term) : Tac unit = exact_args (repeatn n (fun () -> Q_Explicit)) t (** [ngoals ()] returns the number of goals *) let ngoals () : Tac int = List.Tot.Base.length (goals ()) (** [ngoals_smt ()] returns the number of SMT goals *) let ngoals_smt () : Tac int = List.Tot.Base.length (smt_goals ()) (* sigh GGG fix names!! *) let fresh_namedv_named (s:string) : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal s; sort = seal (pack Tv_Unknown); uniq = n; }) (* Create a fresh bound variable (bv), using a generic name. See also [fresh_namedv_named]. *) let fresh_namedv () : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal ("x" ^ string_of_int n); sort = seal (pack Tv_Unknown); uniq = n; }) let fresh_binder_named (s : string) (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal s; sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_binder (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_implicit_binder (t : typ) : Tac binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Implicit; attrs = [] ; } let guard (b : bool) : TacH unit (requires (fun _ -> True)) (ensures (fun ps r -> if b then Success? r /\ Success?.ps r == ps else Failed? r)) (* ^ the proofstate on failure is not exactly equal (has the psc set) *) = if not b then fail "guard failed" else () let try_with (f : unit -> Tac 'a) (h : exn -> Tac 'a) : Tac 'a = match catch f with | Inl e -> h e | Inr x -> x
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val trytac (t: (unit -> Tac 'a)) : Tac (option 'a)
[]
FStar.Tactics.V2.Derived.trytac
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t: (_: Prims.unit -> FStar.Tactics.Effect.Tac 'a) -> FStar.Tactics.Effect.Tac (FStar.Pervasives.Native.option 'a)
{ "end_col": 15, "end_line": 454, "start_col": 4, "start_line": 452 }
FStar.Tactics.Effect.Tac
val add_elem (t: (unit -> Tac 'a)) : Tac 'a
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let add_elem (t : unit -> Tac 'a) : Tac 'a = focus (fun () -> apply (`Cons); focus (fun () -> let x = t () in qed (); x ) )
val add_elem (t: (unit -> Tac 'a)) : Tac 'a let add_elem (t: (unit -> Tac 'a)) : Tac 'a =
true
null
false
focus (fun () -> apply (`Cons); focus (fun () -> let x = t () in qed (); x))
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "Prims.unit", "FStar.Tactics.V2.Derived.focus", "FStar.Tactics.V2.Derived.qed", "FStar.Tactics.V2.Derived.apply" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *) let commute_applied_match () : Tac unit = t_commute_applied_match () (** Similar to [apply_lemma], but will not instantiate uvars in the goal while applying. *) let apply_lemma_noinst (t : term) : Tac unit = t_apply_lemma true false t let apply_lemma_rw (t : term) : Tac unit = t_apply_lemma false true t (** [apply_raw f] is like [apply], but will ask for all arguments regardless of whether they appear free in further goals. See the explanation in [t_apply]. *) let apply_raw (t : term) : Tac unit = t_apply false false false t (** Like [exact], but allows for the term [e] to have a type [t] only under some guard [g], adding the guard as a goal. *) let exact_guard (t : term) : Tac unit = with_policy Goal (fun () -> t_exact true false t) (** (TODO: explain better) When running [pointwise tau] For every subterm [t'] of the goal's type [t], the engine will build a goal [Gamma |= t' == ?u] and run [tau] on it. When the tactic proves the goal, the engine will rewrite [t'] for [?u] in the original goal type. This is done for every subterm, bottom-up. This allows to recurse over an unknown goal type. By inspecting the goal, the [tau] can then decide what to do (to not do anything, use [trefl]). *) let t_pointwise (d:direction) (tau : unit -> Tac unit) : Tac unit = let ctrl (t:term) : Tac (bool & ctrl_flag) = true, Continue in let rw () : Tac unit = tau () in ctrl_rewrite d ctrl rw (** [topdown_rewrite ctrl rw] is used to rewrite those sub-terms [t] of the goal on which [fst (ctrl t)] returns true. On each such sub-term, [rw] is presented with an equality of goal of the form [Gamma |= t == ?u]. When [rw] proves the goal, the engine will rewrite [t] for [?u] in the original goal type. The goal formula is traversed top-down and the traversal can be controlled by [snd (ctrl t)]: When [snd (ctrl t) = 0], the traversal continues down through the position in the goal term. When [snd (ctrl t) = 1], the traversal continues to the next sub-tree of the goal. When [snd (ctrl t) = 2], no more rewrites are performed in the goal. *) let topdown_rewrite (ctrl : term -> Tac (bool * int)) (rw:unit -> Tac unit) : Tac unit = let ctrl' (t:term) : Tac (bool & ctrl_flag) = let b, i = ctrl t in let f = match i with | 0 -> Continue | 1 -> Skip | 2 -> Abort | _ -> fail "topdown_rewrite: bad value from ctrl" in b, f in ctrl_rewrite TopDown ctrl' rw let pointwise (tau : unit -> Tac unit) : Tac unit = t_pointwise BottomUp tau let pointwise' (tau : unit -> Tac unit) : Tac unit = t_pointwise TopDown tau let cur_module () : Tac name = moduleof (top_env ()) let open_modules () : Tac (list name) = env_open_modules (top_env ()) let fresh_uvar (o : option typ) : Tac term = let e = cur_env () in uvar_env e o let unify (t1 t2 : term) : Tac bool = let e = cur_env () in unify_env e t1 t2 let unify_guard (t1 t2 : term) : Tac bool = let e = cur_env () in unify_guard_env e t1 t2 let tmatch (t1 t2 : term) : Tac bool = let e = cur_env () in match_env e t1 t2 (** [divide n t1 t2] will split the current set of goals into the [n] first ones, and the rest. It then runs [t1] on the first set, and [t2] on the second, returning both results (and concatenating remaining goals). *) let divide (n:int) (l : unit -> Tac 'a) (r : unit -> Tac 'b) : Tac ('a * 'b) = if n < 0 then fail "divide: negative n"; let gs, sgs = goals (), smt_goals () in let gs1, gs2 = List.Tot.Base.splitAt n gs in set_goals gs1; set_smt_goals []; let x = l () in let gsl, sgsl = goals (), smt_goals () in set_goals gs2; set_smt_goals []; let y = r () in let gsr, sgsr = goals (), smt_goals () in set_goals (gsl @ gsr); set_smt_goals (sgs @ sgsl @ sgsr); (x, y) let rec iseq (ts : list (unit -> Tac unit)) : Tac unit = match ts with | t::ts -> let _ = divide 1 t (fun () -> iseq ts) in () | [] -> () (** [focus t] runs [t ()] on the current active goal, hiding all others and restoring them at the end. *) let focus (t : unit -> Tac 'a) : Tac 'a = match goals () with | [] -> fail "focus: no goals" | g::gs -> let sgs = smt_goals () in set_goals [g]; set_smt_goals []; let x = t () in set_goals (goals () @ gs); set_smt_goals (smt_goals () @ sgs); x (** Similar to [dump], but only dumping the current goal. *) let dump1 (m : string) = focus (fun () -> dump m) let rec mapAll (t : unit -> Tac 'a) : Tac (list 'a) = match goals () with | [] -> [] | _::_ -> let (h, t) = divide 1 t (fun () -> mapAll t) in h::t let rec iterAll (t : unit -> Tac unit) : Tac unit = (* Could use mapAll, but why even build that list *) match goals () with | [] -> () | _::_ -> let _ = divide 1 t (fun () -> iterAll t) in () let iterAllSMT (t : unit -> Tac unit) : Tac unit = let gs, sgs = goals (), smt_goals () in set_goals sgs; set_smt_goals []; iterAll t; let gs', sgs' = goals (), smt_goals () in set_goals gs; set_smt_goals (gs'@sgs') (** Runs tactic [t1] on the current goal, and then tactic [t2] on *each* subgoal produced by [t1]. Each invocation of [t2] runs on a proofstate with a single goal (they're "focused"). *) let seq (f : unit -> Tac unit) (g : unit -> Tac unit) : Tac unit = focus (fun () -> f (); iterAll g) let exact_args (qs : list aqualv) (t : term) : Tac unit = focus (fun () -> let n = List.Tot.Base.length qs in let uvs = repeatn n (fun () -> fresh_uvar None) in let t' = mk_app t (zip uvs qs) in exact t'; iter (fun uv -> if is_uvar uv then unshelve uv else ()) (L.rev uvs) ) let exact_n (n : int) (t : term) : Tac unit = exact_args (repeatn n (fun () -> Q_Explicit)) t (** [ngoals ()] returns the number of goals *) let ngoals () : Tac int = List.Tot.Base.length (goals ()) (** [ngoals_smt ()] returns the number of SMT goals *) let ngoals_smt () : Tac int = List.Tot.Base.length (smt_goals ()) (* sigh GGG fix names!! *) let fresh_namedv_named (s:string) : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal s; sort = seal (pack Tv_Unknown); uniq = n; }) (* Create a fresh bound variable (bv), using a generic name. See also [fresh_namedv_named]. *) let fresh_namedv () : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal ("x" ^ string_of_int n); sort = seal (pack Tv_Unknown); uniq = n; }) let fresh_binder_named (s : string) (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal s; sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_binder (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_implicit_binder (t : typ) : Tac binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Implicit; attrs = [] ; } let guard (b : bool) : TacH unit (requires (fun _ -> True)) (ensures (fun ps r -> if b then Success? r /\ Success?.ps r == ps else Failed? r)) (* ^ the proofstate on failure is not exactly equal (has the psc set) *) = if not b then fail "guard failed" else () let try_with (f : unit -> Tac 'a) (h : exn -> Tac 'a) : Tac 'a = match catch f with | Inl e -> h e | Inr x -> x let trytac (t : unit -> Tac 'a) : Tac (option 'a) = try Some (t ()) with | _ -> None let or_else (#a:Type) (t1 : unit -> Tac a) (t2 : unit -> Tac a) : Tac a = try t1 () with | _ -> t2 () val (<|>) : (unit -> Tac 'a) -> (unit -> Tac 'a) -> (unit -> Tac 'a) let (<|>) t1 t2 = fun () -> or_else t1 t2 let first (ts : list (unit -> Tac 'a)) : Tac 'a = L.fold_right (<|>) ts (fun () -> fail "no tactics to try") () let rec repeat (#a:Type) (t : unit -> Tac a) : Tac (list a) = match catch t with | Inl _ -> [] | Inr x -> x :: repeat t let repeat1 (#a:Type) (t : unit -> Tac a) : Tac (list a) = t () :: repeat t let repeat' (f : unit -> Tac 'a) : Tac unit = let _ = repeat f in () let norm_term (s : list norm_step) (t : term) : Tac term = let e = try cur_env () with | _ -> top_env () in norm_term_env e s t (** Join all of the SMT goals into one. This helps when all of them are expected to be similar, and therefore easier to prove at once by the SMT solver. TODO: would be nice to try to join them in a more meaningful way, as the order can matter. *) let join_all_smt_goals () = let gs, sgs = goals (), smt_goals () in set_smt_goals []; set_goals sgs; repeat' join; let sgs' = goals () in // should be a single one set_goals gs; set_smt_goals sgs' let discard (tau : unit -> Tac 'a) : unit -> Tac unit = fun () -> let _ = tau () in () // TODO: do we want some value out of this? let rec repeatseq (#a:Type) (t : unit -> Tac a) : Tac unit = let _ = trytac (fun () -> (discard t) `seq` (discard (fun () -> repeatseq t))) in () let tadmit () = tadmit_t (`()) let admit1 () : Tac unit = tadmit () let admit_all () : Tac unit = let _ = repeat tadmit in () (** [is_guard] returns whether the current goal arose from a typechecking guard *) let is_guard () : Tac bool = Tactics.Types.is_guard (_cur_goal ()) let skip_guard () : Tac unit = if is_guard () then smt () else fail "" let guards_to_smt () : Tac unit = let _ = repeat skip_guard in () let simpl () : Tac unit = norm [simplify; primops] let whnf () : Tac unit = norm [weak; hnf; primops; delta] let compute () : Tac unit = norm [primops; iota; delta; zeta] let intros () : Tac (list binding) = repeat intro let intros' () : Tac unit = let _ = intros () in () let destruct tm : Tac unit = let _ = t_destruct tm in () let destruct_intros tm : Tac unit = seq (fun () -> let _ = t_destruct tm in ()) intros' private val __cut : (a:Type) -> (b:Type) -> (a -> b) -> a -> b private let __cut a b f x = f x let tcut (t:term) : Tac binding = let g = cur_goal () in let tt = mk_e_app (`__cut) [t; g] in apply tt; intro () let pose (t:term) : Tac binding = apply (`__cut); flip (); exact t; intro () let intro_as (s:string) : Tac binding = let b = intro () in rename_to b s let pose_as (s:string) (t:term) : Tac binding = let b = pose t in rename_to b s let for_each_binding (f : binding -> Tac 'a) : Tac (list 'a) = map f (cur_vars ()) let rec revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> revert (); revert_all tl let binder_sort (b : binder) : Tot typ = b.sort // Cannot define this inside `assumption` due to #1091 private let rec __assumption_aux (xs : list binding) : Tac unit = match xs with | [] -> fail "no assumption matches goal" | b::bs -> try exact b with | _ -> try (apply (`FStar.Squash.return_squash); exact b) with | _ -> __assumption_aux bs let assumption () : Tac unit = __assumption_aux (cur_vars ()) let destruct_equality_implication (t:term) : Tac (option (formula * term)) = match term_as_formula t with | Implies lhs rhs -> let lhs = term_as_formula' lhs in begin match lhs with | Comp (Eq _) _ _ -> Some (lhs, rhs) | _ -> None end | _ -> None private let __eq_sym #t (a b : t) : Lemma ((a == b) == (b == a)) = FStar.PropositionalExtensionality.apply (a==b) (b==a) (** Like [rewrite], but works with equalities [v == e] and [e == v] *) let rewrite' (x:binding) : Tac unit = ((fun () -> rewrite x) <|> (fun () -> var_retype x; apply_lemma (`__eq_sym); rewrite x) <|> (fun () -> fail "rewrite' failed")) () let rec try_rewrite_equality (x:term) (bs:list binding) : Tac unit = match bs with | [] -> () | x_t::bs -> begin match term_as_formula (type_of_binding x_t) with | Comp (Eq _) y _ -> if term_eq x y then rewrite x_t else try_rewrite_equality x bs | _ -> try_rewrite_equality x bs end let rec rewrite_all_context_equalities (bs:list binding) : Tac unit = match bs with | [] -> () | x_t::bs -> begin (try rewrite x_t with | _ -> ()); rewrite_all_context_equalities bs end let rewrite_eqs_from_context () : Tac unit = rewrite_all_context_equalities (cur_vars ()) let rewrite_equality (t:term) : Tac unit = try_rewrite_equality t (cur_vars ()) let unfold_def (t:term) : Tac unit = match inspect t with | Tv_FVar fv -> let n = implode_qn (inspect_fv fv) in norm [delta_fully [n]] | _ -> fail "unfold_def: term is not a fv" (** Rewrites left-to-right, and bottom-up, given a set of lemmas stating equalities. The lemmas need to prove *propositional* equalities, that is, using [==]. *) let l_to_r (lems:list term) : Tac unit = let first_or_trefl () : Tac unit = fold_left (fun k l () -> (fun () -> apply_lemma_rw l) `or_else` k) trefl lems () in pointwise first_or_trefl let mk_squash (t : term) : Tot term = let sq : term = pack (Tv_FVar (pack_fv squash_qn)) in mk_e_app sq [t] let mk_sq_eq (t1 t2 : term) : Tot term = let eq : term = pack (Tv_FVar (pack_fv eq2_qn)) in mk_squash (mk_e_app eq [t1; t2]) (** Rewrites all appearances of a term [t1] in the goal into [t2]. Creates a new goal for [t1 == t2]. *) let grewrite (t1 t2 : term) : Tac unit = let e = tcut (mk_sq_eq t1 t2) in let e = pack (Tv_Var e) in pointwise (fun () -> (* If the LHS is a uvar, do nothing, so we do not instantiate it. *) let is_uvar = match term_as_formula (cur_goal()) with | Comp (Eq _) lhs rhs -> (match inspect lhs with | Tv_Uvar _ _ -> true | _ -> false) | _ -> false in if is_uvar then trefl () else try exact e with | _ -> trefl ()) private let __un_sq_eq (#a:Type) (x y : a) (_ : (x == y)) : Lemma (x == y) = () (** A wrapper to [grewrite] which takes a binder of an equality type *) let grewrite_eq (b:binding) : Tac unit = match term_as_formula (type_of_binding b) with | Comp (Eq _) l r -> grewrite l r; iseq [idtac; (fun () -> exact b)] | _ -> begin match term_as_formula' (type_of_binding b) with | Comp (Eq _) l r -> grewrite l r; iseq [idtac; (fun () -> apply_lemma (`__un_sq_eq); exact b)] | _ -> fail "grewrite_eq: binder type is not an equality" end private let admit_dump_t () : Tac unit = dump "Admitting"; apply (`admit) val admit_dump : #a:Type -> (#[admit_dump_t ()] x : (unit -> Admit a)) -> unit -> Admit a let admit_dump #a #x () = x () private let magic_dump_t () : Tac unit = dump "Admitting"; apply (`magic); exact (`()); () val magic_dump : #a:Type -> (#[magic_dump_t ()] x : a) -> unit -> Tot a let magic_dump #a #x () = x let change_with t1 t2 : Tac unit = focus (fun () -> grewrite t1 t2; iseq [idtac; trivial] ) let change_sq (t1 : term) : Tac unit = change (mk_e_app (`squash) [t1]) let finish_by (t : unit -> Tac 'a) : Tac 'a = let x = t () in or_else qed (fun () -> fail "finish_by: not finished"); x let solve_then #a #b (t1 : unit -> Tac a) (t2 : a -> Tac b) : Tac b = dup (); let x = focus (fun () -> finish_by t1) in let y = t2 x in trefl (); y
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val add_elem (t: (unit -> Tac 'a)) : Tac 'a
[]
FStar.Tactics.V2.Derived.add_elem
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t: (_: Prims.unit -> FStar.Tactics.Effect.Tac 'a) -> FStar.Tactics.Effect.Tac 'a
{ "end_col": 3, "end_line": 747, "start_col": 45, "start_line": 740 }
FStar.Tactics.Effect.Tac
val unfold_def (t: term) : Tac unit
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let unfold_def (t:term) : Tac unit = match inspect t with | Tv_FVar fv -> let n = implode_qn (inspect_fv fv) in norm [delta_fully [n]] | _ -> fail "unfold_def: term is not a fv"
val unfold_def (t: term) : Tac unit let unfold_def (t: term) : Tac unit =
true
null
false
match inspect t with | Tv_FVar fv -> let n = implode_qn (inspect_fv fv) in norm [delta_fully [n]] | _ -> fail "unfold_def: term is not a fv"
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "FStar.Tactics.NamedView.term", "FStar.Reflection.Types.fv", "FStar.Tactics.V2.Builtins.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_fully", "Prims.string", "Prims.Nil", "Prims.unit", "FStar.Reflection.V2.Builtins.implode_qn", "FStar.Reflection.V2.Builtins.inspect_fv", "FStar.Tactics.NamedView.named_term_view", "FStar.Tactics.V2.Derived.fail", "FStar.Tactics.NamedView.inspect" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *) let commute_applied_match () : Tac unit = t_commute_applied_match () (** Similar to [apply_lemma], but will not instantiate uvars in the goal while applying. *) let apply_lemma_noinst (t : term) : Tac unit = t_apply_lemma true false t let apply_lemma_rw (t : term) : Tac unit = t_apply_lemma false true t (** [apply_raw f] is like [apply], but will ask for all arguments regardless of whether they appear free in further goals. See the explanation in [t_apply]. *) let apply_raw (t : term) : Tac unit = t_apply false false false t (** Like [exact], but allows for the term [e] to have a type [t] only under some guard [g], adding the guard as a goal. *) let exact_guard (t : term) : Tac unit = with_policy Goal (fun () -> t_exact true false t) (** (TODO: explain better) When running [pointwise tau] For every subterm [t'] of the goal's type [t], the engine will build a goal [Gamma |= t' == ?u] and run [tau] on it. When the tactic proves the goal, the engine will rewrite [t'] for [?u] in the original goal type. This is done for every subterm, bottom-up. This allows to recurse over an unknown goal type. By inspecting the goal, the [tau] can then decide what to do (to not do anything, use [trefl]). *) let t_pointwise (d:direction) (tau : unit -> Tac unit) : Tac unit = let ctrl (t:term) : Tac (bool & ctrl_flag) = true, Continue in let rw () : Tac unit = tau () in ctrl_rewrite d ctrl rw (** [topdown_rewrite ctrl rw] is used to rewrite those sub-terms [t] of the goal on which [fst (ctrl t)] returns true. On each such sub-term, [rw] is presented with an equality of goal of the form [Gamma |= t == ?u]. When [rw] proves the goal, the engine will rewrite [t] for [?u] in the original goal type. The goal formula is traversed top-down and the traversal can be controlled by [snd (ctrl t)]: When [snd (ctrl t) = 0], the traversal continues down through the position in the goal term. When [snd (ctrl t) = 1], the traversal continues to the next sub-tree of the goal. When [snd (ctrl t) = 2], no more rewrites are performed in the goal. *) let topdown_rewrite (ctrl : term -> Tac (bool * int)) (rw:unit -> Tac unit) : Tac unit = let ctrl' (t:term) : Tac (bool & ctrl_flag) = let b, i = ctrl t in let f = match i with | 0 -> Continue | 1 -> Skip | 2 -> Abort | _ -> fail "topdown_rewrite: bad value from ctrl" in b, f in ctrl_rewrite TopDown ctrl' rw let pointwise (tau : unit -> Tac unit) : Tac unit = t_pointwise BottomUp tau let pointwise' (tau : unit -> Tac unit) : Tac unit = t_pointwise TopDown tau let cur_module () : Tac name = moduleof (top_env ()) let open_modules () : Tac (list name) = env_open_modules (top_env ()) let fresh_uvar (o : option typ) : Tac term = let e = cur_env () in uvar_env e o let unify (t1 t2 : term) : Tac bool = let e = cur_env () in unify_env e t1 t2 let unify_guard (t1 t2 : term) : Tac bool = let e = cur_env () in unify_guard_env e t1 t2 let tmatch (t1 t2 : term) : Tac bool = let e = cur_env () in match_env e t1 t2 (** [divide n t1 t2] will split the current set of goals into the [n] first ones, and the rest. It then runs [t1] on the first set, and [t2] on the second, returning both results (and concatenating remaining goals). *) let divide (n:int) (l : unit -> Tac 'a) (r : unit -> Tac 'b) : Tac ('a * 'b) = if n < 0 then fail "divide: negative n"; let gs, sgs = goals (), smt_goals () in let gs1, gs2 = List.Tot.Base.splitAt n gs in set_goals gs1; set_smt_goals []; let x = l () in let gsl, sgsl = goals (), smt_goals () in set_goals gs2; set_smt_goals []; let y = r () in let gsr, sgsr = goals (), smt_goals () in set_goals (gsl @ gsr); set_smt_goals (sgs @ sgsl @ sgsr); (x, y) let rec iseq (ts : list (unit -> Tac unit)) : Tac unit = match ts with | t::ts -> let _ = divide 1 t (fun () -> iseq ts) in () | [] -> () (** [focus t] runs [t ()] on the current active goal, hiding all others and restoring them at the end. *) let focus (t : unit -> Tac 'a) : Tac 'a = match goals () with | [] -> fail "focus: no goals" | g::gs -> let sgs = smt_goals () in set_goals [g]; set_smt_goals []; let x = t () in set_goals (goals () @ gs); set_smt_goals (smt_goals () @ sgs); x (** Similar to [dump], but only dumping the current goal. *) let dump1 (m : string) = focus (fun () -> dump m) let rec mapAll (t : unit -> Tac 'a) : Tac (list 'a) = match goals () with | [] -> [] | _::_ -> let (h, t) = divide 1 t (fun () -> mapAll t) in h::t let rec iterAll (t : unit -> Tac unit) : Tac unit = (* Could use mapAll, but why even build that list *) match goals () with | [] -> () | _::_ -> let _ = divide 1 t (fun () -> iterAll t) in () let iterAllSMT (t : unit -> Tac unit) : Tac unit = let gs, sgs = goals (), smt_goals () in set_goals sgs; set_smt_goals []; iterAll t; let gs', sgs' = goals (), smt_goals () in set_goals gs; set_smt_goals (gs'@sgs') (** Runs tactic [t1] on the current goal, and then tactic [t2] on *each* subgoal produced by [t1]. Each invocation of [t2] runs on a proofstate with a single goal (they're "focused"). *) let seq (f : unit -> Tac unit) (g : unit -> Tac unit) : Tac unit = focus (fun () -> f (); iterAll g) let exact_args (qs : list aqualv) (t : term) : Tac unit = focus (fun () -> let n = List.Tot.Base.length qs in let uvs = repeatn n (fun () -> fresh_uvar None) in let t' = mk_app t (zip uvs qs) in exact t'; iter (fun uv -> if is_uvar uv then unshelve uv else ()) (L.rev uvs) ) let exact_n (n : int) (t : term) : Tac unit = exact_args (repeatn n (fun () -> Q_Explicit)) t (** [ngoals ()] returns the number of goals *) let ngoals () : Tac int = List.Tot.Base.length (goals ()) (** [ngoals_smt ()] returns the number of SMT goals *) let ngoals_smt () : Tac int = List.Tot.Base.length (smt_goals ()) (* sigh GGG fix names!! *) let fresh_namedv_named (s:string) : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal s; sort = seal (pack Tv_Unknown); uniq = n; }) (* Create a fresh bound variable (bv), using a generic name. See also [fresh_namedv_named]. *) let fresh_namedv () : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal ("x" ^ string_of_int n); sort = seal (pack Tv_Unknown); uniq = n; }) let fresh_binder_named (s : string) (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal s; sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_binder (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_implicit_binder (t : typ) : Tac binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Implicit; attrs = [] ; } let guard (b : bool) : TacH unit (requires (fun _ -> True)) (ensures (fun ps r -> if b then Success? r /\ Success?.ps r == ps else Failed? r)) (* ^ the proofstate on failure is not exactly equal (has the psc set) *) = if not b then fail "guard failed" else () let try_with (f : unit -> Tac 'a) (h : exn -> Tac 'a) : Tac 'a = match catch f with | Inl e -> h e | Inr x -> x let trytac (t : unit -> Tac 'a) : Tac (option 'a) = try Some (t ()) with | _ -> None let or_else (#a:Type) (t1 : unit -> Tac a) (t2 : unit -> Tac a) : Tac a = try t1 () with | _ -> t2 () val (<|>) : (unit -> Tac 'a) -> (unit -> Tac 'a) -> (unit -> Tac 'a) let (<|>) t1 t2 = fun () -> or_else t1 t2 let first (ts : list (unit -> Tac 'a)) : Tac 'a = L.fold_right (<|>) ts (fun () -> fail "no tactics to try") () let rec repeat (#a:Type) (t : unit -> Tac a) : Tac (list a) = match catch t with | Inl _ -> [] | Inr x -> x :: repeat t let repeat1 (#a:Type) (t : unit -> Tac a) : Tac (list a) = t () :: repeat t let repeat' (f : unit -> Tac 'a) : Tac unit = let _ = repeat f in () let norm_term (s : list norm_step) (t : term) : Tac term = let e = try cur_env () with | _ -> top_env () in norm_term_env e s t (** Join all of the SMT goals into one. This helps when all of them are expected to be similar, and therefore easier to prove at once by the SMT solver. TODO: would be nice to try to join them in a more meaningful way, as the order can matter. *) let join_all_smt_goals () = let gs, sgs = goals (), smt_goals () in set_smt_goals []; set_goals sgs; repeat' join; let sgs' = goals () in // should be a single one set_goals gs; set_smt_goals sgs' let discard (tau : unit -> Tac 'a) : unit -> Tac unit = fun () -> let _ = tau () in () // TODO: do we want some value out of this? let rec repeatseq (#a:Type) (t : unit -> Tac a) : Tac unit = let _ = trytac (fun () -> (discard t) `seq` (discard (fun () -> repeatseq t))) in () let tadmit () = tadmit_t (`()) let admit1 () : Tac unit = tadmit () let admit_all () : Tac unit = let _ = repeat tadmit in () (** [is_guard] returns whether the current goal arose from a typechecking guard *) let is_guard () : Tac bool = Tactics.Types.is_guard (_cur_goal ()) let skip_guard () : Tac unit = if is_guard () then smt () else fail "" let guards_to_smt () : Tac unit = let _ = repeat skip_guard in () let simpl () : Tac unit = norm [simplify; primops] let whnf () : Tac unit = norm [weak; hnf; primops; delta] let compute () : Tac unit = norm [primops; iota; delta; zeta] let intros () : Tac (list binding) = repeat intro let intros' () : Tac unit = let _ = intros () in () let destruct tm : Tac unit = let _ = t_destruct tm in () let destruct_intros tm : Tac unit = seq (fun () -> let _ = t_destruct tm in ()) intros' private val __cut : (a:Type) -> (b:Type) -> (a -> b) -> a -> b private let __cut a b f x = f x let tcut (t:term) : Tac binding = let g = cur_goal () in let tt = mk_e_app (`__cut) [t; g] in apply tt; intro () let pose (t:term) : Tac binding = apply (`__cut); flip (); exact t; intro () let intro_as (s:string) : Tac binding = let b = intro () in rename_to b s let pose_as (s:string) (t:term) : Tac binding = let b = pose t in rename_to b s let for_each_binding (f : binding -> Tac 'a) : Tac (list 'a) = map f (cur_vars ()) let rec revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> revert (); revert_all tl let binder_sort (b : binder) : Tot typ = b.sort // Cannot define this inside `assumption` due to #1091 private let rec __assumption_aux (xs : list binding) : Tac unit = match xs with | [] -> fail "no assumption matches goal" | b::bs -> try exact b with | _ -> try (apply (`FStar.Squash.return_squash); exact b) with | _ -> __assumption_aux bs let assumption () : Tac unit = __assumption_aux (cur_vars ()) let destruct_equality_implication (t:term) : Tac (option (formula * term)) = match term_as_formula t with | Implies lhs rhs -> let lhs = term_as_formula' lhs in begin match lhs with | Comp (Eq _) _ _ -> Some (lhs, rhs) | _ -> None end | _ -> None private let __eq_sym #t (a b : t) : Lemma ((a == b) == (b == a)) = FStar.PropositionalExtensionality.apply (a==b) (b==a) (** Like [rewrite], but works with equalities [v == e] and [e == v] *) let rewrite' (x:binding) : Tac unit = ((fun () -> rewrite x) <|> (fun () -> var_retype x; apply_lemma (`__eq_sym); rewrite x) <|> (fun () -> fail "rewrite' failed")) () let rec try_rewrite_equality (x:term) (bs:list binding) : Tac unit = match bs with | [] -> () | x_t::bs -> begin match term_as_formula (type_of_binding x_t) with | Comp (Eq _) y _ -> if term_eq x y then rewrite x_t else try_rewrite_equality x bs | _ -> try_rewrite_equality x bs end let rec rewrite_all_context_equalities (bs:list binding) : Tac unit = match bs with | [] -> () | x_t::bs -> begin (try rewrite x_t with | _ -> ()); rewrite_all_context_equalities bs end let rewrite_eqs_from_context () : Tac unit = rewrite_all_context_equalities (cur_vars ()) let rewrite_equality (t:term) : Tac unit = try_rewrite_equality t (cur_vars ())
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val unfold_def (t: term) : Tac unit
[]
FStar.Tactics.V2.Derived.unfold_def
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t: FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 46, "end_line": 642, "start_col": 4, "start_line": 638 }
FStar.Tactics.Effect.Tac
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let join_all_smt_goals () = let gs, sgs = goals (), smt_goals () in set_smt_goals []; set_goals sgs; repeat' join; let sgs' = goals () in // should be a single one set_goals gs; set_smt_goals sgs'
let join_all_smt_goals () =
true
null
false
let gs, sgs = goals (), smt_goals () in set_smt_goals []; set_goals sgs; repeat' join; let sgs' = goals () in set_goals gs; set_smt_goals sgs'
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "Prims.unit", "Prims.list", "FStar.Tactics.Types.goal", "FStar.Tactics.V2.Builtins.set_smt_goals", "FStar.Tactics.V2.Builtins.set_goals", "FStar.Tactics.V2.Derived.goals", "FStar.Tactics.V2.Derived.repeat'", "FStar.Tactics.V2.Builtins.join", "Prims.Nil", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "FStar.Tactics.V2.Derived.smt_goals" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *) let commute_applied_match () : Tac unit = t_commute_applied_match () (** Similar to [apply_lemma], but will not instantiate uvars in the goal while applying. *) let apply_lemma_noinst (t : term) : Tac unit = t_apply_lemma true false t let apply_lemma_rw (t : term) : Tac unit = t_apply_lemma false true t (** [apply_raw f] is like [apply], but will ask for all arguments regardless of whether they appear free in further goals. See the explanation in [t_apply]. *) let apply_raw (t : term) : Tac unit = t_apply false false false t (** Like [exact], but allows for the term [e] to have a type [t] only under some guard [g], adding the guard as a goal. *) let exact_guard (t : term) : Tac unit = with_policy Goal (fun () -> t_exact true false t) (** (TODO: explain better) When running [pointwise tau] For every subterm [t'] of the goal's type [t], the engine will build a goal [Gamma |= t' == ?u] and run [tau] on it. When the tactic proves the goal, the engine will rewrite [t'] for [?u] in the original goal type. This is done for every subterm, bottom-up. This allows to recurse over an unknown goal type. By inspecting the goal, the [tau] can then decide what to do (to not do anything, use [trefl]). *) let t_pointwise (d:direction) (tau : unit -> Tac unit) : Tac unit = let ctrl (t:term) : Tac (bool & ctrl_flag) = true, Continue in let rw () : Tac unit = tau () in ctrl_rewrite d ctrl rw (** [topdown_rewrite ctrl rw] is used to rewrite those sub-terms [t] of the goal on which [fst (ctrl t)] returns true. On each such sub-term, [rw] is presented with an equality of goal of the form [Gamma |= t == ?u]. When [rw] proves the goal, the engine will rewrite [t] for [?u] in the original goal type. The goal formula is traversed top-down and the traversal can be controlled by [snd (ctrl t)]: When [snd (ctrl t) = 0], the traversal continues down through the position in the goal term. When [snd (ctrl t) = 1], the traversal continues to the next sub-tree of the goal. When [snd (ctrl t) = 2], no more rewrites are performed in the goal. *) let topdown_rewrite (ctrl : term -> Tac (bool * int)) (rw:unit -> Tac unit) : Tac unit = let ctrl' (t:term) : Tac (bool & ctrl_flag) = let b, i = ctrl t in let f = match i with | 0 -> Continue | 1 -> Skip | 2 -> Abort | _ -> fail "topdown_rewrite: bad value from ctrl" in b, f in ctrl_rewrite TopDown ctrl' rw let pointwise (tau : unit -> Tac unit) : Tac unit = t_pointwise BottomUp tau let pointwise' (tau : unit -> Tac unit) : Tac unit = t_pointwise TopDown tau let cur_module () : Tac name = moduleof (top_env ()) let open_modules () : Tac (list name) = env_open_modules (top_env ()) let fresh_uvar (o : option typ) : Tac term = let e = cur_env () in uvar_env e o let unify (t1 t2 : term) : Tac bool = let e = cur_env () in unify_env e t1 t2 let unify_guard (t1 t2 : term) : Tac bool = let e = cur_env () in unify_guard_env e t1 t2 let tmatch (t1 t2 : term) : Tac bool = let e = cur_env () in match_env e t1 t2 (** [divide n t1 t2] will split the current set of goals into the [n] first ones, and the rest. It then runs [t1] on the first set, and [t2] on the second, returning both results (and concatenating remaining goals). *) let divide (n:int) (l : unit -> Tac 'a) (r : unit -> Tac 'b) : Tac ('a * 'b) = if n < 0 then fail "divide: negative n"; let gs, sgs = goals (), smt_goals () in let gs1, gs2 = List.Tot.Base.splitAt n gs in set_goals gs1; set_smt_goals []; let x = l () in let gsl, sgsl = goals (), smt_goals () in set_goals gs2; set_smt_goals []; let y = r () in let gsr, sgsr = goals (), smt_goals () in set_goals (gsl @ gsr); set_smt_goals (sgs @ sgsl @ sgsr); (x, y) let rec iseq (ts : list (unit -> Tac unit)) : Tac unit = match ts with | t::ts -> let _ = divide 1 t (fun () -> iseq ts) in () | [] -> () (** [focus t] runs [t ()] on the current active goal, hiding all others and restoring them at the end. *) let focus (t : unit -> Tac 'a) : Tac 'a = match goals () with | [] -> fail "focus: no goals" | g::gs -> let sgs = smt_goals () in set_goals [g]; set_smt_goals []; let x = t () in set_goals (goals () @ gs); set_smt_goals (smt_goals () @ sgs); x (** Similar to [dump], but only dumping the current goal. *) let dump1 (m : string) = focus (fun () -> dump m) let rec mapAll (t : unit -> Tac 'a) : Tac (list 'a) = match goals () with | [] -> [] | _::_ -> let (h, t) = divide 1 t (fun () -> mapAll t) in h::t let rec iterAll (t : unit -> Tac unit) : Tac unit = (* Could use mapAll, but why even build that list *) match goals () with | [] -> () | _::_ -> let _ = divide 1 t (fun () -> iterAll t) in () let iterAllSMT (t : unit -> Tac unit) : Tac unit = let gs, sgs = goals (), smt_goals () in set_goals sgs; set_smt_goals []; iterAll t; let gs', sgs' = goals (), smt_goals () in set_goals gs; set_smt_goals (gs'@sgs') (** Runs tactic [t1] on the current goal, and then tactic [t2] on *each* subgoal produced by [t1]. Each invocation of [t2] runs on a proofstate with a single goal (they're "focused"). *) let seq (f : unit -> Tac unit) (g : unit -> Tac unit) : Tac unit = focus (fun () -> f (); iterAll g) let exact_args (qs : list aqualv) (t : term) : Tac unit = focus (fun () -> let n = List.Tot.Base.length qs in let uvs = repeatn n (fun () -> fresh_uvar None) in let t' = mk_app t (zip uvs qs) in exact t'; iter (fun uv -> if is_uvar uv then unshelve uv else ()) (L.rev uvs) ) let exact_n (n : int) (t : term) : Tac unit = exact_args (repeatn n (fun () -> Q_Explicit)) t (** [ngoals ()] returns the number of goals *) let ngoals () : Tac int = List.Tot.Base.length (goals ()) (** [ngoals_smt ()] returns the number of SMT goals *) let ngoals_smt () : Tac int = List.Tot.Base.length (smt_goals ()) (* sigh GGG fix names!! *) let fresh_namedv_named (s:string) : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal s; sort = seal (pack Tv_Unknown); uniq = n; }) (* Create a fresh bound variable (bv), using a generic name. See also [fresh_namedv_named]. *) let fresh_namedv () : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal ("x" ^ string_of_int n); sort = seal (pack Tv_Unknown); uniq = n; }) let fresh_binder_named (s : string) (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal s; sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_binder (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_implicit_binder (t : typ) : Tac binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Implicit; attrs = [] ; } let guard (b : bool) : TacH unit (requires (fun _ -> True)) (ensures (fun ps r -> if b then Success? r /\ Success?.ps r == ps else Failed? r)) (* ^ the proofstate on failure is not exactly equal (has the psc set) *) = if not b then fail "guard failed" else () let try_with (f : unit -> Tac 'a) (h : exn -> Tac 'a) : Tac 'a = match catch f with | Inl e -> h e | Inr x -> x let trytac (t : unit -> Tac 'a) : Tac (option 'a) = try Some (t ()) with | _ -> None let or_else (#a:Type) (t1 : unit -> Tac a) (t2 : unit -> Tac a) : Tac a = try t1 () with | _ -> t2 () val (<|>) : (unit -> Tac 'a) -> (unit -> Tac 'a) -> (unit -> Tac 'a) let (<|>) t1 t2 = fun () -> or_else t1 t2 let first (ts : list (unit -> Tac 'a)) : Tac 'a = L.fold_right (<|>) ts (fun () -> fail "no tactics to try") () let rec repeat (#a:Type) (t : unit -> Tac a) : Tac (list a) = match catch t with | Inl _ -> [] | Inr x -> x :: repeat t let repeat1 (#a:Type) (t : unit -> Tac a) : Tac (list a) = t () :: repeat t let repeat' (f : unit -> Tac 'a) : Tac unit = let _ = repeat f in () let norm_term (s : list norm_step) (t : term) : Tac term = let e = try cur_env () with | _ -> top_env () in norm_term_env e s t (** Join all of the SMT goals into one. This helps when all of them are expected to be similar, and therefore easier to prove at once by the SMT solver. TODO: would be nice to try to join them in a more meaningful
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val join_all_smt_goals : _: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
[]
FStar.Tactics.V2.Derived.join_all_smt_goals
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 20, "end_line": 497, "start_col": 27, "start_line": 490 }
FStar.Tactics.Effect.Tac
val open_modules: Prims.unit -> Tac (list name)
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let open_modules () : Tac (list name) = env_open_modules (top_env ())
val open_modules: Prims.unit -> Tac (list name) let open_modules () : Tac (list name) =
true
null
false
env_open_modules (top_env ())
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "Prims.unit", "FStar.Reflection.V2.Builtins.env_open_modules", "Prims.list", "FStar.Reflection.Types.name", "FStar.Reflection.Types.env", "FStar.Tactics.V2.Builtins.top_env" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *) let commute_applied_match () : Tac unit = t_commute_applied_match () (** Similar to [apply_lemma], but will not instantiate uvars in the goal while applying. *) let apply_lemma_noinst (t : term) : Tac unit = t_apply_lemma true false t let apply_lemma_rw (t : term) : Tac unit = t_apply_lemma false true t (** [apply_raw f] is like [apply], but will ask for all arguments regardless of whether they appear free in further goals. See the explanation in [t_apply]. *) let apply_raw (t : term) : Tac unit = t_apply false false false t (** Like [exact], but allows for the term [e] to have a type [t] only under some guard [g], adding the guard as a goal. *) let exact_guard (t : term) : Tac unit = with_policy Goal (fun () -> t_exact true false t) (** (TODO: explain better) When running [pointwise tau] For every subterm [t'] of the goal's type [t], the engine will build a goal [Gamma |= t' == ?u] and run [tau] on it. When the tactic proves the goal, the engine will rewrite [t'] for [?u] in the original goal type. This is done for every subterm, bottom-up. This allows to recurse over an unknown goal type. By inspecting the goal, the [tau] can then decide what to do (to not do anything, use [trefl]). *) let t_pointwise (d:direction) (tau : unit -> Tac unit) : Tac unit = let ctrl (t:term) : Tac (bool & ctrl_flag) = true, Continue in let rw () : Tac unit = tau () in ctrl_rewrite d ctrl rw (** [topdown_rewrite ctrl rw] is used to rewrite those sub-terms [t] of the goal on which [fst (ctrl t)] returns true. On each such sub-term, [rw] is presented with an equality of goal of the form [Gamma |= t == ?u]. When [rw] proves the goal, the engine will rewrite [t] for [?u] in the original goal type. The goal formula is traversed top-down and the traversal can be controlled by [snd (ctrl t)]: When [snd (ctrl t) = 0], the traversal continues down through the position in the goal term. When [snd (ctrl t) = 1], the traversal continues to the next sub-tree of the goal. When [snd (ctrl t) = 2], no more rewrites are performed in the goal. *) let topdown_rewrite (ctrl : term -> Tac (bool * int)) (rw:unit -> Tac unit) : Tac unit = let ctrl' (t:term) : Tac (bool & ctrl_flag) = let b, i = ctrl t in let f = match i with | 0 -> Continue | 1 -> Skip | 2 -> Abort | _ -> fail "topdown_rewrite: bad value from ctrl" in b, f in ctrl_rewrite TopDown ctrl' rw let pointwise (tau : unit -> Tac unit) : Tac unit = t_pointwise BottomUp tau let pointwise' (tau : unit -> Tac unit) : Tac unit = t_pointwise TopDown tau let cur_module () : Tac name = moduleof (top_env ())
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val open_modules: Prims.unit -> Tac (list name)
[]
FStar.Tactics.V2.Derived.open_modules
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Tactics.Effect.Tac (Prims.list FStar.Reflection.Types.name)
{ "end_col": 33, "end_line": 283, "start_col": 4, "start_line": 283 }
FStar.Tactics.Effect.Tac
val destruct_equality_implication (t: term) : Tac (option (formula * term))
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let destruct_equality_implication (t:term) : Tac (option (formula * term)) = match term_as_formula t with | Implies lhs rhs -> let lhs = term_as_formula' lhs in begin match lhs with | Comp (Eq _) _ _ -> Some (lhs, rhs) | _ -> None end | _ -> None
val destruct_equality_implication (t: term) : Tac (option (formula * term)) let destruct_equality_implication (t: term) : Tac (option (formula * term)) =
true
null
false
match term_as_formula t with | Implies lhs rhs -> let lhs = term_as_formula' lhs in (match lhs with | Comp (Eq _) _ _ -> Some (lhs, rhs) | _ -> None) | _ -> None
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "FStar.Tactics.NamedView.term", "FStar.Pervasives.Native.option", "FStar.Reflection.Types.typ", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple2", "FStar.Reflection.V2.Formula.formula", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.None", "FStar.Reflection.V2.Formula.term_as_formula'", "FStar.Reflection.V2.Formula.term_as_formula" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *) let trefl () : Tac unit = t_trefl false (** See docs for [t_trefl] *) let trefl_guard () : Tac unit = t_trefl true (** See docs for [t_commute_applied_match] *) let commute_applied_match () : Tac unit = t_commute_applied_match () (** Similar to [apply_lemma], but will not instantiate uvars in the goal while applying. *) let apply_lemma_noinst (t : term) : Tac unit = t_apply_lemma true false t let apply_lemma_rw (t : term) : Tac unit = t_apply_lemma false true t (** [apply_raw f] is like [apply], but will ask for all arguments regardless of whether they appear free in further goals. See the explanation in [t_apply]. *) let apply_raw (t : term) : Tac unit = t_apply false false false t (** Like [exact], but allows for the term [e] to have a type [t] only under some guard [g], adding the guard as a goal. *) let exact_guard (t : term) : Tac unit = with_policy Goal (fun () -> t_exact true false t) (** (TODO: explain better) When running [pointwise tau] For every subterm [t'] of the goal's type [t], the engine will build a goal [Gamma |= t' == ?u] and run [tau] on it. When the tactic proves the goal, the engine will rewrite [t'] for [?u] in the original goal type. This is done for every subterm, bottom-up. This allows to recurse over an unknown goal type. By inspecting the goal, the [tau] can then decide what to do (to not do anything, use [trefl]). *) let t_pointwise (d:direction) (tau : unit -> Tac unit) : Tac unit = let ctrl (t:term) : Tac (bool & ctrl_flag) = true, Continue in let rw () : Tac unit = tau () in ctrl_rewrite d ctrl rw (** [topdown_rewrite ctrl rw] is used to rewrite those sub-terms [t] of the goal on which [fst (ctrl t)] returns true. On each such sub-term, [rw] is presented with an equality of goal of the form [Gamma |= t == ?u]. When [rw] proves the goal, the engine will rewrite [t] for [?u] in the original goal type. The goal formula is traversed top-down and the traversal can be controlled by [snd (ctrl t)]: When [snd (ctrl t) = 0], the traversal continues down through the position in the goal term. When [snd (ctrl t) = 1], the traversal continues to the next sub-tree of the goal. When [snd (ctrl t) = 2], no more rewrites are performed in the goal. *) let topdown_rewrite (ctrl : term -> Tac (bool * int)) (rw:unit -> Tac unit) : Tac unit = let ctrl' (t:term) : Tac (bool & ctrl_flag) = let b, i = ctrl t in let f = match i with | 0 -> Continue | 1 -> Skip | 2 -> Abort | _ -> fail "topdown_rewrite: bad value from ctrl" in b, f in ctrl_rewrite TopDown ctrl' rw let pointwise (tau : unit -> Tac unit) : Tac unit = t_pointwise BottomUp tau let pointwise' (tau : unit -> Tac unit) : Tac unit = t_pointwise TopDown tau let cur_module () : Tac name = moduleof (top_env ()) let open_modules () : Tac (list name) = env_open_modules (top_env ()) let fresh_uvar (o : option typ) : Tac term = let e = cur_env () in uvar_env e o let unify (t1 t2 : term) : Tac bool = let e = cur_env () in unify_env e t1 t2 let unify_guard (t1 t2 : term) : Tac bool = let e = cur_env () in unify_guard_env e t1 t2 let tmatch (t1 t2 : term) : Tac bool = let e = cur_env () in match_env e t1 t2 (** [divide n t1 t2] will split the current set of goals into the [n] first ones, and the rest. It then runs [t1] on the first set, and [t2] on the second, returning both results (and concatenating remaining goals). *) let divide (n:int) (l : unit -> Tac 'a) (r : unit -> Tac 'b) : Tac ('a * 'b) = if n < 0 then fail "divide: negative n"; let gs, sgs = goals (), smt_goals () in let gs1, gs2 = List.Tot.Base.splitAt n gs in set_goals gs1; set_smt_goals []; let x = l () in let gsl, sgsl = goals (), smt_goals () in set_goals gs2; set_smt_goals []; let y = r () in let gsr, sgsr = goals (), smt_goals () in set_goals (gsl @ gsr); set_smt_goals (sgs @ sgsl @ sgsr); (x, y) let rec iseq (ts : list (unit -> Tac unit)) : Tac unit = match ts with | t::ts -> let _ = divide 1 t (fun () -> iseq ts) in () | [] -> () (** [focus t] runs [t ()] on the current active goal, hiding all others and restoring them at the end. *) let focus (t : unit -> Tac 'a) : Tac 'a = match goals () with | [] -> fail "focus: no goals" | g::gs -> let sgs = smt_goals () in set_goals [g]; set_smt_goals []; let x = t () in set_goals (goals () @ gs); set_smt_goals (smt_goals () @ sgs); x (** Similar to [dump], but only dumping the current goal. *) let dump1 (m : string) = focus (fun () -> dump m) let rec mapAll (t : unit -> Tac 'a) : Tac (list 'a) = match goals () with | [] -> [] | _::_ -> let (h, t) = divide 1 t (fun () -> mapAll t) in h::t let rec iterAll (t : unit -> Tac unit) : Tac unit = (* Could use mapAll, but why even build that list *) match goals () with | [] -> () | _::_ -> let _ = divide 1 t (fun () -> iterAll t) in () let iterAllSMT (t : unit -> Tac unit) : Tac unit = let gs, sgs = goals (), smt_goals () in set_goals sgs; set_smt_goals []; iterAll t; let gs', sgs' = goals (), smt_goals () in set_goals gs; set_smt_goals (gs'@sgs') (** Runs tactic [t1] on the current goal, and then tactic [t2] on *each* subgoal produced by [t1]. Each invocation of [t2] runs on a proofstate with a single goal (they're "focused"). *) let seq (f : unit -> Tac unit) (g : unit -> Tac unit) : Tac unit = focus (fun () -> f (); iterAll g) let exact_args (qs : list aqualv) (t : term) : Tac unit = focus (fun () -> let n = List.Tot.Base.length qs in let uvs = repeatn n (fun () -> fresh_uvar None) in let t' = mk_app t (zip uvs qs) in exact t'; iter (fun uv -> if is_uvar uv then unshelve uv else ()) (L.rev uvs) ) let exact_n (n : int) (t : term) : Tac unit = exact_args (repeatn n (fun () -> Q_Explicit)) t (** [ngoals ()] returns the number of goals *) let ngoals () : Tac int = List.Tot.Base.length (goals ()) (** [ngoals_smt ()] returns the number of SMT goals *) let ngoals_smt () : Tac int = List.Tot.Base.length (smt_goals ()) (* sigh GGG fix names!! *) let fresh_namedv_named (s:string) : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal s; sort = seal (pack Tv_Unknown); uniq = n; }) (* Create a fresh bound variable (bv), using a generic name. See also [fresh_namedv_named]. *) let fresh_namedv () : Tac namedv = let n = fresh () in pack_namedv ({ ppname = seal ("x" ^ string_of_int n); sort = seal (pack Tv_Unknown); uniq = n; }) let fresh_binder_named (s : string) (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal s; sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_binder (t : typ) : Tac simple_binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Explicit; attrs = [] ; } let fresh_implicit_binder (t : typ) : Tac binder = let n = fresh () in { ppname = seal ("x" ^ string_of_int n); sort = t; uniq = n; qual = Q_Implicit; attrs = [] ; } let guard (b : bool) : TacH unit (requires (fun _ -> True)) (ensures (fun ps r -> if b then Success? r /\ Success?.ps r == ps else Failed? r)) (* ^ the proofstate on failure is not exactly equal (has the psc set) *) = if not b then fail "guard failed" else () let try_with (f : unit -> Tac 'a) (h : exn -> Tac 'a) : Tac 'a = match catch f with | Inl e -> h e | Inr x -> x let trytac (t : unit -> Tac 'a) : Tac (option 'a) = try Some (t ()) with | _ -> None let or_else (#a:Type) (t1 : unit -> Tac a) (t2 : unit -> Tac a) : Tac a = try t1 () with | _ -> t2 () val (<|>) : (unit -> Tac 'a) -> (unit -> Tac 'a) -> (unit -> Tac 'a) let (<|>) t1 t2 = fun () -> or_else t1 t2 let first (ts : list (unit -> Tac 'a)) : Tac 'a = L.fold_right (<|>) ts (fun () -> fail "no tactics to try") () let rec repeat (#a:Type) (t : unit -> Tac a) : Tac (list a) = match catch t with | Inl _ -> [] | Inr x -> x :: repeat t let repeat1 (#a:Type) (t : unit -> Tac a) : Tac (list a) = t () :: repeat t let repeat' (f : unit -> Tac 'a) : Tac unit = let _ = repeat f in () let norm_term (s : list norm_step) (t : term) : Tac term = let e = try cur_env () with | _ -> top_env () in norm_term_env e s t (** Join all of the SMT goals into one. This helps when all of them are expected to be similar, and therefore easier to prove at once by the SMT solver. TODO: would be nice to try to join them in a more meaningful way, as the order can matter. *) let join_all_smt_goals () = let gs, sgs = goals (), smt_goals () in set_smt_goals []; set_goals sgs; repeat' join; let sgs' = goals () in // should be a single one set_goals gs; set_smt_goals sgs' let discard (tau : unit -> Tac 'a) : unit -> Tac unit = fun () -> let _ = tau () in () // TODO: do we want some value out of this? let rec repeatseq (#a:Type) (t : unit -> Tac a) : Tac unit = let _ = trytac (fun () -> (discard t) `seq` (discard (fun () -> repeatseq t))) in () let tadmit () = tadmit_t (`()) let admit1 () : Tac unit = tadmit () let admit_all () : Tac unit = let _ = repeat tadmit in () (** [is_guard] returns whether the current goal arose from a typechecking guard *) let is_guard () : Tac bool = Tactics.Types.is_guard (_cur_goal ()) let skip_guard () : Tac unit = if is_guard () then smt () else fail "" let guards_to_smt () : Tac unit = let _ = repeat skip_guard in () let simpl () : Tac unit = norm [simplify; primops] let whnf () : Tac unit = norm [weak; hnf; primops; delta] let compute () : Tac unit = norm [primops; iota; delta; zeta] let intros () : Tac (list binding) = repeat intro let intros' () : Tac unit = let _ = intros () in () let destruct tm : Tac unit = let _ = t_destruct tm in () let destruct_intros tm : Tac unit = seq (fun () -> let _ = t_destruct tm in ()) intros' private val __cut : (a:Type) -> (b:Type) -> (a -> b) -> a -> b private let __cut a b f x = f x let tcut (t:term) : Tac binding = let g = cur_goal () in let tt = mk_e_app (`__cut) [t; g] in apply tt; intro () let pose (t:term) : Tac binding = apply (`__cut); flip (); exact t; intro () let intro_as (s:string) : Tac binding = let b = intro () in rename_to b s let pose_as (s:string) (t:term) : Tac binding = let b = pose t in rename_to b s let for_each_binding (f : binding -> Tac 'a) : Tac (list 'a) = map f (cur_vars ()) let rec revert_all (bs:list binding) : Tac unit = match bs with | [] -> () | _::tl -> revert (); revert_all tl let binder_sort (b : binder) : Tot typ = b.sort // Cannot define this inside `assumption` due to #1091 private let rec __assumption_aux (xs : list binding) : Tac unit = match xs with | [] -> fail "no assumption matches goal" | b::bs -> try exact b with | _ -> try (apply (`FStar.Squash.return_squash); exact b) with | _ -> __assumption_aux bs let assumption () : Tac unit = __assumption_aux (cur_vars ())
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val destruct_equality_implication (t: term) : Tac (option (formula * term))
[]
FStar.Tactics.V2.Derived.destruct_equality_implication
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
t: FStar.Tactics.NamedView.term -> FStar.Tactics.Effect.Tac (FStar.Pervasives.Native.option (FStar.Reflection.V2.Formula.formula * FStar.Tactics.NamedView.term))
{ "end_col": 15, "end_line": 595, "start_col": 4, "start_line": 588 }
FStar.Tactics.Effect.Tac
val name_of_bv (bv: bv) : Tac string
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname)
val name_of_bv (bv: bv) : Tac string let name_of_bv (bv: bv) : Tac string =
true
null
false
unseal ((inspect_bv bv).ppname)
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "FStar.Tactics.NamedView.bv", "FStar.Tactics.Unseal.unseal", "Prims.string", "FStar.Reflection.V2.Data.__proj__Mkbv_view__item__ppname", "FStar.Tactics.NamedView.inspect_bv" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val name_of_bv (bv: bv) : Tac string
[]
FStar.Tactics.V2.Derived.name_of_bv
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
bv: FStar.Tactics.NamedView.bv -> FStar.Tactics.Effect.Tac Prims.string
{ "end_col": 35, "end_line": 35, "start_col": 4, "start_line": 35 }
FStar.Tactics.Effect.Tac
val type_of_var (x: namedv) : Tac typ
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort)
val type_of_var (x: namedv) : Tac typ let type_of_var (x: namedv) : Tac typ =
true
null
false
unseal ((inspect_namedv x).sort)
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "FStar.Tactics.NamedView.namedv", "FStar.Tactics.Unseal.unseal", "FStar.Reflection.Types.typ", "FStar.Reflection.V2.Data.__proj__Mknamedv_view__item__sort", "FStar.Tactics.NamedView.inspect_namedv" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val type_of_var (x: namedv) : Tac typ
[]
FStar.Tactics.V2.Derived.type_of_var
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: FStar.Tactics.NamedView.namedv -> FStar.Tactics.Effect.Tac FStar.Reflection.Types.typ
{ "end_col": 34, "end_line": 52, "start_col": 2, "start_line": 52 }
Prims.Tot
val type_of_binding (x: binding) : Tot typ
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let type_of_binding (x : binding) : Tot typ = x.sort
val type_of_binding (x: binding) : Tot typ let type_of_binding (x: binding) : Tot typ =
false
null
false
x.sort
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[ "total" ]
[ "FStar.Tactics.NamedView.binding", "FStar.Reflection.V2.Data.__proj__Mkbinding__item__sort", "FStar.Reflection.Types.typ" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort)
false
true
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val type_of_binding (x: binding) : Tot typ
[]
FStar.Tactics.V2.Derived.type_of_binding
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: FStar.Tactics.NamedView.binding -> FStar.Reflection.Types.typ
{ "end_col": 8, "end_line": 55, "start_col": 2, "start_line": 55 }
FStar.Tactics.Effect.Tac
val bv_to_string (bv: bv) : Tac string
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv
val bv_to_string (bv: bv) : Tac string let bv_to_string (bv: bv) : Tac string =
true
null
false
name_of_bv bv
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "FStar.Tactics.NamedView.bv", "FStar.Tactics.V2.Derived.name_of_bv", "Prims.string" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string =
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bv_to_string (bv: bv) : Tac string
[]
FStar.Tactics.V2.Derived.bv_to_string
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
bv: FStar.Tactics.NamedView.bv -> FStar.Tactics.Effect.Tac Prims.string
{ "end_col": 17, "end_line": 39, "start_col": 4, "start_line": 39 }
FStar.Tactics.Effect.Tac
val trefl: Prims.unit -> Tac unit
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let trefl () : Tac unit = t_trefl false
val trefl: Prims.unit -> Tac unit let trefl () : Tac unit =
true
null
false
t_trefl false
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "Prims.unit", "FStar.Tactics.V2.Builtins.t_trefl" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *) let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!" (** [debug str] is similar to [print str], but will only print the message if the [--debug] option was given for the current module AND [--debug_level Tac] is on. *) let debug (m:string) : Tac unit = if debugging () then print m (** [smt] will mark the current goal for being solved through the SMT. This does not immediately run the SMT: it just dumps the goal in the SMT bin. Note, if you dump a proof-relevant goal there, the engine will later raise an error. *) let smt () : Tac unit = match goals (), smt_goals () with | [], _ -> fail "smt: no active goals" | g::gs, gs' -> begin set_goals gs; set_smt_goals (g :: gs') end let idtac () : Tac unit = () (** Push the current goal to the back. *) let later () : Tac unit = match goals () with | g::gs -> set_goals (gs @ [g]) | _ -> fail "later: no goals" (** [apply f] will attempt to produce a solution to the goal by an application of [f] to any amount of arguments (which need to be solved as further goals). The amount of arguments introduced is the least such that [f a_i] unifies with the goal's type. *) let apply (t : term) : Tac unit = t_apply true false false t let apply_noinst (t : term) : Tac unit = t_apply true true false t (** [apply_lemma l] will solve a goal of type [squash phi] when [l] is a Lemma ensuring [phi]. The arguments to [l] and its requires clause are introduced as new goals. As a small optimization, [unit] arguments are discharged by the engine. Just a thin wrapper around [t_apply_lemma]. *) let apply_lemma (t : term) : Tac unit = t_apply_lemma false false t (** See docs for [t_trefl] *)
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val trefl: Prims.unit -> Tac unit
[]
FStar.Tactics.V2.Derived.trefl
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 15, "end_line": 196, "start_col": 2, "start_line": 196 }
FStar.Tactics.Effect.Tac
val qed: Prims.unit -> Tac unit
[ { "abbrev": true, "full_module": "FStar.Tactics.Visit", "short_module": "V" }, { "abbrev": true, "full_module": "FStar.List.Tot.Base", "short_module": "L" }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxCoercions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.NamedView", "short_module": null }, { "abbrev": false, "full_module": "FStar.VConfig", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.SyntaxHelpers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Result", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Formula", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let qed () : Tac unit = match goals () with | [] -> () | _ -> fail "qed: not done!"
val qed: Prims.unit -> Tac unit let qed () : Tac unit =
true
null
false
match goals () with | [] -> () | _ -> fail "qed: not done!"
{ "checked_file": "FStar.Tactics.V2.Derived.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.VConfig.fsti.checked", "FStar.Tactics.Visit.fst.checked", "FStar.Tactics.V2.SyntaxHelpers.fst.checked", "FStar.Tactics.V2.SyntaxCoercions.fst.checked", "FStar.Tactics.V2.Builtins.fsti.checked", "FStar.Tactics.Util.fst.checked", "FStar.Tactics.Types.fsti.checked", "FStar.Tactics.Result.fsti.checked", "FStar.Tactics.NamedView.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Reflection.V2.Formula.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Range.fsti.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.V2.Derived.fst" }
[]
[ "Prims.unit", "Prims.list", "FStar.Tactics.Types.goal", "FStar.Tactics.V2.Derived.fail", "FStar.Tactics.V2.Derived.goals" ]
[]
(* 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.V2.Derived open FStar.Reflection.V2 open FStar.Reflection.V2.Formula open FStar.Tactics.Types open FStar.Tactics.Effect open FStar.Tactics.V2.Builtins open FStar.Tactics.Result open FStar.Tactics.Util open FStar.Tactics.V2.SyntaxHelpers open FStar.VConfig open FStar.Tactics.NamedView open FStar.Tactics.V2.SyntaxCoercions module L = FStar.List.Tot.Base module V = FStar.Tactics.Visit private let (@) = L.op_At let name_of_bv (bv : bv) : Tac string = unseal ((inspect_bv bv).ppname) let bv_to_string (bv : bv) : Tac string = (* Could also print type...? *) name_of_bv bv let name_of_binder (b : binder) : Tac string = unseal b.ppname let binder_to_string (b : binder) : Tac string = // TODO: print aqual, attributes..? or no? name_of_binder b ^ "@@" ^ string_of_int b.uniq ^ "::(" ^ term_to_string b.sort ^ ")" let binding_to_string (b : binding) : Tac string = unseal b.ppname let type_of_var (x : namedv) : Tac typ = unseal ((inspect_namedv x).sort) let type_of_binding (x : binding) : Tot typ = x.sort exception Goal_not_trivial let goals () : Tac (list goal) = goals_of (get ()) let smt_goals () : Tac (list goal) = smt_goals_of (get ()) let fail (#a:Type) (m:string) : TAC a (fun ps post -> post (Failed (TacticFailure m) ps)) = raise #a (TacticFailure m) let fail_silently (#a:Type) (m:string) : TAC a (fun _ post -> forall ps. post (Failed (TacticFailure m) ps)) = set_urgency 0; raise #a (TacticFailure m) (** Return the current *goal*, not its type. (Ignores SMT goals) *) let _cur_goal () : Tac goal = match goals () with | [] -> fail "no more goals" | g::_ -> g (** [cur_env] returns the current goal's environment *) let cur_env () : Tac env = goal_env (_cur_goal ()) (** [cur_goal] returns the current goal's type *) let cur_goal () : Tac typ = goal_type (_cur_goal ()) (** [cur_witness] returns the current goal's witness *) let cur_witness () : Tac term = goal_witness (_cur_goal ()) (** [cur_goal_safe] will always return the current goal, without failing. It must be statically verified that there indeed is a goal in order to call it. *) let cur_goal_safe () : TacH goal (requires (fun ps -> ~(goals_of ps == []))) (ensures (fun ps0 r -> exists g. r == Success g ps0)) = match goals_of (get ()) with | g :: _ -> g let cur_vars () : Tac (list binding) = vars_of_env (cur_env ()) (** Set the guard policy only locally, without affecting calling code *) let with_policy pol (f : unit -> Tac 'a) : Tac 'a = let old_pol = get_guard_policy () in set_guard_policy pol; let r = f () in set_guard_policy old_pol; r (** [exact e] will solve a goal [Gamma |- w : t] if [e] has type exactly [t] in [Gamma]. *) let exact (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true false t) (** [exact_with_ref e] will solve a goal [Gamma |- w : t] if [e] has type [t'] where [t'] is a subtype of [t] in [Gamma]. This is a more flexible variant of [exact]. *) let exact_with_ref (t : term) : Tac unit = with_policy SMT (fun () -> t_exact true true t) let trivial () : Tac unit = norm [iota; zeta; reify_; delta; primops; simplify; unmeta]; let g = cur_goal () in match term_as_formula g with | True_ -> exact (`()) | _ -> raise Goal_not_trivial (* Another hook to just run a tactic without goals, just by reusing `with_tactic` *) let run_tactic (t:unit -> Tac unit) : Pure unit (requires (set_range_of (with_tactic (fun () -> trivial (); t ()) (squash True)) (range_of t))) (ensures (fun _ -> True)) = () (** Ignore the current goal. If left unproven, this will fail after the tactic finishes. *) let dismiss () : Tac unit = match goals () with | [] -> fail "dismiss: no more goals" | _::gs -> set_goals gs (** Flip the order of the first two goals. *) let flip () : Tac unit = let gs = goals () in match goals () with | [] | [_] -> fail "flip: less than two goals" | g1::g2::gs -> set_goals (g2::g1::gs) (** Succeed if there are no more goals left, and fail otherwise. *)
false
false
FStar.Tactics.V2.Derived.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val qed: Prims.unit -> Tac unit
[]
FStar.Tactics.V2.Derived.qed
{ "file_name": "ulib/FStar.Tactics.V2.Derived.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 32, "end_line": 148, "start_col": 4, "start_line": 146 }