file_name
stringlengths
5
52
name
stringlengths
4
95
original_source_type
stringlengths
0
23k
source_type
stringlengths
9
23k
source_definition
stringlengths
9
57.9k
source
dict
source_range
dict
file_context
stringlengths
0
721k
dependencies
dict
opens_and_abbrevs
listlengths
2
94
vconfig
dict
interleaved
bool
1 class
verbose_type
stringlengths
1
7.42k
effect
stringclasses
118 values
effect_flags
sequencelengths
0
2
mutual_with
sequencelengths
0
11
ideal_premises
sequencelengths
0
236
proof_features
sequencelengths
0
1
is_simple_lemma
bool
2 classes
is_div
bool
2 classes
is_proof
bool
2 classes
is_simply_typed
bool
2 classes
is_type
bool
2 classes
partial_definition
stringlengths
5
3.99k
completed_definiton
stringlengths
1
1.63M
isa_cross_project_example
bool
1 class
Vale.Lib.Seqs.fst
Vale.Lib.Seqs.reveal_opaque_rec
val reveal_opaque_rec : s: Prims.string -> x: _ -> FStar.Pervasives.Lemma (ensures FStar.Pervasives.norm [FStar.Pervasives.zeta; FStar.Pervasives.delta_only [s]] x == x)
let reveal_opaque_rec (s:string) = norm_spec [zeta; delta_only [s]]
{ "file_name": "vale/code/lib/collections/Vale.Lib.Seqs.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 67, "end_line": 93, "start_col": 0, "start_line": 93 }
module Vale.Lib.Seqs open FStar.Mul let lemma_slice_first_exactly_in_append (#a:Type) (x y:seq a) : Lemma (slice (append x y) 0 (length x) == x) = let xy = append x y in let xy_slice = slice xy 0 (length x) in let x_slice = slice x 0 (length x) in assert(equal xy_slice x_slice); // OBSERVE: extensionality () let lemma_all_but_last_append (#t:Type) (a:seq t) (b:seq t{length b > 0}) : Lemma (all_but_last (append a b) == append a (all_but_last b)) = let ab = all_but_last (append a b) in let app_a_b = append a (all_but_last b) in assert (equal ab app_a_b) // OBSERVE: extensionality let reverse_seq_append (#a:eqtype) (s:seq a) (t:seq a) : Lemma(ensures reverse_seq (append s t) == append (reverse_seq t) (reverse_seq s)) = assert (equal (reverse_seq (append s t)) (append (reverse_seq t) (reverse_seq s))) let reverse_reverse_seq (#a:Type) (s:seq a) : Lemma(ensures reverse_seq (reverse_seq s) == s) = assert (equal (reverse_seq (reverse_seq s)) s) let rec seq_map_i_indexed (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) (i:int) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f (i + j) (index s j)) }) (decreases %[(length s)]) = if length s = 0 then empty else cons (f i (head s)) (seq_map_i_indexed f (tail s) (i + 1)) let seq_map_i (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f j (index s j)) }) = seq_map_i_indexed f s 0 let seq_map_internal_associative (#a:Type) (#b:eqtype) (f:int->a->b) (s:seq a) (pivot:int{0 <= pivot /\ pivot < length s}) : Lemma (let left,right = split s pivot in seq_map_i f s == seq_map_i_indexed f left 0 @| seq_map_i_indexed f right pivot ) = let left,right = split s pivot in let full_map = seq_map_i f s in let part1 = seq_map_i_indexed f left 0 in let part2 = seq_map_i_indexed f right pivot in assert (equal (seq_map_i f s) (seq_map_i_indexed f left 0 @| seq_map_i_indexed f right pivot)); () let seq_map_inverses (#a #b:Type) (f:a -> b) (g:b -> a) (s:seq a) : Lemma (requires forall x . g (f x) == x) (ensures seq_map g (seq_map f s) == s) = let mid = seq_map f s in let final = seq_map g mid in assert (equal s final); () let slice_append_adds (#a:Type) (s:seq a) (i:nat) (j:nat{ i <= j /\ j <= length s }) : Lemma (slice s 0 i @| slice s i j == slice s 0 j) = assert (equal (slice s 0 i @| slice s i j) (slice s 0 j)); () let slice_seq_map_commute (#a #b:Type) (f:a -> b) (s:seq a) (i:nat) (j:nat{ i <= j /\ j <= length s }) : Lemma (slice (seq_map f s) i j == seq_map f (slice s i j)) = assert (equal (slice (seq_map f s) i j) (seq_map f (slice s i j))); () let append_distributes_seq_map (#a #b:Type) (f:a -> b) (s1 s2:seq a) : Lemma (seq_map f (s1 @| s2) == seq_map f s1 @| seq_map f s2) = assert (equal (seq_map f (s1 @| s2)) (seq_map f s1 @| seq_map f s2)); () let seq_map_injective #a #b f s s' = assert (forall (i:nat).{:pattern index s i} i < length s ==> index (seq_map f s) i == f (index s i)); assert (forall (i:nat).{:pattern index s i} i < length s ==> index (seq_map f s') i == f (index s' i)); assert (equal s s') let list_to_seq #a l = Seq.seq_of_list l
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Lib.Seqs.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: Prims.string -> x: _ -> FStar.Pervasives.Lemma (ensures FStar.Pervasives.norm [FStar.Pervasives.zeta; FStar.Pervasives.delta_only [s]] x == x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.string", "FStar.Pervasives.norm_spec", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.zeta", "FStar.Pervasives.delta_only", "Prims.Nil", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.Pervasives.norm", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let reveal_opaque_rec (s: string) =
norm_spec [zeta; delta_only [s]]
false
Tutorial.fst
Tutorial.tau3
val tau3: Prims.unit -> Tac unit
val tau3: Prims.unit -> Tac unit
let tau3 () : Tac unit = Tactics.split (); smt (); trivial ()
{ "file_name": "examples/tactics/Tutorial.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 12, "end_line": 112, "start_col": 0, "start_line": 109 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Tutorial /// This file presents a walkthrough of the tactics engine in its current /// (July 23rd, 2017) state. It is mostly aimed at users and power users, leaving /// some details about the implementation out of this. open FStar.Tactics.V2 open FStar.List /// **First, what are tactics supposed to be?** /// /// In other dependently-typed theorem provers, they are a way to construct /// (or find) proofs automatically, which can be very tedious. Take a /// goal such as ``a + (b + c) == (c + a) + b``: we can get a proofterm for /// it by applying and composing associativity and commutativity lemmas. /// However, this proofterm is very dependent on the exact goal we're /// trying to prove: any change to the goal will require a change to the /// proof. This is annoying, since no real insight is required for the /// proof. Tactics provide an extensible way to automate these kind of /// proofs, improving robustness of proofs and the user's sanity. In one /// way or another, tactics reflect on the goal they have been called on, /// possibly inspecting the local and global environments, and implement /// a custom behaviour to construct such proof. In the previous example, /// one possibility for a tactic is shuffling the summands on each side /// following some well-defined order, a totally automatable process. /// /// You might be thinking: "doesn't F* already have an SMT solver backend /// for this reason?". Yes, but this does not at all negate the need for /// more automation in proofs. One could want to not call the SMT and stay /// only within F*, or to break down a proof obligation into more manageable /// chunks for the SMT, or even to simply change some SMT options or its /// environment for different subgoals. The main goal is to get more robust /// and faster proofs. /// /// On the other side of the Curry-Howard isomorphism, tactics can also /// be used to construct arbitrary terms, and not necessarily proofs. /// In this sense, they enable "metaprogramming" such as automatically /// generating printers for datatypes, recursors, or for whatever crazy /// boilerplate-like thing you want to do. We can also benefit from that in /// F*. /// /// So, enough talk, **what's the hello world of tactics?** /// The entry point for *proving* in tactics is `assert_by_tactic`, /// which takes a tactic to be run on the goal to prove. val ex1 : unit -> Lemma True let ex1 () = assert_by_tactic True idtac /// Here, ``idtac`` is the identity tactic, which does nothing. Certainly, /// ``True`` is a simple enough goal so this example succeeds. In between, the /// tactic is running with `True` as a goal, in the “logical environment” /// where we need to do the proof. Running the following example will cause /// the exact “proofstate” where the tactic runs to be printed in the /// standard output. val ex2 : unit -> Lemma True let ex2 () = assert_by_tactic True (fun () -> dump "Example 2") /// This yields the following:: /// /// Goal 1/1 /// uu___: unit /// p: pure_post unit /// ---------------------- /// squash l_True /// (*?u18*) _ uu___6626 p /// The output shows that we have only one “active” goal (that we're still working /// on) and no goals that have been already dispatched to the SMT. /// /// Concretely, to prove `True`, the engine is asking us to provide a term /// of type `squash True`. Squashing is the way we do proof-irrelevance in F*, /// and you can simply think of the type `squash phi` as the type of irrelevant /// proofs of `phi`. We call goals that are squashed “irrelevant”. /// .. note:: /// /// For experts: You might notice that ``True`` is already a squash (of /// ``trivial``), so this seems useless. In this case it is, but we squash /// nevertheless for consistency since this might be not so. /// A tactic is not required to completely prove an assertion, and can leave /// any number of goals unsolved, which will be fed to the SMT. Importantly, /// this can only be done on irrelevant goals, as the SMT does not produce /// proof terms! /// As expected, we can also manipulate logical formulas. There is a derived set of /// tactics (FStar.Tactics.Logical) simplifying this task, which is somewhat /// complicated due to squashing. Let's write a tactic to split a conjunction /// and solve one of its subformulas.
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Tutorial.fst" }
[ { "abbrev": false, "full_module": "FStar.List", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.unit", "FStar.Tactics.V2.Derived.trivial", "FStar.Tactics.V2.Derived.smt", "FStar.Tactics.V1.Logic.split" ]
[]
false
true
false
false
false
let tau3 () : Tac unit =
Tactics.split (); smt (); trivial ()
false
FStar.ImmutableArray.fsti
FStar.ImmutableArray.elem_precedes
val elem_precedes (#a: Type u#a) (s: t a) (i: nat{i < length s}) : Lemma (index s i << s)
val elem_precedes (#a: Type u#a) (s: t a) (i: nat{i < length s}) : Lemma (index s i << s)
let elem_precedes (#a:Type u#a) (s:t a) (i : nat{i < length s}) : Lemma (index s i << s) = FStar.List.Tot.( to_list_precedes s; let l = to_list s in assert (memP (index l i) l); memP_precedes (index l i) l )
{ "file_name": "ulib/FStar.ImmutableArray.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 5, "end_line": 81, "start_col": 0, "start_line": 74 }
(* Copyright 2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Authors: N. Swamy *) (* This module provides a primitive type of immutable arrays, implemented in OCaml by an array. The main intended usage of this module, as suggested by Jay Lorch, is to provide a sequence-like type with constant-time random access of elements, as opposed to FStar.Seq and related types, which provide only linear time access. Both the F* normalizer and NBE engine are aware of this type and reduce its three functions, `of_list`, `length`, and `index`, by invoking the corresponding operations on the underlying OCaml array that represents a `t`. See tests/micro-benchmarks/TestImmutableArray.fst for some samples And also FStar.ImmutableArray, which includes this interface and augments it with various properties of the functions below. *) module FStar.ImmutableArray include FStar.ImmutableArray.Base (* Converting an immutable array back to a list *) val to_list (#a:Type u#a) (s:t a) : Tot (list a) (* to_list is the inverse of of_list *) val to_list_of_list (#a:Type u#a) (l:list a) : Lemma (to_list (of_list l) == l) [SMTPat (of_list l)] (* of_list is the inverse of to_list *) val of_list_to_list (#a:Type u#a) (s:t a) : Lemma (of_list (to_list s) == s) (* The length of an immutable array is the length of its corresponding list *) val length_spec (#a:Type u#a) (s:t a) : Lemma (length s == FStar.List.Tot.length (to_list s)) [SMTPat (length s)] (* The indexes of an immutable array are in correspondence with its underling list *) val index_spec (#a:Type u#a) (s:t a) (i:nat{ i < length s }) : Lemma (index s i == FStar.List.Tot.index (to_list s) i) [SMTPat (index s i)] (* The list of elements precedes the array.*) val to_list_precedes (#a:Type u#a) (s:t a) : Lemma (to_list s << s) (* Idem. *) let of_list_precedes (#a:Type u#a) (l:list a) : Lemma (l << of_list l) = to_list_precedes (of_list l)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.ImmutableArray.Base.fsti.checked" ], "interface_file": false, "source_file": "FStar.ImmutableArray.fsti" }
[ { "abbrev": false, "full_module": "FStar.ImmutableArray.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.ImmutableArray.Base.t a -> i: Prims.nat{i < FStar.ImmutableArray.Base.length s} -> FStar.Pervasives.Lemma (ensures FStar.ImmutableArray.Base.index s i << s)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.ImmutableArray.Base.t", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.ImmutableArray.Base.length", "FStar.List.Tot.Properties.memP_precedes", "FStar.List.Tot.Base.index", "Prims.unit", "Prims._assert", "FStar.List.Tot.Base.memP", "Prims.list", "FStar.ImmutableArray.to_list", "FStar.ImmutableArray.to_list_precedes", "Prims.l_True", "Prims.squash", "Prims.precedes", "FStar.ImmutableArray.Base.index", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let elem_precedes (#a: Type u#a) (s: t a) (i: nat{i < length s}) : Lemma (index s i << s) =
let open FStar.List.Tot in to_list_precedes s; let l = to_list s in assert (memP (index l i) l); memP_precedes (index l i) l
false
Tutorial.fst
Tutorial.is_conj
val is_conj: Prims.unit -> Tac bool
val is_conj: Prims.unit -> Tac bool
let is_conj () : Tac bool = let g = cur_goal () in match term_as_formula g with | And _ _ -> true | _ -> false
{ "file_name": "examples/tactics/Tutorial.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 20, "end_line": 168, "start_col": 0, "start_line": 164 }
(* 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 Tutorial /// This file presents a walkthrough of the tactics engine in its current /// (July 23rd, 2017) state. It is mostly aimed at users and power users, leaving /// some details about the implementation out of this. open FStar.Tactics.V2 open FStar.List /// **First, what are tactics supposed to be?** /// /// In other dependently-typed theorem provers, they are a way to construct /// (or find) proofs automatically, which can be very tedious. Take a /// goal such as ``a + (b + c) == (c + a) + b``: we can get a proofterm for /// it by applying and composing associativity and commutativity lemmas. /// However, this proofterm is very dependent on the exact goal we're /// trying to prove: any change to the goal will require a change to the /// proof. This is annoying, since no real insight is required for the /// proof. Tactics provide an extensible way to automate these kind of /// proofs, improving robustness of proofs and the user's sanity. In one /// way or another, tactics reflect on the goal they have been called on, /// possibly inspecting the local and global environments, and implement /// a custom behaviour to construct such proof. In the previous example, /// one possibility for a tactic is shuffling the summands on each side /// following some well-defined order, a totally automatable process. /// /// You might be thinking: "doesn't F* already have an SMT solver backend /// for this reason?". Yes, but this does not at all negate the need for /// more automation in proofs. One could want to not call the SMT and stay /// only within F*, or to break down a proof obligation into more manageable /// chunks for the SMT, or even to simply change some SMT options or its /// environment for different subgoals. The main goal is to get more robust /// and faster proofs. /// /// On the other side of the Curry-Howard isomorphism, tactics can also /// be used to construct arbitrary terms, and not necessarily proofs. /// In this sense, they enable "metaprogramming" such as automatically /// generating printers for datatypes, recursors, or for whatever crazy /// boilerplate-like thing you want to do. We can also benefit from that in /// F*. /// /// So, enough talk, **what's the hello world of tactics?** /// The entry point for *proving* in tactics is `assert_by_tactic`, /// which takes a tactic to be run on the goal to prove. val ex1 : unit -> Lemma True let ex1 () = assert_by_tactic True idtac /// Here, ``idtac`` is the identity tactic, which does nothing. Certainly, /// ``True`` is a simple enough goal so this example succeeds. In between, the /// tactic is running with `True` as a goal, in the “logical environment” /// where we need to do the proof. Running the following example will cause /// the exact “proofstate” where the tactic runs to be printed in the /// standard output. val ex2 : unit -> Lemma True let ex2 () = assert_by_tactic True (fun () -> dump "Example 2") /// This yields the following:: /// /// Goal 1/1 /// uu___: unit /// p: pure_post unit /// ---------------------- /// squash l_True /// (*?u18*) _ uu___6626 p /// The output shows that we have only one “active” goal (that we're still working /// on) and no goals that have been already dispatched to the SMT. /// /// Concretely, to prove `True`, the engine is asking us to provide a term /// of type `squash True`. Squashing is the way we do proof-irrelevance in F*, /// and you can simply think of the type `squash phi` as the type of irrelevant /// proofs of `phi`. We call goals that are squashed “irrelevant”. /// .. note:: /// /// For experts: You might notice that ``True`` is already a squash (of /// ``trivial``), so this seems useless. In this case it is, but we squash /// nevertheless for consistency since this might be not so. /// A tactic is not required to completely prove an assertion, and can leave /// any number of goals unsolved, which will be fed to the SMT. Importantly, /// this can only be done on irrelevant goals, as the SMT does not produce /// proof terms! /// As expected, we can also manipulate logical formulas. There is a derived set of /// tactics (FStar.Tactics.Logical) simplifying this task, which is somewhat /// complicated due to squashing. Let's write a tactic to split a conjunction /// and solve one of its subformulas. let tau3 () : Tac unit = Tactics.split (); smt (); trivial () let ex3 (x : nat) = assert_by_tactic (x + x >= 0 /\ List.length [4;5;1] == 3) tau3 /// First, we defined tau3 as a custom tactic, composed by applying ``split``, /// ``smt`` and ``trivial`` in that order. The ``tactic 'a`` type is a monad, and /// this is F*'s version of do notation for it. /// /// The ``split`` tactic will destruct the original goal into its /// two conjuncts, creating two new goals. /// /// Try adding ``dump "After split";`` just after ``split`` above, and run that code again. Now we see the following:: /// /// After split /// Goal 1/2 /// x: nat /// ------------------- /// squash (x + x >= 0) /// (*?u58*) _ x /// Goal 2/2 /// x: nat /// ------------------------------ /// squash (length [4; 5; 1] == 3) /// (*?u59*) _ x /// /// Further tactic steps are applied to the first goal. For the first one, /// we want to just give it to the smt, so we call into the ``smt`` tactic, /// which always succeeds and marks a goal for SMT discharging. If we were /// to dump the proofstate here, we'd see the first goal was simply moved /// into the "SMT goals" set. /// /// The second conjunct one can be shown true simply by normalization, so we /// can call into the ``trivial`` tactic to take care of it internally. /// /// .. note:: /// /// There is currently no support for a "try SMT" tactic, which would /// return back control if the SMT solver cannot prove the goal. This /// requires some rework in how guards are discharged in F*. /// /// For an automation example, let's write a tactic that will split all /// top-level conjunctions in our goal, trying to discharge them if /// they're trivial. Importantly, we need to be able to inspect the goal /// we're trying to prove from *within* the tactic. This is done via the /// ``cur_goal`` primitive, which returns the goal as ``term``, a reflection of /// F*'s internal term representation. These ``term``\ s are actually opaque, /// and can only be meaningfully used through some *views* defined on them. /// Since we're dealing with a logical formula, the ``formula`` view is the /// most comfortable one. We can decide if our goal is a conjunction in the /// following way:
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Tutorial.fst" }
[ { "abbrev": false, "full_module": "FStar.List", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.bool
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.unit", "FStar.Tactics.NamedView.term", "FStar.Reflection.V2.Formula.formula", "Prims.bool", "FStar.Reflection.V2.Formula.term_as_formula", "FStar.Stubs.Reflection.Types.typ", "FStar.Tactics.V2.Derived.cur_goal" ]
[]
false
true
false
false
false
let is_conj () : Tac bool =
let g = cur_goal () in match term_as_formula g with | And _ _ -> true | _ -> false
false
Vale.Lib.Seqs.fst
Vale.Lib.Seqs.reverse_seq_append
val reverse_seq_append (#a:eqtype) (s:seq a) (t:seq a) : Lemma(ensures reverse_seq (append s t) == append (reverse_seq t) (reverse_seq s))
val reverse_seq_append (#a:eqtype) (s:seq a) (t:seq a) : Lemma(ensures reverse_seq (append s t) == append (reverse_seq t) (reverse_seq s))
let reverse_seq_append (#a:eqtype) (s:seq a) (t:seq a) : Lemma(ensures reverse_seq (append s t) == append (reverse_seq t) (reverse_seq s)) = assert (equal (reverse_seq (append s t)) (append (reverse_seq t) (reverse_seq s)))
{ "file_name": "vale/code/lib/collections/Vale.Lib.Seqs.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 84, "end_line": 21, "start_col": 0, "start_line": 18 }
module Vale.Lib.Seqs open FStar.Mul let lemma_slice_first_exactly_in_append (#a:Type) (x y:seq a) : Lemma (slice (append x y) 0 (length x) == x) = let xy = append x y in let xy_slice = slice xy 0 (length x) in let x_slice = slice x 0 (length x) in assert(equal xy_slice x_slice); // OBSERVE: extensionality () let lemma_all_but_last_append (#t:Type) (a:seq t) (b:seq t{length b > 0}) : Lemma (all_but_last (append a b) == append a (all_but_last b)) = let ab = all_but_last (append a b) in let app_a_b = append a (all_but_last b) in assert (equal ab app_a_b) // OBSERVE: extensionality
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Lib.Seqs.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.Seq.Base.seq a -> t: FStar.Seq.Base.seq a -> FStar.Pervasives.Lemma (ensures Vale.Lib.Seqs_s.reverse_seq (FStar.Seq.Base.append s t) == FStar.Seq.Base.append (Vale.Lib.Seqs_s.reverse_seq t) (Vale.Lib.Seqs_s.reverse_seq s))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.eqtype", "FStar.Seq.Base.seq", "Prims._assert", "FStar.Seq.Base.equal", "Vale.Lib.Seqs_s.reverse_seq", "FStar.Seq.Base.append", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let reverse_seq_append (#a: eqtype) (s t: seq a) : Lemma (ensures reverse_seq (append s t) == append (reverse_seq t) (reverse_seq s)) =
assert (equal (reverse_seq (append s t)) (append (reverse_seq t) (reverse_seq s)))
false
Vale.PPC64LE.InsBasic.fst
Vale.PPC64LE.InsBasic.va_wpProof_Sl64
val va_wpProof_Sl64 : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:va_operand_reg_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Sl64 dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Sl64 dst src1 src2) ([va_mod_reg_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
val va_wpProof_Sl64 : dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:va_operand_reg_opr -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Sl64 dst src1 src2 va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Sl64 dst src1 src2) ([va_mod_reg_opr dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
let va_wpProof_Sl64 dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_Sl64 (va_code_Sl64 dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "file_name": "obj/Vale.PPC64LE.InsBasic.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 22, "end_line": 708, "start_col": 0, "start_line": 702 }
module Vale.PPC64LE.InsBasic open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.Memory open Vale.PPC64LE.Stack_i friend Vale.PPC64LE.Decls module S = Vale.PPC64LE.Semantics_s //-- Move [@ "opaque_to_smt"] let va_code_Move dst src = (Ins (S.Move dst src)) [@ "opaque_to_smt"] let va_codegen_success_Move dst src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Move va_b0 va_s0 dst src = va_reveal_opaque (`%va_code_Move) (va_code_Move dst src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.Move dst src)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.Move dst src)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Move dst src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Move (va_code_Move dst src) va_s0 dst src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- LoadImm64 [@ "opaque_to_smt"] let va_code_LoadImm64 dst src = (Ins (S.LoadImm64 dst src)) [@ "opaque_to_smt"] let va_codegen_success_LoadImm64 dst src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_LoadImm64 va_b0 va_s0 dst src = va_reveal_opaque (`%va_code_LoadImm64) (va_code_LoadImm64 dst src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.LoadImm64 dst src)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.LoadImm64 dst src)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_LoadImm64 dst src va_s0 va_k = let (va_sM, va_f0) = va_lemma_LoadImm64 (va_code_LoadImm64 dst src) va_s0 dst src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- LoadImmShl64 [@ "opaque_to_smt"] let va_code_LoadImmShl64 dst src = (Ins (S.LoadImmShl64 dst src)) [@ "opaque_to_smt"] let va_codegen_success_LoadImmShl64 dst src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_LoadImmShl64 va_b0 va_s0 dst src = va_reveal_opaque (`%va_code_LoadImmShl64) (va_code_LoadImmShl64 dst src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.LoadImmShl64 dst src)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.LoadImmShl64 dst src)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_LoadImmShl64 dst src va_s0 va_k = let (va_sM, va_f0) = va_lemma_LoadImmShl64 (va_code_LoadImmShl64 dst src) va_s0 dst src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AddLa [@ "opaque_to_smt"] let va_code_AddLa dst src1 src2 = (Ins (S.AddLa dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_AddLa dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_AddLa va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_AddLa) (va_code_AddLa dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.AddLa dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.AddLa dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_AddLa dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_AddLa (va_code_AddLa dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Add [@ "opaque_to_smt"] let va_code_Add dst src1 src2 = (Ins (S.Add dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_Add dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Add va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_Add) (va_code_Add dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.Add dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.Add dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Add dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_Add (va_code_Add dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AddWrap [@ "opaque_to_smt"] let va_code_AddWrap dst src1 src2 = (Ins (S.Add dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_AddWrap dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_AddWrap va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_AddWrap) (va_code_AddWrap dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.Add dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.Add dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_AddWrap dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_AddWrap (va_code_AddWrap dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AddImm [@ "opaque_to_smt"] let va_code_AddImm dst src1 src2 = (Ins (S.AddImm dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_AddImm dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_AddImm va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_AddImm) (va_code_AddImm dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.AddImm dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.AddImm dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_AddImm dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_AddImm (va_code_AddImm dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AddImmWrap [@ "opaque_to_smt"] let va_code_AddImmWrap dst src1 src2 = (Ins (S.AddImm dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_AddImmWrap dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_AddImmWrap va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_AddImmWrap) (va_code_AddImmWrap dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.AddImm dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.AddImm dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_AddImmWrap dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_AddImmWrap (va_code_AddImmWrap dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AddCarry [@ "opaque_to_smt"] let va_code_AddCarry dst src1 src2 = (Ins (S.AddCarry dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_AddCarry dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_AddCarry va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_AddCarry) (va_code_AddCarry dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.AddCarry dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.AddCarry dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_AddCarry dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_AddCarry (va_code_AddCarry dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_xer va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0)))); va_lemma_norm_mods ([va_Mod_xer; va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AddExtended [@ "opaque_to_smt"] let va_code_AddExtended dst src1 src2 = (Ins (S.AddExtended dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_AddExtended dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_AddExtended va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_AddExtended) (va_code_AddExtended dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.AddExtended dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.AddExtended dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_AddExtended dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_AddExtended (va_code_AddExtended dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_xer va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0)))); va_lemma_norm_mods ([va_Mod_xer; va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AddExtendedOV [@ "opaque_to_smt"] let va_code_AddExtendedOV dst src1 src2 = (Ins (S.AddExtendedOV dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_AddExtendedOV dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_AddExtendedOV va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_AddExtendedOV) (va_code_AddExtendedOV dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.AddExtendedOV dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.AddExtendedOV dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_AddExtendedOV dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_AddExtendedOV (va_code_AddExtendedOV dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_xer va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0)))); va_lemma_norm_mods ([va_Mod_xer; va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Sub [@ "opaque_to_smt"] let va_code_Sub dst src1 src2 = (Ins (S.Sub dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_Sub dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Sub va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_Sub) (va_code_Sub dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.Sub dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.Sub dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Sub dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_Sub (va_code_Sub dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- SubWrap [@ "opaque_to_smt"] let va_code_SubWrap dst src1 src2 = (Ins (S.Sub dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_SubWrap dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_SubWrap va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_SubWrap) (va_code_SubWrap dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.Sub dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.Sub dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_SubWrap dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_SubWrap (va_code_SubWrap dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- SubImm [@ "opaque_to_smt"] let va_code_SubImm dst src1 src2 = (Ins (S.SubImm dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_SubImm dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_SubImm va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_SubImm) (va_code_SubImm dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.SubImm dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.SubImm dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_SubImm dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_SubImm (va_code_SubImm dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- SubImmWrap [@ "opaque_to_smt"] let va_code_SubImmWrap dst src1 src2 = (Ins (S.SubImm dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_SubImmWrap dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_SubImmWrap va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_SubImmWrap) (va_code_SubImmWrap dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.SubImm dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.SubImm dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_SubImmWrap dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_SubImmWrap (va_code_SubImmWrap dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- MulLow64 [@ "opaque_to_smt"] let va_code_MulLow64 dst src1 src2 = (Ins (S.MulLow64 dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_MulLow64 dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_MulLow64 va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_MulLow64) (va_code_MulLow64 dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.MulLow64 dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.MulLow64 dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_MulLow64 dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_MulLow64 (va_code_MulLow64 dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- MulLow64Wrap [@ "opaque_to_smt"] let va_code_MulLow64Wrap dst src1 src2 = (Ins (S.MulLow64 dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_MulLow64Wrap dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_MulLow64Wrap va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_MulLow64Wrap) (va_code_MulLow64Wrap dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.MulLow64 dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.MulLow64 dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_MulLow64Wrap dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_MulLow64Wrap (va_code_MulLow64Wrap dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- MulHigh64U [@ "opaque_to_smt"] let va_code_MulHigh64U dst src1 src2 = (Ins (S.MulHigh64U dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_MulHigh64U dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_MulHigh64U va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_MulHigh64U) (va_code_MulHigh64U dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.MulHigh64U dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.MulHigh64U dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_MulHigh64U dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_MulHigh64U (va_code_MulHigh64U dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Xor [@ "opaque_to_smt"] let va_code_Xor dst src1 src2 = (Ins (S.Xor dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_Xor dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Xor va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_Xor) (va_code_Xor dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.Xor dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.Xor dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Xor dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_Xor (va_code_Xor dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- And [@ "opaque_to_smt"] let va_code_And dst src1 src2 = (Ins (S.And dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_And dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_And va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_And) (va_code_And dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.And dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.And dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_And dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_And (va_code_And dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Sr64Imm [@ "opaque_to_smt"] let va_code_Sr64Imm dst src1 src2 = (Ins (S.Sr64Imm dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_Sr64Imm dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Sr64Imm va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_Sr64Imm) (va_code_Sr64Imm dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.Sr64Imm dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.Sr64Imm dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Sr64Imm dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_Sr64Imm (va_code_Sr64Imm dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Sl64Imm [@ "opaque_to_smt"] let va_code_Sl64Imm dst src1 src2 = (Ins (S.Sl64Imm dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_Sl64Imm dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Sl64Imm va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_Sl64Imm) (va_code_Sl64Imm dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.Sl64Imm dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.Sl64Imm dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Sl64Imm dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_Sl64Imm (va_code_Sl64Imm dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Sr64 [@ "opaque_to_smt"] let va_code_Sr64 dst src1 src2 = (Ins (S.Sr64 dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_Sr64 dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Sr64 va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_Sr64) (va_code_Sr64 dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.Sr64 dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.Sr64 dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Sr64 dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_Sr64 (va_code_Sr64 dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Sl64 [@ "opaque_to_smt"] let va_code_Sl64 dst src1 src2 = (Ins (S.Sl64 dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_Sl64 dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Sl64 va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_Sl64) (va_code_Sl64 dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.Sl64 dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.Sl64 dst src1 src2)) va_s0 in (va_sM, va_fM)
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.Decls.fst.checked", "Vale.PPC64LE.Decls.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.InsBasic.fst" }
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.PPC64LE.Decls.va_operand_reg_opr -> src1: Vale.PPC64LE.Decls.va_operand_reg_opr -> src2: Vale.PPC64LE.Decls.va_operand_reg_opr -> va_s0: Vale.PPC64LE.Decls.va_state -> va_k: (_: Vale.PPC64LE.Decls.va_state -> _: Prims.unit -> Type0) -> Prims.Ghost ((Vale.PPC64LE.Decls.va_state * Vale.PPC64LE.Decls.va_fuel) * Prims.unit)
Prims.Ghost
[]
[]
[ "Vale.PPC64LE.Decls.va_operand_reg_opr", "Vale.PPC64LE.Decls.va_state", "Prims.unit", "Vale.PPC64LE.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "Vale.PPC64LE.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.PPC64LE.QuickCode.mod_t", "Vale.PPC64LE.QuickCode.va_mod_reg_opr", "Prims.Nil", "Prims._assert", "Vale.PPC64LE.Decls.va_state_eq", "Vale.PPC64LE.Decls.va_update_ok", "Vale.PPC64LE.Decls.va_update_operand_reg_opr", "Vale.PPC64LE.Decls.va_lemma_upd_update", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.PPC64LE.Machine_s.state", "Vale.PPC64LE.InsBasic.va_lemma_Sl64", "Vale.PPC64LE.InsBasic.va_code_Sl64" ]
[]
false
false
false
false
false
let va_wpProof_Sl64 dst src1 src2 va_s0 va_k =
let va_sM, va_f0 = va_lemma_Sl64 (va_code_Sl64 dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
false
Vale.Lib.Seqs.fst
Vale.Lib.Seqs.lemma_slice_first_exactly_in_append
val lemma_slice_first_exactly_in_append (#a:Type) (x y:seq a) : Lemma (slice (append x y) 0 (length x) == x)
val lemma_slice_first_exactly_in_append (#a:Type) (x y:seq a) : Lemma (slice (append x y) 0 (length x) == x)
let lemma_slice_first_exactly_in_append (#a:Type) (x y:seq a) : Lemma (slice (append x y) 0 (length x) == x) = let xy = append x y in let xy_slice = slice xy 0 (length x) in let x_slice = slice x 0 (length x) in assert(equal xy_slice x_slice); // OBSERVE: extensionality ()
{ "file_name": "vale/code/lib/collections/Vale.Lib.Seqs.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 10, "start_col": 0, "start_line": 4 }
module Vale.Lib.Seqs open FStar.Mul
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Lib.Seqs.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Seq.Base.seq a -> y: FStar.Seq.Base.seq a -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.slice (FStar.Seq.Base.append x y) 0 (FStar.Seq.Base.length x) == x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Prims.unit", "Prims._assert", "FStar.Seq.Base.equal", "FStar.Seq.Base.slice", "FStar.Seq.Base.length", "FStar.Seq.Base.append", "Prims.l_True", "Prims.squash", "Prims.eq2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let lemma_slice_first_exactly_in_append (#a: Type) (x y: seq a) : Lemma (slice (append x y) 0 (length x) == x) =
let xy = append x y in let xy_slice = slice xy 0 (length x) in let x_slice = slice x 0 (length x) in assert (equal xy_slice x_slice); ()
false
Tutorial.fst
Tutorial.ex1
val ex1 : unit -> Lemma True
val ex1 : unit -> Lemma True
let ex1 () = assert_by_tactic True idtac
{ "file_name": "examples/tactics/Tutorial.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 31, "end_line": 63, "start_col": 0, "start_line": 62 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Tutorial /// This file presents a walkthrough of the tactics engine in its current /// (July 23rd, 2017) state. It is mostly aimed at users and power users, leaving /// some details about the implementation out of this. open FStar.Tactics.V2 open FStar.List /// **First, what are tactics supposed to be?** /// /// In other dependently-typed theorem provers, they are a way to construct /// (or find) proofs automatically, which can be very tedious. Take a /// goal such as ``a + (b + c) == (c + a) + b``: we can get a proofterm for /// it by applying and composing associativity and commutativity lemmas. /// However, this proofterm is very dependent on the exact goal we're /// trying to prove: any change to the goal will require a change to the /// proof. This is annoying, since no real insight is required for the /// proof. Tactics provide an extensible way to automate these kind of /// proofs, improving robustness of proofs and the user's sanity. In one /// way or another, tactics reflect on the goal they have been called on, /// possibly inspecting the local and global environments, and implement /// a custom behaviour to construct such proof. In the previous example, /// one possibility for a tactic is shuffling the summands on each side /// following some well-defined order, a totally automatable process. /// /// You might be thinking: "doesn't F* already have an SMT solver backend /// for this reason?". Yes, but this does not at all negate the need for /// more automation in proofs. One could want to not call the SMT and stay /// only within F*, or to break down a proof obligation into more manageable /// chunks for the SMT, or even to simply change some SMT options or its /// environment for different subgoals. The main goal is to get more robust /// and faster proofs. /// /// On the other side of the Curry-Howard isomorphism, tactics can also /// be used to construct arbitrary terms, and not necessarily proofs. /// In this sense, they enable "metaprogramming" such as automatically /// generating printers for datatypes, recursors, or for whatever crazy /// boilerplate-like thing you want to do. We can also benefit from that in /// F*. /// /// So, enough talk, **what's the hello world of tactics?** /// The entry point for *proving* in tactics is `assert_by_tactic`, /// which takes a tactic to be run on the goal to prove.
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Tutorial.fst" }
[ { "abbrev": false, "full_module": "FStar.List", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Prims.l_True)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "FStar.Tactics.Effect.assert_by_tactic", "Prims.l_True", "FStar.Tactics.V2.Derived.idtac" ]
[]
true
false
true
false
false
let ex1 () =
assert_by_tactic True idtac
false
Tutorial.fst
Tutorial.ex2
val ex2 : unit -> Lemma True
val ex2 : unit -> Lemma True
let ex2 () = assert_by_tactic True (fun () -> dump "Example 2")
{ "file_name": "examples/tactics/Tutorial.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 54, "end_line": 74, "start_col": 0, "start_line": 73 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Tutorial /// This file presents a walkthrough of the tactics engine in its current /// (July 23rd, 2017) state. It is mostly aimed at users and power users, leaving /// some details about the implementation out of this. open FStar.Tactics.V2 open FStar.List /// **First, what are tactics supposed to be?** /// /// In other dependently-typed theorem provers, they are a way to construct /// (or find) proofs automatically, which can be very tedious. Take a /// goal such as ``a + (b + c) == (c + a) + b``: we can get a proofterm for /// it by applying and composing associativity and commutativity lemmas. /// However, this proofterm is very dependent on the exact goal we're /// trying to prove: any change to the goal will require a change to the /// proof. This is annoying, since no real insight is required for the /// proof. Tactics provide an extensible way to automate these kind of /// proofs, improving robustness of proofs and the user's sanity. In one /// way or another, tactics reflect on the goal they have been called on, /// possibly inspecting the local and global environments, and implement /// a custom behaviour to construct such proof. In the previous example, /// one possibility for a tactic is shuffling the summands on each side /// following some well-defined order, a totally automatable process. /// /// You might be thinking: "doesn't F* already have an SMT solver backend /// for this reason?". Yes, but this does not at all negate the need for /// more automation in proofs. One could want to not call the SMT and stay /// only within F*, or to break down a proof obligation into more manageable /// chunks for the SMT, or even to simply change some SMT options or its /// environment for different subgoals. The main goal is to get more robust /// and faster proofs. /// /// On the other side of the Curry-Howard isomorphism, tactics can also /// be used to construct arbitrary terms, and not necessarily proofs. /// In this sense, they enable "metaprogramming" such as automatically /// generating printers for datatypes, recursors, or for whatever crazy /// boilerplate-like thing you want to do. We can also benefit from that in /// F*. /// /// So, enough talk, **what's the hello world of tactics?** /// The entry point for *proving* in tactics is `assert_by_tactic`, /// which takes a tactic to be run on the goal to prove. val ex1 : unit -> Lemma True let ex1 () = assert_by_tactic True idtac /// Here, ``idtac`` is the identity tactic, which does nothing. Certainly, /// ``True`` is a simple enough goal so this example succeeds. In between, the /// tactic is running with `True` as a goal, in the “logical environment” /// where we need to do the proof. Running the following example will cause /// the exact “proofstate” where the tactic runs to be printed in the /// standard output.
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Tutorial.fst" }
[ { "abbrev": false, "full_module": "FStar.List", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Prims.l_True)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "FStar.Tactics.Effect.assert_by_tactic", "Prims.l_True", "FStar.Stubs.Tactics.V2.Builtins.dump" ]
[]
false
false
true
false
false
let ex2 () =
assert_by_tactic True (fun () -> dump "Example 2")
false
Simple.fst
Simple.mk_n_list
val mk_n_list (#a: Type) (n: nat) (x: a) : list a
val mk_n_list (#a: Type) (n: nat) (x: a) : list a
let mk_n_list (#a:Type) (n:nat) (x:a) : list a = let rec aux (n:nat) out = if n = 0 then out else aux (n - 1) (x :: out) in aux n []
{ "file_name": "examples/native_tactics/Simple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 10, "end_line": 39, "start_col": 0, "start_line": 34 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Simple [@@ plugin] let id (x:int{x >= 0}) = let rec countdown (y:nat) = if y=0 then x else countdown (y - 1) in countdown x [@@ plugin] let poly_id (#a:Type) (x:int{x >= 0}) (r:a) : a = let rec countdown (y:nat) = if y=0 then r else countdown (y - 1) in countdown x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Simple.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat -> x: a -> Prims.list a
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.Nil", "Prims.list", "Prims.op_Equality", "Prims.int", "Prims.bool", "Prims.op_Subtraction", "Prims.Cons" ]
[]
false
false
false
true
false
let mk_n_list (#a: Type) (n: nat) (x: a) : list a =
let rec aux (n: nat) out = if n = 0 then out else aux (n - 1) (x :: out) in aux n []
false
Vale.Lib.Seqs.fst
Vale.Lib.Seqs.lemma_all_but_last_append
val lemma_all_but_last_append (#t:Type) (a:seq t) (b:seq t{length b > 0}) : Lemma (all_but_last (append a b) == append a (all_but_last b))
val lemma_all_but_last_append (#t:Type) (a:seq t) (b:seq t{length b > 0}) : Lemma (all_but_last (append a b) == append a (all_but_last b))
let lemma_all_but_last_append (#t:Type) (a:seq t) (b:seq t{length b > 0}) : Lemma (all_but_last (append a b) == append a (all_but_last b)) = let ab = all_but_last (append a b) in let app_a_b = append a (all_but_last b) in assert (equal ab app_a_b)
{ "file_name": "vale/code/lib/collections/Vale.Lib.Seqs.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 27, "end_line": 16, "start_col": 0, "start_line": 12 }
module Vale.Lib.Seqs open FStar.Mul let lemma_slice_first_exactly_in_append (#a:Type) (x y:seq a) : Lemma (slice (append x y) 0 (length x) == x) = let xy = append x y in let xy_slice = slice xy 0 (length x) in let x_slice = slice x 0 (length x) in assert(equal xy_slice x_slice); // OBSERVE: extensionality ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Lib.Seqs.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: FStar.Seq.Base.seq t -> b: FStar.Seq.Base.seq t {FStar.Seq.Base.length b > 0} -> FStar.Pervasives.Lemma (ensures Vale.Lib.Seqs_s.all_but_last (FStar.Seq.Base.append a b) == FStar.Seq.Base.append a (Vale.Lib.Seqs_s.all_but_last b))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Prims.b2t", "Prims.op_GreaterThan", "FStar.Seq.Base.length", "Prims._assert", "FStar.Seq.Base.equal", "FStar.Seq.Base.append", "Vale.Lib.Seqs_s.all_but_last", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let lemma_all_but_last_append (#t: Type) (a: seq t) (b: seq t {length b > 0}) : Lemma (all_but_last (append a b) == append a (all_but_last b)) =
let ab = all_but_last (append a b) in let app_a_b = append a (all_but_last b) in assert (equal ab app_a_b)
false
Simple.fst
Simple.id
val id : x: Prims.int{x >= 0} -> x: Prims.int{x >= 0}
let id (x:int{x >= 0}) = let rec countdown (y:nat) = if y=0 then x else countdown (y - 1) in countdown x
{ "file_name": "examples/native_tactics/Simple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 13, "end_line": 23, "start_col": 0, "start_line": 18 }
(* 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 Simple
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Simple.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Prims.int{x >= 0} -> x: Prims.int{x >= 0}
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.nat", "Prims.op_Equality", "Prims.bool", "Prims.op_Subtraction" ]
[]
false
false
false
false
false
let id (x: int{x >= 0}) =
let rec countdown (y: nat) = if y = 0 then x else countdown (y - 1) in countdown x
false
Tutorial.fst
Tutorial.split_all
val split_all: Prims.unit -> Tac unit
val split_all: Prims.unit -> Tac unit
let rec split_all () : Tac unit = if is_conj () then begin Tactics.split (); iseq [split_all; split_all] end else let _ = trytac trivial in ()
{ "file_name": "examples/tactics/Tutorial.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 6, "end_line": 184, "start_col": 0, "start_line": 175 }
(* 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 Tutorial /// This file presents a walkthrough of the tactics engine in its current /// (July 23rd, 2017) state. It is mostly aimed at users and power users, leaving /// some details about the implementation out of this. open FStar.Tactics.V2 open FStar.List /// **First, what are tactics supposed to be?** /// /// In other dependently-typed theorem provers, they are a way to construct /// (or find) proofs automatically, which can be very tedious. Take a /// goal such as ``a + (b + c) == (c + a) + b``: we can get a proofterm for /// it by applying and composing associativity and commutativity lemmas. /// However, this proofterm is very dependent on the exact goal we're /// trying to prove: any change to the goal will require a change to the /// proof. This is annoying, since no real insight is required for the /// proof. Tactics provide an extensible way to automate these kind of /// proofs, improving robustness of proofs and the user's sanity. In one /// way or another, tactics reflect on the goal they have been called on, /// possibly inspecting the local and global environments, and implement /// a custom behaviour to construct such proof. In the previous example, /// one possibility for a tactic is shuffling the summands on each side /// following some well-defined order, a totally automatable process. /// /// You might be thinking: "doesn't F* already have an SMT solver backend /// for this reason?". Yes, but this does not at all negate the need for /// more automation in proofs. One could want to not call the SMT and stay /// only within F*, or to break down a proof obligation into more manageable /// chunks for the SMT, or even to simply change some SMT options or its /// environment for different subgoals. The main goal is to get more robust /// and faster proofs. /// /// On the other side of the Curry-Howard isomorphism, tactics can also /// be used to construct arbitrary terms, and not necessarily proofs. /// In this sense, they enable "metaprogramming" such as automatically /// generating printers for datatypes, recursors, or for whatever crazy /// boilerplate-like thing you want to do. We can also benefit from that in /// F*. /// /// So, enough talk, **what's the hello world of tactics?** /// The entry point for *proving* in tactics is `assert_by_tactic`, /// which takes a tactic to be run on the goal to prove. val ex1 : unit -> Lemma True let ex1 () = assert_by_tactic True idtac /// Here, ``idtac`` is the identity tactic, which does nothing. Certainly, /// ``True`` is a simple enough goal so this example succeeds. In between, the /// tactic is running with `True` as a goal, in the “logical environment” /// where we need to do the proof. Running the following example will cause /// the exact “proofstate” where the tactic runs to be printed in the /// standard output. val ex2 : unit -> Lemma True let ex2 () = assert_by_tactic True (fun () -> dump "Example 2") /// This yields the following:: /// /// Goal 1/1 /// uu___: unit /// p: pure_post unit /// ---------------------- /// squash l_True /// (*?u18*) _ uu___6626 p /// The output shows that we have only one “active” goal (that we're still working /// on) and no goals that have been already dispatched to the SMT. /// /// Concretely, to prove `True`, the engine is asking us to provide a term /// of type `squash True`. Squashing is the way we do proof-irrelevance in F*, /// and you can simply think of the type `squash phi` as the type of irrelevant /// proofs of `phi`. We call goals that are squashed “irrelevant”. /// .. note:: /// /// For experts: You might notice that ``True`` is already a squash (of /// ``trivial``), so this seems useless. In this case it is, but we squash /// nevertheless for consistency since this might be not so. /// A tactic is not required to completely prove an assertion, and can leave /// any number of goals unsolved, which will be fed to the SMT. Importantly, /// this can only be done on irrelevant goals, as the SMT does not produce /// proof terms! /// As expected, we can also manipulate logical formulas. There is a derived set of /// tactics (FStar.Tactics.Logical) simplifying this task, which is somewhat /// complicated due to squashing. Let's write a tactic to split a conjunction /// and solve one of its subformulas. let tau3 () : Tac unit = Tactics.split (); smt (); trivial () let ex3 (x : nat) = assert_by_tactic (x + x >= 0 /\ List.length [4;5;1] == 3) tau3 /// First, we defined tau3 as a custom tactic, composed by applying ``split``, /// ``smt`` and ``trivial`` in that order. The ``tactic 'a`` type is a monad, and /// this is F*'s version of do notation for it. /// /// The ``split`` tactic will destruct the original goal into its /// two conjuncts, creating two new goals. /// /// Try adding ``dump "After split";`` just after ``split`` above, and run that code again. Now we see the following:: /// /// After split /// Goal 1/2 /// x: nat /// ------------------- /// squash (x + x >= 0) /// (*?u58*) _ x /// Goal 2/2 /// x: nat /// ------------------------------ /// squash (length [4; 5; 1] == 3) /// (*?u59*) _ x /// /// Further tactic steps are applied to the first goal. For the first one, /// we want to just give it to the smt, so we call into the ``smt`` tactic, /// which always succeeds and marks a goal for SMT discharging. If we were /// to dump the proofstate here, we'd see the first goal was simply moved /// into the "SMT goals" set. /// /// The second conjunct one can be shown true simply by normalization, so we /// can call into the ``trivial`` tactic to take care of it internally. /// /// .. note:: /// /// There is currently no support for a "try SMT" tactic, which would /// return back control if the SMT solver cannot prove the goal. This /// requires some rework in how guards are discharged in F*. /// /// For an automation example, let's write a tactic that will split all /// top-level conjunctions in our goal, trying to discharge them if /// they're trivial. Importantly, we need to be able to inspect the goal /// we're trying to prove from *within* the tactic. This is done via the /// ``cur_goal`` primitive, which returns the goal as ``term``, a reflection of /// F*'s internal term representation. These ``term``\ s are actually opaque, /// and can only be meaningfully used through some *views* defined on them. /// Since we're dealing with a logical formula, the ``formula`` view is the /// most comfortable one. We can decide if our goal is a conjunction in the /// following way: let is_conj () : Tac bool = let g = cur_goal () in match term_as_formula g with | And _ _ -> true | _ -> false /// Now, we want a tactic that will call ``split`` when our goal is a /// conjunction, and then recurse on the conjuncts! The iseq tactic /// proves handy here. Given a list of tactics, ``iseq`` will apply them in /// succession to each of the open goals.
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Tutorial.fst" }
[ { "abbrev": false, "full_module": "FStar.List", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.unit", "FStar.Tactics.V2.Derived.iseq", "Prims.Cons", "Tutorial.split_all", "Prims.Nil", "FStar.Tactics.V1.Logic.split", "Prims.bool", "FStar.Pervasives.Native.option", "FStar.Tactics.V2.Derived.trytac", "FStar.Tactics.V2.Derived.trivial", "Tutorial.is_conj" ]
[ "recursion" ]
false
true
false
false
false
let rec split_all () : Tac unit =
if is_conj () then (Tactics.split (); iseq [split_all; split_all]) else let _ = trytac trivial in ()
false
Vale.Lib.Seqs.fst
Vale.Lib.Seqs.seq_map_i
val seq_map_i (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f j (index s j)) })
val seq_map_i (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f j (index s j)) })
let seq_map_i (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f j (index s j)) }) = seq_map_i_indexed f s 0
{ "file_name": "vale/code/lib/collections/Vale.Lib.Seqs.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 25, "end_line": 44, "start_col": 0, "start_line": 39 }
module Vale.Lib.Seqs open FStar.Mul let lemma_slice_first_exactly_in_append (#a:Type) (x y:seq a) : Lemma (slice (append x y) 0 (length x) == x) = let xy = append x y in let xy_slice = slice xy 0 (length x) in let x_slice = slice x 0 (length x) in assert(equal xy_slice x_slice); // OBSERVE: extensionality () let lemma_all_but_last_append (#t:Type) (a:seq t) (b:seq t{length b > 0}) : Lemma (all_but_last (append a b) == append a (all_but_last b)) = let ab = all_but_last (append a b) in let app_a_b = append a (all_but_last b) in assert (equal ab app_a_b) // OBSERVE: extensionality let reverse_seq_append (#a:eqtype) (s:seq a) (t:seq a) : Lemma(ensures reverse_seq (append s t) == append (reverse_seq t) (reverse_seq s)) = assert (equal (reverse_seq (append s t)) (append (reverse_seq t) (reverse_seq s))) let reverse_reverse_seq (#a:Type) (s:seq a) : Lemma(ensures reverse_seq (reverse_seq s) == s) = assert (equal (reverse_seq (reverse_seq s)) s) let rec seq_map_i_indexed (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) (i:int) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f (i + j) (index s j)) }) (decreases %[(length s)]) = if length s = 0 then empty else cons (f i (head s)) (seq_map_i_indexed f (tail s) (i + 1))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Lib.Seqs.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: Prims.int -> _: a -> b) -> s: FStar.Seq.Base.seq a -> s': FStar.Seq.Base.seq b { FStar.Seq.Base.length s' == FStar.Seq.Base.length s /\ (forall (j: i: Prims.int {i >= 0 /\ i < FStar.Seq.Base.length s /\ (i >= 0) /\ (i < FStar.Seq.Base.length s')}) . {:pattern FStar.Seq.Base.index s' j} 0 <= j /\ j < FStar.Seq.Base.length s ==> FStar.Seq.Base.index s' j == f j (FStar.Seq.Base.index s j)) }
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "FStar.Seq.Base.seq", "Vale.Lib.Seqs.seq_map_i_indexed", "Prims.l_and", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "Prims.l_Forall", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.l_imp", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.index" ]
[]
false
false
false
false
false
let seq_map_i (#a #b: Type) (f: (int -> a -> b)) (s: seq a) : Tot (s': seq b { length s' == length s /\ (forall j. {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f j (index s j)) }) =
seq_map_i_indexed f s 0
false
Vale.PPC64LE.InsBasic.fst
Vale.PPC64LE.InsBasic.va_lemma_Sr64
val va_lemma_Sr64 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:va_operand_reg_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Sr64 dst src1 src2) va_s0 /\ va_is_dst_reg_opr dst va_s0 /\ va_is_src_reg_opr src1 va_s0 /\ va_is_src_reg_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_reg_opr va_sM dst == Vale.Arch.Types.ishr64 (va_eval_reg_opr va_s0 src1) (va_eval_reg_opr va_s0 src2 `op_Modulus` 64) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))))
val va_lemma_Sr64 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_reg_opr -> src1:va_operand_reg_opr -> src2:va_operand_reg_opr -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Sr64 dst src1 src2) va_s0 /\ va_is_dst_reg_opr dst va_s0 /\ va_is_src_reg_opr src1 va_s0 /\ va_is_src_reg_opr src2 va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_reg_opr va_sM dst == Vale.Arch.Types.ishr64 (va_eval_reg_opr va_s0 src1) (va_eval_reg_opr va_s0 src2 `op_Modulus` 64) /\ va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))))
let va_lemma_Sr64 va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_Sr64) (va_code_Sr64 dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.Sr64 dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.Sr64 dst src1 src2)) va_s0 in (va_sM, va_fM)
{ "file_name": "obj/Vale.PPC64LE.InsBasic.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 16, "end_line": 669, "start_col": 0, "start_line": 664 }
module Vale.PPC64LE.InsBasic open Vale.PPC64LE.Machine_s open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.Memory open Vale.PPC64LE.Stack_i friend Vale.PPC64LE.Decls module S = Vale.PPC64LE.Semantics_s //-- Move [@ "opaque_to_smt"] let va_code_Move dst src = (Ins (S.Move dst src)) [@ "opaque_to_smt"] let va_codegen_success_Move dst src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Move va_b0 va_s0 dst src = va_reveal_opaque (`%va_code_Move) (va_code_Move dst src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.Move dst src)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.Move dst src)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Move dst src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Move (va_code_Move dst src) va_s0 dst src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- LoadImm64 [@ "opaque_to_smt"] let va_code_LoadImm64 dst src = (Ins (S.LoadImm64 dst src)) [@ "opaque_to_smt"] let va_codegen_success_LoadImm64 dst src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_LoadImm64 va_b0 va_s0 dst src = va_reveal_opaque (`%va_code_LoadImm64) (va_code_LoadImm64 dst src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.LoadImm64 dst src)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.LoadImm64 dst src)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_LoadImm64 dst src va_s0 va_k = let (va_sM, va_f0) = va_lemma_LoadImm64 (va_code_LoadImm64 dst src) va_s0 dst src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- LoadImmShl64 [@ "opaque_to_smt"] let va_code_LoadImmShl64 dst src = (Ins (S.LoadImmShl64 dst src)) [@ "opaque_to_smt"] let va_codegen_success_LoadImmShl64 dst src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_LoadImmShl64 va_b0 va_s0 dst src = va_reveal_opaque (`%va_code_LoadImmShl64) (va_code_LoadImmShl64 dst src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.LoadImmShl64 dst src)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.LoadImmShl64 dst src)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_LoadImmShl64 dst src va_s0 va_k = let (va_sM, va_f0) = va_lemma_LoadImmShl64 (va_code_LoadImmShl64 dst src) va_s0 dst src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AddLa [@ "opaque_to_smt"] let va_code_AddLa dst src1 src2 = (Ins (S.AddLa dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_AddLa dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_AddLa va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_AddLa) (va_code_AddLa dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.AddLa dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.AddLa dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_AddLa dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_AddLa (va_code_AddLa dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Add [@ "opaque_to_smt"] let va_code_Add dst src1 src2 = (Ins (S.Add dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_Add dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Add va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_Add) (va_code_Add dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.Add dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.Add dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Add dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_Add (va_code_Add dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AddWrap [@ "opaque_to_smt"] let va_code_AddWrap dst src1 src2 = (Ins (S.Add dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_AddWrap dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_AddWrap va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_AddWrap) (va_code_AddWrap dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.Add dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.Add dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_AddWrap dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_AddWrap (va_code_AddWrap dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AddImm [@ "opaque_to_smt"] let va_code_AddImm dst src1 src2 = (Ins (S.AddImm dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_AddImm dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_AddImm va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_AddImm) (va_code_AddImm dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.AddImm dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.AddImm dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_AddImm dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_AddImm (va_code_AddImm dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AddImmWrap [@ "opaque_to_smt"] let va_code_AddImmWrap dst src1 src2 = (Ins (S.AddImm dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_AddImmWrap dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_AddImmWrap va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_AddImmWrap) (va_code_AddImmWrap dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.AddImm dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.AddImm dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_AddImmWrap dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_AddImmWrap (va_code_AddImmWrap dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AddCarry [@ "opaque_to_smt"] let va_code_AddCarry dst src1 src2 = (Ins (S.AddCarry dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_AddCarry dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_AddCarry va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_AddCarry) (va_code_AddCarry dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.AddCarry dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.AddCarry dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_AddCarry dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_AddCarry (va_code_AddCarry dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_xer va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0)))); va_lemma_norm_mods ([va_Mod_xer; va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AddExtended [@ "opaque_to_smt"] let va_code_AddExtended dst src1 src2 = (Ins (S.AddExtended dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_AddExtended dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_AddExtended va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_AddExtended) (va_code_AddExtended dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.AddExtended dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.AddExtended dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_AddExtended dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_AddExtended (va_code_AddExtended dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_xer va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0)))); va_lemma_norm_mods ([va_Mod_xer; va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- AddExtendedOV [@ "opaque_to_smt"] let va_code_AddExtendedOV dst src1 src2 = (Ins (S.AddExtendedOV dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_AddExtendedOV dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_AddExtendedOV va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_AddExtendedOV) (va_code_AddExtendedOV dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.AddExtendedOV dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.AddExtendedOV dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_AddExtendedOV dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_AddExtendedOV (va_code_AddExtendedOV dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_xer va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0)))); va_lemma_norm_mods ([va_Mod_xer; va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Sub [@ "opaque_to_smt"] let va_code_Sub dst src1 src2 = (Ins (S.Sub dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_Sub dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Sub va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_Sub) (va_code_Sub dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.Sub dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.Sub dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Sub dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_Sub (va_code_Sub dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- SubWrap [@ "opaque_to_smt"] let va_code_SubWrap dst src1 src2 = (Ins (S.Sub dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_SubWrap dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_SubWrap va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_SubWrap) (va_code_SubWrap dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.Sub dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.Sub dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_SubWrap dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_SubWrap (va_code_SubWrap dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- SubImm [@ "opaque_to_smt"] let va_code_SubImm dst src1 src2 = (Ins (S.SubImm dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_SubImm dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_SubImm va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_SubImm) (va_code_SubImm dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.SubImm dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.SubImm dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_SubImm dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_SubImm (va_code_SubImm dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- SubImmWrap [@ "opaque_to_smt"] let va_code_SubImmWrap dst src1 src2 = (Ins (S.SubImm dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_SubImmWrap dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_SubImmWrap va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_SubImmWrap) (va_code_SubImmWrap dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.SubImm dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.SubImm dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_SubImmWrap dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_SubImmWrap (va_code_SubImmWrap dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- MulLow64 [@ "opaque_to_smt"] let va_code_MulLow64 dst src1 src2 = (Ins (S.MulLow64 dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_MulLow64 dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_MulLow64 va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_MulLow64) (va_code_MulLow64 dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.MulLow64 dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.MulLow64 dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_MulLow64 dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_MulLow64 (va_code_MulLow64 dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- MulLow64Wrap [@ "opaque_to_smt"] let va_code_MulLow64Wrap dst src1 src2 = (Ins (S.MulLow64 dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_MulLow64Wrap dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_MulLow64Wrap va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_MulLow64Wrap) (va_code_MulLow64Wrap dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.MulLow64 dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.MulLow64 dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_MulLow64Wrap dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_MulLow64Wrap (va_code_MulLow64Wrap dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- MulHigh64U [@ "opaque_to_smt"] let va_code_MulHigh64U dst src1 src2 = (Ins (S.MulHigh64U dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_MulHigh64U dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_MulHigh64U va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_MulHigh64U) (va_code_MulHigh64U dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.MulHigh64U dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.MulHigh64U dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_MulHigh64U dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_MulHigh64U (va_code_MulHigh64U dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Xor [@ "opaque_to_smt"] let va_code_Xor dst src1 src2 = (Ins (S.Xor dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_Xor dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Xor va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_Xor) (va_code_Xor dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.Xor dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.Xor dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Xor dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_Xor (va_code_Xor dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- And [@ "opaque_to_smt"] let va_code_And dst src1 src2 = (Ins (S.And dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_And dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_And va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_And) (va_code_And dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.And dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.And dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_And dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_And (va_code_And dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Sr64Imm [@ "opaque_to_smt"] let va_code_Sr64Imm dst src1 src2 = (Ins (S.Sr64Imm dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_Sr64Imm dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Sr64Imm va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_Sr64Imm) (va_code_Sr64Imm dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.Sr64Imm dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.Sr64Imm dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Sr64Imm dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_Sr64Imm (va_code_Sr64Imm dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Sl64Imm [@ "opaque_to_smt"] let va_code_Sl64Imm dst src1 src2 = (Ins (S.Sl64Imm dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_Sl64Imm dst src1 src2 = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Sl64Imm va_b0 va_s0 dst src1 src2 = va_reveal_opaque (`%va_code_Sl64Imm) (va_code_Sl64Imm dst src1 src2); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (S.Sl64Imm dst src1 src2)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (S.Sl64Imm dst src1 src2)) va_s0 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Sl64Imm dst src1 src2 va_s0 va_k = let (va_sM, va_f0) = va_lemma_Sl64Imm (va_code_Sl64Imm dst src1 src2) va_s0 dst src1 src2 in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_reg_opr dst va_sM va_s0))); va_lemma_norm_mods ([va_mod_reg_opr dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Sr64 [@ "opaque_to_smt"] let va_code_Sr64 dst src1 src2 = (Ins (S.Sr64 dst src1 src2)) [@ "opaque_to_smt"] let va_codegen_success_Sr64 dst src1 src2 = (va_ttrue ())
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.Stack_i.fsti.checked", "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.Decls.fst.checked", "Vale.PPC64LE.Decls.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.InsBasic.fst" }
[ { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.PPC64LE.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
va_b0: Vale.PPC64LE.Decls.va_code -> va_s0: Vale.PPC64LE.Decls.va_state -> dst: Vale.PPC64LE.Decls.va_operand_reg_opr -> src1: Vale.PPC64LE.Decls.va_operand_reg_opr -> src2: Vale.PPC64LE.Decls.va_operand_reg_opr -> Prims.Ghost (Vale.PPC64LE.Decls.va_state * Vale.PPC64LE.Decls.va_fuel)
Prims.Ghost
[]
[]
[ "Vale.PPC64LE.Decls.va_code", "Vale.PPC64LE.Decls.va_state", "Vale.PPC64LE.Decls.va_operand_reg_opr", "Vale.PPC64LE.State.state", "Vale.PPC64LE.Lemmas.fuel", "FStar.Pervasives.Native.Mktuple2", "Vale.PPC64LE.Decls.va_fuel", "FStar.Pervasives.Native.tuple2", "Vale.PPC64LE.Machine_s.state", "Prims.nat", "Vale.PPC64LE.Decls.va_eval_ins", "Vale.PPC64LE.Machine_s.Ins", "Vale.PPC64LE.Semantics_s.ins", "Vale.PPC64LE.Semantics_s.ocmp", "Vale.PPC64LE.Semantics_s.Sr64", "Prims.unit", "Vale.PPC64LE.Decls.va_ins_lemma", "Vale.PPC64LE.Decls.ins", "Vale.PPC64LE.Decls.ocmp", "Vale.PPC64LE.Decls.va_reveal_opaque", "Vale.PPC64LE.InsBasic.va_code_Sr64" ]
[]
false
false
false
false
false
let va_lemma_Sr64 va_b0 va_s0 dst src1 src2 =
va_reveal_opaque (`%va_code_Sr64) (va_code_Sr64 dst src1 src2); let va_old_s:va_state = va_s0 in va_ins_lemma (Ins (S.Sr64 dst src1 src2)) va_s0; let va_sM, va_fM = va_eval_ins (Ins (S.Sr64 dst src1 src2)) va_s0 in (va_sM, va_fM)
false
Simple.fst
Simple.poly_list_id
val poly_list_id : l: Prims.list a -> Prims.list a
let poly_list_id (#a:Type) (l:list a) = let rec aux (l:list a) (out:list a) = match l with | [] -> List.Tot.rev out | hd::tl -> aux tl (hd::out) in aux l []
{ "file_name": "examples/native_tactics/Simple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 10, "end_line": 48, "start_col": 0, "start_line": 42 }
(* 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 Simple [@@ plugin] let id (x:int{x >= 0}) = let rec countdown (y:nat) = if y=0 then x else countdown (y - 1) in countdown x [@@ plugin] let poly_id (#a:Type) (x:int{x >= 0}) (r:a) : a = let rec countdown (y:nat) = if y=0 then r else countdown (y - 1) in countdown x [@@ plugin] let mk_n_list (#a:Type) (n:nat) (x:a) : list a = let rec aux (n:nat) out = if n = 0 then out else aux (n - 1) (x :: out) in aux n []
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Simple.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
l: Prims.list a -> Prims.list a
Prims.Tot
[ "total" ]
[]
[ "Prims.list", "Prims.Nil", "FStar.List.Tot.Base.rev", "Prims.Cons" ]
[]
false
false
false
true
false
let poly_list_id (#a: Type) (l: list a) =
let rec aux (l out: list a) = match l with | [] -> List.Tot.rev out | hd :: tl -> aux tl (hd :: out) in aux l []
false
Vale.Lib.Seqs.fst
Vale.Lib.Seqs.seq_map_inverses
val seq_map_inverses (#a #b:Type) (f:a -> b) (g:b -> a) (s:seq a) : Lemma (requires forall x . g (f x) == x) (ensures seq_map g (seq_map f s) == s)
val seq_map_inverses (#a #b:Type) (f:a -> b) (g:b -> a) (s:seq a) : Lemma (requires forall x . g (f x) == x) (ensures seq_map g (seq_map f s) == s)
let seq_map_inverses (#a #b:Type) (f:a -> b) (g:b -> a) (s:seq a) : Lemma (requires forall x . g (f x) == x) (ensures seq_map g (seq_map f s) == s) = let mid = seq_map f s in let final = seq_map g mid in assert (equal s final); ()
{ "file_name": "vale/code/lib/collections/Vale.Lib.Seqs.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 64, "start_col": 0, "start_line": 57 }
module Vale.Lib.Seqs open FStar.Mul let lemma_slice_first_exactly_in_append (#a:Type) (x y:seq a) : Lemma (slice (append x y) 0 (length x) == x) = let xy = append x y in let xy_slice = slice xy 0 (length x) in let x_slice = slice x 0 (length x) in assert(equal xy_slice x_slice); // OBSERVE: extensionality () let lemma_all_but_last_append (#t:Type) (a:seq t) (b:seq t{length b > 0}) : Lemma (all_but_last (append a b) == append a (all_but_last b)) = let ab = all_but_last (append a b) in let app_a_b = append a (all_but_last b) in assert (equal ab app_a_b) // OBSERVE: extensionality let reverse_seq_append (#a:eqtype) (s:seq a) (t:seq a) : Lemma(ensures reverse_seq (append s t) == append (reverse_seq t) (reverse_seq s)) = assert (equal (reverse_seq (append s t)) (append (reverse_seq t) (reverse_seq s))) let reverse_reverse_seq (#a:Type) (s:seq a) : Lemma(ensures reverse_seq (reverse_seq s) == s) = assert (equal (reverse_seq (reverse_seq s)) s) let rec seq_map_i_indexed (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) (i:int) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f (i + j) (index s j)) }) (decreases %[(length s)]) = if length s = 0 then empty else cons (f i (head s)) (seq_map_i_indexed f (tail s) (i + 1)) let seq_map_i (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f j (index s j)) }) = seq_map_i_indexed f s 0 let seq_map_internal_associative (#a:Type) (#b:eqtype) (f:int->a->b) (s:seq a) (pivot:int{0 <= pivot /\ pivot < length s}) : Lemma (let left,right = split s pivot in seq_map_i f s == seq_map_i_indexed f left 0 @| seq_map_i_indexed f right pivot ) = let left,right = split s pivot in let full_map = seq_map_i f s in let part1 = seq_map_i_indexed f left 0 in let part2 = seq_map_i_indexed f right pivot in assert (equal (seq_map_i f s) (seq_map_i_indexed f left 0 @| seq_map_i_indexed f right pivot)); ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Lib.Seqs.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: a -> b) -> g: (_: b -> a) -> s: FStar.Seq.Base.seq a -> FStar.Pervasives.Lemma (requires forall (x: a). g (f x) == x) (ensures Vale.Lib.Seqs_s.seq_map g (Vale.Lib.Seqs_s.seq_map f s) == s)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Prims.unit", "Prims._assert", "FStar.Seq.Base.equal", "Vale.Lib.Seqs_s.seq_map", "Prims.l_Forall", "Prims.eq2", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let seq_map_inverses (#a #b: Type) (f: (a -> b)) (g: (b -> a)) (s: seq a) : Lemma (requires forall x. g (f x) == x) (ensures seq_map g (seq_map f s) == s) =
let mid = seq_map f s in let final = seq_map g mid in assert (equal s final); ()
false
Simple.fst
Simple.poly_id
val poly_id (#a: Type) (x: int{x >= 0}) (r: a) : a
val poly_id (#a: Type) (x: int{x >= 0}) (r: a) : a
let poly_id (#a:Type) (x:int{x >= 0}) (r:a) : a = let rec countdown (y:nat) = if y=0 then r else countdown (y - 1) in countdown x
{ "file_name": "examples/native_tactics/Simple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 13, "end_line": 31, "start_col": 0, "start_line": 26 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Simple [@@ plugin] let id (x:int{x >= 0}) = let rec countdown (y:nat) = if y=0 then x else countdown (y - 1) in countdown x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Simple.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Prims.int{x >= 0} -> r: a -> a
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.nat", "Prims.op_Equality", "Prims.bool", "Prims.op_Subtraction" ]
[]
false
false
false
false
false
let poly_id (#a: Type) (x: int{x >= 0}) (r: a) : a =
let rec countdown (y: nat) = if y = 0 then r else countdown (y - 1) in countdown x
false
Vale.Lib.Seqs.fst
Vale.Lib.Seqs.seq_map_i_indexed
val seq_map_i_indexed (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) (i:int) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f (i + j) (index s j)) })
val seq_map_i_indexed (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) (i:int) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f (i + j) (index s j)) })
let rec seq_map_i_indexed (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) (i:int) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f (i + j) (index s j)) }) (decreases %[(length s)]) = if length s = 0 then empty else cons (f i (head s)) (seq_map_i_indexed f (tail s) (i + 1))
{ "file_name": "vale/code/lib/collections/Vale.Lib.Seqs.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 63, "end_line": 37, "start_col": 0, "start_line": 29 }
module Vale.Lib.Seqs open FStar.Mul let lemma_slice_first_exactly_in_append (#a:Type) (x y:seq a) : Lemma (slice (append x y) 0 (length x) == x) = let xy = append x y in let xy_slice = slice xy 0 (length x) in let x_slice = slice x 0 (length x) in assert(equal xy_slice x_slice); // OBSERVE: extensionality () let lemma_all_but_last_append (#t:Type) (a:seq t) (b:seq t{length b > 0}) : Lemma (all_but_last (append a b) == append a (all_but_last b)) = let ab = all_but_last (append a b) in let app_a_b = append a (all_but_last b) in assert (equal ab app_a_b) // OBSERVE: extensionality let reverse_seq_append (#a:eqtype) (s:seq a) (t:seq a) : Lemma(ensures reverse_seq (append s t) == append (reverse_seq t) (reverse_seq s)) = assert (equal (reverse_seq (append s t)) (append (reverse_seq t) (reverse_seq s))) let reverse_reverse_seq (#a:Type) (s:seq a) : Lemma(ensures reverse_seq (reverse_seq s) == s) = assert (equal (reverse_seq (reverse_seq s)) s)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Lib.Seqs.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: Prims.int -> _: a -> b) -> s: FStar.Seq.Base.seq a -> i: Prims.int -> Prims.Tot (s': FStar.Seq.Base.seq b { FStar.Seq.Base.length s' == FStar.Seq.Base.length s /\ (forall (j: i: Prims.int { i >= 0 /\ i < FStar.Seq.Base.length s /\ (i >= 0) /\ (i < FStar.Seq.Base.length s') }). {:pattern FStar.Seq.Base.index s' j} 0 <= j /\ j < FStar.Seq.Base.length s ==> FStar.Seq.Base.index s' j == f (i + j) (FStar.Seq.Base.index s j)) })
Prims.Tot
[ "", "total" ]
[]
[ "Prims.int", "FStar.Seq.Base.seq", "Prims.op_Equality", "FStar.Seq.Base.length", "FStar.Seq.Base.empty", "Prims.bool", "FStar.Seq.Base.cons", "FStar.Seq.Properties.head", "Vale.Lib.Seqs.seq_map_i_indexed", "FStar.Seq.Properties.tail", "Prims.op_Addition", "Prims.l_and", "Prims.eq2", "Prims.nat", "Prims.l_Forall", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.l_imp", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.index" ]
[ "recursion" ]
false
false
false
false
false
let rec seq_map_i_indexed (#a #b: Type) (f: (int -> a -> b)) (s: seq a) (i: int) : Tot (s': seq b { length s' == length s /\ (forall j. {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f (i + j) (index s j)) }) (decreases %[(length s)]) =
if length s = 0 then empty else cons (f i (head s)) (seq_map_i_indexed f (tail s) (i + 1))
false
Vale.Lib.Seqs.fst
Vale.Lib.Seqs.reverse_reverse_seq
val reverse_reverse_seq (#a:Type) (s:seq a) : Lemma(ensures reverse_seq (reverse_seq s) == s) [SMTPat (reverse_seq (reverse_seq s))]
val reverse_reverse_seq (#a:Type) (s:seq a) : Lemma(ensures reverse_seq (reverse_seq s) == s) [SMTPat (reverse_seq (reverse_seq s))]
let reverse_reverse_seq (#a:Type) (s:seq a) : Lemma(ensures reverse_seq (reverse_seq s) == s) = assert (equal (reverse_seq (reverse_seq s)) s)
{ "file_name": "vale/code/lib/collections/Vale.Lib.Seqs.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 48, "end_line": 26, "start_col": 0, "start_line": 23 }
module Vale.Lib.Seqs open FStar.Mul let lemma_slice_first_exactly_in_append (#a:Type) (x y:seq a) : Lemma (slice (append x y) 0 (length x) == x) = let xy = append x y in let xy_slice = slice xy 0 (length x) in let x_slice = slice x 0 (length x) in assert(equal xy_slice x_slice); // OBSERVE: extensionality () let lemma_all_but_last_append (#t:Type) (a:seq t) (b:seq t{length b > 0}) : Lemma (all_but_last (append a b) == append a (all_but_last b)) = let ab = all_but_last (append a b) in let app_a_b = append a (all_but_last b) in assert (equal ab app_a_b) // OBSERVE: extensionality let reverse_seq_append (#a:eqtype) (s:seq a) (t:seq a) : Lemma(ensures reverse_seq (append s t) == append (reverse_seq t) (reverse_seq s)) = assert (equal (reverse_seq (append s t)) (append (reverse_seq t) (reverse_seq s)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Lib.Seqs.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.Seq.Base.seq a -> FStar.Pervasives.Lemma (ensures Vale.Lib.Seqs_s.reverse_seq (Vale.Lib.Seqs_s.reverse_seq s) == s) [SMTPat (Vale.Lib.Seqs_s.reverse_seq (Vale.Lib.Seqs_s.reverse_seq s))]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Prims._assert", "FStar.Seq.Base.equal", "Vale.Lib.Seqs_s.reverse_seq", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let reverse_reverse_seq (#a: Type) (s: seq a) : Lemma (ensures reverse_seq (reverse_seq s) == s) =
assert (equal (reverse_seq (reverse_seq s)) s)
false
Vale.Lib.Seqs.fst
Vale.Lib.Seqs.slice_append_adds
val slice_append_adds (#a:Type) (s:seq a) (i:nat) (j:nat{ i <= j /\ j <= length s }) : Lemma (slice s 0 i @| slice s i j == slice s 0 j)
val slice_append_adds (#a:Type) (s:seq a) (i:nat) (j:nat{ i <= j /\ j <= length s }) : Lemma (slice s 0 i @| slice s i j == slice s 0 j)
let slice_append_adds (#a:Type) (s:seq a) (i:nat) (j:nat{ i <= j /\ j <= length s }) : Lemma (slice s 0 i @| slice s i j == slice s 0 j) = assert (equal (slice s 0 i @| slice s i j) (slice s 0 j)); ()
{ "file_name": "vale/code/lib/collections/Vale.Lib.Seqs.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 71, "start_col": 0, "start_line": 66 }
module Vale.Lib.Seqs open FStar.Mul let lemma_slice_first_exactly_in_append (#a:Type) (x y:seq a) : Lemma (slice (append x y) 0 (length x) == x) = let xy = append x y in let xy_slice = slice xy 0 (length x) in let x_slice = slice x 0 (length x) in assert(equal xy_slice x_slice); // OBSERVE: extensionality () let lemma_all_but_last_append (#t:Type) (a:seq t) (b:seq t{length b > 0}) : Lemma (all_but_last (append a b) == append a (all_but_last b)) = let ab = all_but_last (append a b) in let app_a_b = append a (all_but_last b) in assert (equal ab app_a_b) // OBSERVE: extensionality let reverse_seq_append (#a:eqtype) (s:seq a) (t:seq a) : Lemma(ensures reverse_seq (append s t) == append (reverse_seq t) (reverse_seq s)) = assert (equal (reverse_seq (append s t)) (append (reverse_seq t) (reverse_seq s))) let reverse_reverse_seq (#a:Type) (s:seq a) : Lemma(ensures reverse_seq (reverse_seq s) == s) = assert (equal (reverse_seq (reverse_seq s)) s) let rec seq_map_i_indexed (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) (i:int) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f (i + j) (index s j)) }) (decreases %[(length s)]) = if length s = 0 then empty else cons (f i (head s)) (seq_map_i_indexed f (tail s) (i + 1)) let seq_map_i (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f j (index s j)) }) = seq_map_i_indexed f s 0 let seq_map_internal_associative (#a:Type) (#b:eqtype) (f:int->a->b) (s:seq a) (pivot:int{0 <= pivot /\ pivot < length s}) : Lemma (let left,right = split s pivot in seq_map_i f s == seq_map_i_indexed f left 0 @| seq_map_i_indexed f right pivot ) = let left,right = split s pivot in let full_map = seq_map_i f s in let part1 = seq_map_i_indexed f left 0 in let part2 = seq_map_i_indexed f right pivot in assert (equal (seq_map_i f s) (seq_map_i_indexed f left 0 @| seq_map_i_indexed f right pivot)); () let seq_map_inverses (#a #b:Type) (f:a -> b) (g:b -> a) (s:seq a) : Lemma (requires forall x . g (f x) == x) (ensures seq_map g (seq_map f s) == s) = let mid = seq_map f s in let final = seq_map g mid in assert (equal s final); ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Lib.Seqs.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.Seq.Base.seq a -> i: Prims.nat -> j: Prims.nat{i <= j /\ j <= FStar.Seq.Base.length s} -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.slice s 0 i @| FStar.Seq.Base.slice s i j == FStar.Seq.Base.slice s 0 j)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.length", "Prims.unit", "Prims._assert", "FStar.Seq.Base.equal", "FStar.Seq.Base.op_At_Bar", "FStar.Seq.Base.slice", "Prims.l_True", "Prims.squash", "Prims.eq2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let slice_append_adds (#a: Type) (s: seq a) (i: nat) (j: nat{i <= j /\ j <= length s}) : Lemma (slice s 0 i @| slice s i j == slice s 0 j) =
assert (equal (slice s 0 i @| slice s i j) (slice s 0 j)); ()
false
Vale.Lib.Seqs.fst
Vale.Lib.Seqs.list_to_seq
val list_to_seq (#a:Type) (l:list a) : Pure (seq a) (requires True) (ensures fun s -> Seq.length s == List.length l)
val list_to_seq (#a:Type) (l:list a) : Pure (seq a) (requires True) (ensures fun s -> Seq.length s == List.length l)
let list_to_seq #a l = Seq.seq_of_list l
{ "file_name": "vale/code/lib/collections/Vale.Lib.Seqs.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 19, "end_line": 91, "start_col": 0, "start_line": 90 }
module Vale.Lib.Seqs open FStar.Mul let lemma_slice_first_exactly_in_append (#a:Type) (x y:seq a) : Lemma (slice (append x y) 0 (length x) == x) = let xy = append x y in let xy_slice = slice xy 0 (length x) in let x_slice = slice x 0 (length x) in assert(equal xy_slice x_slice); // OBSERVE: extensionality () let lemma_all_but_last_append (#t:Type) (a:seq t) (b:seq t{length b > 0}) : Lemma (all_but_last (append a b) == append a (all_but_last b)) = let ab = all_but_last (append a b) in let app_a_b = append a (all_but_last b) in assert (equal ab app_a_b) // OBSERVE: extensionality let reverse_seq_append (#a:eqtype) (s:seq a) (t:seq a) : Lemma(ensures reverse_seq (append s t) == append (reverse_seq t) (reverse_seq s)) = assert (equal (reverse_seq (append s t)) (append (reverse_seq t) (reverse_seq s))) let reverse_reverse_seq (#a:Type) (s:seq a) : Lemma(ensures reverse_seq (reverse_seq s) == s) = assert (equal (reverse_seq (reverse_seq s)) s) let rec seq_map_i_indexed (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) (i:int) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f (i + j) (index s j)) }) (decreases %[(length s)]) = if length s = 0 then empty else cons (f i (head s)) (seq_map_i_indexed f (tail s) (i + 1)) let seq_map_i (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f j (index s j)) }) = seq_map_i_indexed f s 0 let seq_map_internal_associative (#a:Type) (#b:eqtype) (f:int->a->b) (s:seq a) (pivot:int{0 <= pivot /\ pivot < length s}) : Lemma (let left,right = split s pivot in seq_map_i f s == seq_map_i_indexed f left 0 @| seq_map_i_indexed f right pivot ) = let left,right = split s pivot in let full_map = seq_map_i f s in let part1 = seq_map_i_indexed f left 0 in let part2 = seq_map_i_indexed f right pivot in assert (equal (seq_map_i f s) (seq_map_i_indexed f left 0 @| seq_map_i_indexed f right pivot)); () let seq_map_inverses (#a #b:Type) (f:a -> b) (g:b -> a) (s:seq a) : Lemma (requires forall x . g (f x) == x) (ensures seq_map g (seq_map f s) == s) = let mid = seq_map f s in let final = seq_map g mid in assert (equal s final); () let slice_append_adds (#a:Type) (s:seq a) (i:nat) (j:nat{ i <= j /\ j <= length s }) : Lemma (slice s 0 i @| slice s i j == slice s 0 j) = assert (equal (slice s 0 i @| slice s i j) (slice s 0 j)); () let slice_seq_map_commute (#a #b:Type) (f:a -> b) (s:seq a) (i:nat) (j:nat{ i <= j /\ j <= length s }) : Lemma (slice (seq_map f s) i j == seq_map f (slice s i j)) = assert (equal (slice (seq_map f s) i j) (seq_map f (slice s i j))); () let append_distributes_seq_map (#a #b:Type) (f:a -> b) (s1 s2:seq a) : Lemma (seq_map f (s1 @| s2) == seq_map f s1 @| seq_map f s2) = assert (equal (seq_map f (s1 @| s2)) (seq_map f s1 @| seq_map f s2)); () let seq_map_injective #a #b f s s' = assert (forall (i:nat).{:pattern index s i} i < length s ==> index (seq_map f s) i == f (index s i)); assert (forall (i:nat).{:pattern index s i} i < length s ==> index (seq_map f s') i == f (index s' i)); assert (equal s s')
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Lib.Seqs.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
l: Prims.list a -> Prims.Pure (FStar.Seq.Base.seq a)
Prims.Pure
[]
[]
[ "Prims.list", "FStar.Seq.Base.seq_of_list", "FStar.Seq.Base.seq" ]
[]
false
false
false
false
false
let list_to_seq #a l =
Seq.seq_of_list l
false
Simple.fst
Simple.eq_int_list
val eq_int_list (l m: list int) : Tot bool (decreases l)
val eq_int_list (l m: list int) : Tot bool (decreases l)
let rec eq_int_list (l m :list int) : Tot bool (decreases l) = match l, m with | [], [] -> true | l::ls, m::ms -> l = m && eq_int_list ls ms | _ -> false
{ "file_name": "examples/native_tactics/Simple.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 14, "end_line": 55, "start_col": 0, "start_line": 51 }
(* 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 Simple [@@ plugin] let id (x:int{x >= 0}) = let rec countdown (y:nat) = if y=0 then x else countdown (y - 1) in countdown x [@@ plugin] let poly_id (#a:Type) (x:int{x >= 0}) (r:a) : a = let rec countdown (y:nat) = if y=0 then r else countdown (y - 1) in countdown x [@@ plugin] let mk_n_list (#a:Type) (n:nat) (x:a) : list a = let rec aux (n:nat) out = if n = 0 then out else aux (n - 1) (x :: out) in aux n [] [@@ plugin] let poly_list_id (#a:Type) (l:list a) = let rec aux (l:list a) (out:list a) = match l with | [] -> List.Tot.rev out | hd::tl -> aux tl (hd::out) in aux l []
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Simple.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
l: Prims.list Prims.int -> m: Prims.list Prims.int -> Prims.Tot Prims.bool
Prims.Tot
[ "total", "" ]
[]
[ "Prims.list", "Prims.int", "FStar.Pervasives.Native.Mktuple2", "Prims.op_AmpAmp", "Prims.op_Equality", "Simple.eq_int_list", "FStar.Pervasives.Native.tuple2", "Prims.bool" ]
[ "recursion" ]
false
false
false
true
false
let rec eq_int_list (l m: list int) : Tot bool (decreases l) =
match l, m with | [], [] -> true | l :: ls, m :: ms -> l = m && eq_int_list ls ms | _ -> false
false
Vale.Lib.Seqs.fst
Vale.Lib.Seqs.seq_map_internal_associative
val seq_map_internal_associative (#a:Type) (#b:eqtype) (f:int->a->b) (s:seq a) (pivot:int{0 <= pivot /\ pivot < length s}) : Lemma (let left,right = split s pivot in seq_map_i f s == seq_map_i_indexed f left 0 @| seq_map_i_indexed f right pivot )
val seq_map_internal_associative (#a:Type) (#b:eqtype) (f:int->a->b) (s:seq a) (pivot:int{0 <= pivot /\ pivot < length s}) : Lemma (let left,right = split s pivot in seq_map_i f s == seq_map_i_indexed f left 0 @| seq_map_i_indexed f right pivot )
let seq_map_internal_associative (#a:Type) (#b:eqtype) (f:int->a->b) (s:seq a) (pivot:int{0 <= pivot /\ pivot < length s}) : Lemma (let left,right = split s pivot in seq_map_i f s == seq_map_i_indexed f left 0 @| seq_map_i_indexed f right pivot ) = let left,right = split s pivot in let full_map = seq_map_i f s in let part1 = seq_map_i_indexed f left 0 in let part2 = seq_map_i_indexed f right pivot in assert (equal (seq_map_i f s) (seq_map_i_indexed f left 0 @| seq_map_i_indexed f right pivot)); ()
{ "file_name": "vale/code/lib/collections/Vale.Lib.Seqs.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 55, "start_col": 0, "start_line": 46 }
module Vale.Lib.Seqs open FStar.Mul let lemma_slice_first_exactly_in_append (#a:Type) (x y:seq a) : Lemma (slice (append x y) 0 (length x) == x) = let xy = append x y in let xy_slice = slice xy 0 (length x) in let x_slice = slice x 0 (length x) in assert(equal xy_slice x_slice); // OBSERVE: extensionality () let lemma_all_but_last_append (#t:Type) (a:seq t) (b:seq t{length b > 0}) : Lemma (all_but_last (append a b) == append a (all_but_last b)) = let ab = all_but_last (append a b) in let app_a_b = append a (all_but_last b) in assert (equal ab app_a_b) // OBSERVE: extensionality let reverse_seq_append (#a:eqtype) (s:seq a) (t:seq a) : Lemma(ensures reverse_seq (append s t) == append (reverse_seq t) (reverse_seq s)) = assert (equal (reverse_seq (append s t)) (append (reverse_seq t) (reverse_seq s))) let reverse_reverse_seq (#a:Type) (s:seq a) : Lemma(ensures reverse_seq (reverse_seq s) == s) = assert (equal (reverse_seq (reverse_seq s)) s) let rec seq_map_i_indexed (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) (i:int) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f (i + j) (index s j)) }) (decreases %[(length s)]) = if length s = 0 then empty else cons (f i (head s)) (seq_map_i_indexed f (tail s) (i + 1)) let seq_map_i (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f j (index s j)) }) = seq_map_i_indexed f s 0
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Lib.Seqs.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: Prims.int -> _: a -> b) -> s: FStar.Seq.Base.seq a -> pivot: Prims.int{0 <= pivot /\ pivot < FStar.Seq.Base.length s} -> FStar.Pervasives.Lemma (ensures (let _ = FStar.Seq.Properties.split s pivot in (let FStar.Pervasives.Native.Mktuple2 #_ #_ left right = _ in Vale.Lib.Seqs.seq_map_i f s == Vale.Lib.Seqs.seq_map_i_indexed f left 0 @| Vale.Lib.Seqs.seq_map_i_indexed f right pivot) <: Type0))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.eqtype", "Prims.int", "FStar.Seq.Base.seq", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "FStar.Seq.Base.length", "Prims.unit", "Prims._assert", "FStar.Seq.Base.equal", "Vale.Lib.Seqs.seq_map_i", "FStar.Seq.Base.op_At_Bar", "Vale.Lib.Seqs.seq_map_i_indexed", "Prims.eq2", "Prims.nat", "Prims.l_Forall", "Prims.op_GreaterThanOrEqual", "Prims.l_imp", "FStar.Seq.Base.index", "Prims.op_Addition", "FStar.Pervasives.Native.tuple2", "FStar.Seq.Properties.split", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let seq_map_internal_associative (#a: Type) (#b: eqtype) (f: (int -> a -> b)) (s: seq a) (pivot: int{0 <= pivot /\ pivot < length s}) : Lemma (let left, right = split s pivot in seq_map_i f s == seq_map_i_indexed f left 0 @| seq_map_i_indexed f right pivot) =
let left, right = split s pivot in let full_map = seq_map_i f s in let part1 = seq_map_i_indexed f left 0 in let part2 = seq_map_i_indexed f right pivot in assert (equal (seq_map_i f s) (seq_map_i_indexed f left 0 @| seq_map_i_indexed f right pivot)); ()
false
Vale.Lib.Seqs.fst
Vale.Lib.Seqs.slice_seq_map_commute
val slice_seq_map_commute (#a #b:Type) (f:a -> b) (s:seq a) (i:nat) (j:nat{ i <= j /\ j <= length s }) : Lemma (slice (seq_map f s) i j == seq_map f (slice s i j))
val slice_seq_map_commute (#a #b:Type) (f:a -> b) (s:seq a) (i:nat) (j:nat{ i <= j /\ j <= length s }) : Lemma (slice (seq_map f s) i j == seq_map f (slice s i j))
let slice_seq_map_commute (#a #b:Type) (f:a -> b) (s:seq a) (i:nat) (j:nat{ i <= j /\ j <= length s }) : Lemma (slice (seq_map f s) i j == seq_map f (slice s i j)) = assert (equal (slice (seq_map f s) i j) (seq_map f (slice s i j))); ()
{ "file_name": "vale/code/lib/collections/Vale.Lib.Seqs.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 77, "start_col": 0, "start_line": 73 }
module Vale.Lib.Seqs open FStar.Mul let lemma_slice_first_exactly_in_append (#a:Type) (x y:seq a) : Lemma (slice (append x y) 0 (length x) == x) = let xy = append x y in let xy_slice = slice xy 0 (length x) in let x_slice = slice x 0 (length x) in assert(equal xy_slice x_slice); // OBSERVE: extensionality () let lemma_all_but_last_append (#t:Type) (a:seq t) (b:seq t{length b > 0}) : Lemma (all_but_last (append a b) == append a (all_but_last b)) = let ab = all_but_last (append a b) in let app_a_b = append a (all_but_last b) in assert (equal ab app_a_b) // OBSERVE: extensionality let reverse_seq_append (#a:eqtype) (s:seq a) (t:seq a) : Lemma(ensures reverse_seq (append s t) == append (reverse_seq t) (reverse_seq s)) = assert (equal (reverse_seq (append s t)) (append (reverse_seq t) (reverse_seq s))) let reverse_reverse_seq (#a:Type) (s:seq a) : Lemma(ensures reverse_seq (reverse_seq s) == s) = assert (equal (reverse_seq (reverse_seq s)) s) let rec seq_map_i_indexed (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) (i:int) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f (i + j) (index s j)) }) (decreases %[(length s)]) = if length s = 0 then empty else cons (f i (head s)) (seq_map_i_indexed f (tail s) (i + 1)) let seq_map_i (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f j (index s j)) }) = seq_map_i_indexed f s 0 let seq_map_internal_associative (#a:Type) (#b:eqtype) (f:int->a->b) (s:seq a) (pivot:int{0 <= pivot /\ pivot < length s}) : Lemma (let left,right = split s pivot in seq_map_i f s == seq_map_i_indexed f left 0 @| seq_map_i_indexed f right pivot ) = let left,right = split s pivot in let full_map = seq_map_i f s in let part1 = seq_map_i_indexed f left 0 in let part2 = seq_map_i_indexed f right pivot in assert (equal (seq_map_i f s) (seq_map_i_indexed f left 0 @| seq_map_i_indexed f right pivot)); () let seq_map_inverses (#a #b:Type) (f:a -> b) (g:b -> a) (s:seq a) : Lemma (requires forall x . g (f x) == x) (ensures seq_map g (seq_map f s) == s) = let mid = seq_map f s in let final = seq_map g mid in assert (equal s final); () let slice_append_adds (#a:Type) (s:seq a) (i:nat) (j:nat{ i <= j /\ j <= length s }) : Lemma (slice s 0 i @| slice s i j == slice s 0 j) = assert (equal (slice s 0 i @| slice s i j) (slice s 0 j)); ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Lib.Seqs.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: a -> b) -> s: FStar.Seq.Base.seq a -> i: Prims.nat -> j: Prims.nat{i <= j /\ j <= FStar.Seq.Base.length s} -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.slice (Vale.Lib.Seqs_s.seq_map f s) i j == Vale.Lib.Seqs_s.seq_map f (FStar.Seq.Base.slice s i j))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.length", "Prims.unit", "Prims._assert", "FStar.Seq.Base.equal", "FStar.Seq.Base.slice", "Vale.Lib.Seqs_s.seq_map", "Prims.l_True", "Prims.squash", "Prims.eq2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let slice_seq_map_commute (#a #b: Type) (f: (a -> b)) (s: seq a) (i: nat) (j: nat{i <= j /\ j <= length s}) : Lemma (slice (seq_map f s) i j == seq_map f (slice s i j)) =
assert (equal (slice (seq_map f s) i j) (seq_map f (slice s i j))); ()
false
Vale.Lib.Seqs.fst
Vale.Lib.Seqs.seq_map_injective
val seq_map_injective (#a #b:Type) (f:a -> b) (s s':seq a) : Lemma (requires (forall (x x':a).{:pattern (f x); (f x')} f x == f x' ==> x == x') /\ seq_map f s == seq_map f s') (ensures s == s')
val seq_map_injective (#a #b:Type) (f:a -> b) (s s':seq a) : Lemma (requires (forall (x x':a).{:pattern (f x); (f x')} f x == f x' ==> x == x') /\ seq_map f s == seq_map f s') (ensures s == s')
let seq_map_injective #a #b f s s' = assert (forall (i:nat).{:pattern index s i} i < length s ==> index (seq_map f s) i == f (index s i)); assert (forall (i:nat).{:pattern index s i} i < length s ==> index (seq_map f s') i == f (index s' i)); assert (equal s s')
{ "file_name": "vale/code/lib/collections/Vale.Lib.Seqs.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 21, "end_line": 88, "start_col": 0, "start_line": 85 }
module Vale.Lib.Seqs open FStar.Mul let lemma_slice_first_exactly_in_append (#a:Type) (x y:seq a) : Lemma (slice (append x y) 0 (length x) == x) = let xy = append x y in let xy_slice = slice xy 0 (length x) in let x_slice = slice x 0 (length x) in assert(equal xy_slice x_slice); // OBSERVE: extensionality () let lemma_all_but_last_append (#t:Type) (a:seq t) (b:seq t{length b > 0}) : Lemma (all_but_last (append a b) == append a (all_but_last b)) = let ab = all_but_last (append a b) in let app_a_b = append a (all_but_last b) in assert (equal ab app_a_b) // OBSERVE: extensionality let reverse_seq_append (#a:eqtype) (s:seq a) (t:seq a) : Lemma(ensures reverse_seq (append s t) == append (reverse_seq t) (reverse_seq s)) = assert (equal (reverse_seq (append s t)) (append (reverse_seq t) (reverse_seq s))) let reverse_reverse_seq (#a:Type) (s:seq a) : Lemma(ensures reverse_seq (reverse_seq s) == s) = assert (equal (reverse_seq (reverse_seq s)) s) let rec seq_map_i_indexed (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) (i:int) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f (i + j) (index s j)) }) (decreases %[(length s)]) = if length s = 0 then empty else cons (f i (head s)) (seq_map_i_indexed f (tail s) (i + 1)) let seq_map_i (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f j (index s j)) }) = seq_map_i_indexed f s 0 let seq_map_internal_associative (#a:Type) (#b:eqtype) (f:int->a->b) (s:seq a) (pivot:int{0 <= pivot /\ pivot < length s}) : Lemma (let left,right = split s pivot in seq_map_i f s == seq_map_i_indexed f left 0 @| seq_map_i_indexed f right pivot ) = let left,right = split s pivot in let full_map = seq_map_i f s in let part1 = seq_map_i_indexed f left 0 in let part2 = seq_map_i_indexed f right pivot in assert (equal (seq_map_i f s) (seq_map_i_indexed f left 0 @| seq_map_i_indexed f right pivot)); () let seq_map_inverses (#a #b:Type) (f:a -> b) (g:b -> a) (s:seq a) : Lemma (requires forall x . g (f x) == x) (ensures seq_map g (seq_map f s) == s) = let mid = seq_map f s in let final = seq_map g mid in assert (equal s final); () let slice_append_adds (#a:Type) (s:seq a) (i:nat) (j:nat{ i <= j /\ j <= length s }) : Lemma (slice s 0 i @| slice s i j == slice s 0 j) = assert (equal (slice s 0 i @| slice s i j) (slice s 0 j)); () let slice_seq_map_commute (#a #b:Type) (f:a -> b) (s:seq a) (i:nat) (j:nat{ i <= j /\ j <= length s }) : Lemma (slice (seq_map f s) i j == seq_map f (slice s i j)) = assert (equal (slice (seq_map f s) i j) (seq_map f (slice s i j))); () let append_distributes_seq_map (#a #b:Type) (f:a -> b) (s1 s2:seq a) : Lemma (seq_map f (s1 @| s2) == seq_map f s1 @| seq_map f s2) = assert (equal (seq_map f (s1 @| s2)) (seq_map f s1 @| seq_map f s2)); ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Lib.Seqs.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: a -> b) -> s: FStar.Seq.Base.seq a -> s': FStar.Seq.Base.seq a -> FStar.Pervasives.Lemma (requires (forall (x: a) (x': a). {:pattern f x; f x'} f x == f x' ==> x == x') /\ Vale.Lib.Seqs_s.seq_map f s == Vale.Lib.Seqs_s.seq_map f s') (ensures s == s')
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Prims._assert", "FStar.Seq.Base.equal", "Prims.unit", "Prims.l_Forall", "Prims.nat", "Prims.l_imp", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "Prims.eq2", "FStar.Seq.Base.index", "Vale.Lib.Seqs_s.seq_map" ]
[]
false
false
true
false
false
let seq_map_injective #a #b f s s' =
assert (forall (i: nat). {:pattern index s i} i < length s ==> index (seq_map f s) i == f (index s i)); assert (forall (i: nat). {:pattern index s i} i < length s ==> index (seq_map f s') i == f (index s' i)); assert (equal s s')
false
FStar.Reflection.V2.Arith.fst
FStar.Reflection.V2.Arith.lt
val lt : e1: FStar.Reflection.V2.Arith.expr -> e2: FStar.Reflection.V2.Arith.expr -> FStar.Reflection.V2.Arith.prop
let lt e1 e2 = CompProp e1 C_Lt e2
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 34, "end_line": 65, "start_col": 0, "start_line": 65 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e1: FStar.Reflection.V2.Arith.expr -> e2: FStar.Reflection.V2.Arith.expr -> FStar.Reflection.V2.Arith.prop
Prims.Tot
[ "total" ]
[]
[ "FStar.Reflection.V2.Arith.expr", "FStar.Reflection.V2.Arith.CompProp", "FStar.Reflection.V2.Arith.C_Lt", "FStar.Reflection.V2.Arith.prop" ]
[]
false
false
false
true
false
let lt e1 e2 =
CompProp e1 C_Lt e2
false
Vale.Lib.Seqs.fst
Vale.Lib.Seqs.append_distributes_seq_map
val append_distributes_seq_map (#a #b:Type) (f:a -> b) (s1 s2:seq a) : Lemma (seq_map f (s1 @| s2) == seq_map f s1 @| seq_map f s2)
val append_distributes_seq_map (#a #b:Type) (f:a -> b) (s1 s2:seq a) : Lemma (seq_map f (s1 @| s2) == seq_map f s1 @| seq_map f s2)
let append_distributes_seq_map (#a #b:Type) (f:a -> b) (s1 s2:seq a) : Lemma (seq_map f (s1 @| s2) == seq_map f s1 @| seq_map f s2) = assert (equal (seq_map f (s1 @| s2)) (seq_map f s1 @| seq_map f s2)); ()
{ "file_name": "vale/code/lib/collections/Vale.Lib.Seqs.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 83, "start_col": 0, "start_line": 79 }
module Vale.Lib.Seqs open FStar.Mul let lemma_slice_first_exactly_in_append (#a:Type) (x y:seq a) : Lemma (slice (append x y) 0 (length x) == x) = let xy = append x y in let xy_slice = slice xy 0 (length x) in let x_slice = slice x 0 (length x) in assert(equal xy_slice x_slice); // OBSERVE: extensionality () let lemma_all_but_last_append (#t:Type) (a:seq t) (b:seq t{length b > 0}) : Lemma (all_but_last (append a b) == append a (all_but_last b)) = let ab = all_but_last (append a b) in let app_a_b = append a (all_but_last b) in assert (equal ab app_a_b) // OBSERVE: extensionality let reverse_seq_append (#a:eqtype) (s:seq a) (t:seq a) : Lemma(ensures reverse_seq (append s t) == append (reverse_seq t) (reverse_seq s)) = assert (equal (reverse_seq (append s t)) (append (reverse_seq t) (reverse_seq s))) let reverse_reverse_seq (#a:Type) (s:seq a) : Lemma(ensures reverse_seq (reverse_seq s) == s) = assert (equal (reverse_seq (reverse_seq s)) s) let rec seq_map_i_indexed (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) (i:int) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f (i + j) (index s j)) }) (decreases %[(length s)]) = if length s = 0 then empty else cons (f i (head s)) (seq_map_i_indexed f (tail s) (i + 1)) let seq_map_i (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f j (index s j)) }) = seq_map_i_indexed f s 0 let seq_map_internal_associative (#a:Type) (#b:eqtype) (f:int->a->b) (s:seq a) (pivot:int{0 <= pivot /\ pivot < length s}) : Lemma (let left,right = split s pivot in seq_map_i f s == seq_map_i_indexed f left 0 @| seq_map_i_indexed f right pivot ) = let left,right = split s pivot in let full_map = seq_map_i f s in let part1 = seq_map_i_indexed f left 0 in let part2 = seq_map_i_indexed f right pivot in assert (equal (seq_map_i f s) (seq_map_i_indexed f left 0 @| seq_map_i_indexed f right pivot)); () let seq_map_inverses (#a #b:Type) (f:a -> b) (g:b -> a) (s:seq a) : Lemma (requires forall x . g (f x) == x) (ensures seq_map g (seq_map f s) == s) = let mid = seq_map f s in let final = seq_map g mid in assert (equal s final); () let slice_append_adds (#a:Type) (s:seq a) (i:nat) (j:nat{ i <= j /\ j <= length s }) : Lemma (slice s 0 i @| slice s i j == slice s 0 j) = assert (equal (slice s 0 i @| slice s i j) (slice s 0 j)); () let slice_seq_map_commute (#a #b:Type) (f:a -> b) (s:seq a) (i:nat) (j:nat{ i <= j /\ j <= length s }) : Lemma (slice (seq_map f s) i j == seq_map f (slice s i j)) = assert (equal (slice (seq_map f s) i j) (seq_map f (slice s i j))); ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Lib.Seqs.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: a -> b) -> s1: FStar.Seq.Base.seq a -> s2: FStar.Seq.Base.seq a -> FStar.Pervasives.Lemma (ensures Vale.Lib.Seqs_s.seq_map f (s1 @| s2) == Vale.Lib.Seqs_s.seq_map f s1 @| Vale.Lib.Seqs_s.seq_map f s2)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Prims.unit", "Prims._assert", "FStar.Seq.Base.equal", "Vale.Lib.Seqs_s.seq_map", "FStar.Seq.Base.op_At_Bar", "Prims.l_True", "Prims.squash", "Prims.eq2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let append_distributes_seq_map (#a #b: Type) (f: (a -> b)) (s1 s2: seq a) : Lemma (seq_map f (s1 @| s2) == seq_map f s1 @| seq_map f s2) =
assert (equal (seq_map f (s1 @| s2)) (seq_map f s1 @| seq_map f s2)); ()
false
FStar.Reflection.V2.Arith.fst
FStar.Reflection.V2.Arith.eq
val eq : e1: FStar.Reflection.V2.Arith.expr -> e2: FStar.Reflection.V2.Arith.expr -> FStar.Reflection.V2.Arith.prop
let eq e1 e2 = CompProp e1 C_Eq e2
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 34, "end_line": 67, "start_col": 0, "start_line": 67 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e1: FStar.Reflection.V2.Arith.expr -> e2: FStar.Reflection.V2.Arith.expr -> FStar.Reflection.V2.Arith.prop
Prims.Tot
[ "total" ]
[]
[ "FStar.Reflection.V2.Arith.expr", "FStar.Reflection.V2.Arith.CompProp", "FStar.Reflection.V2.Arith.C_Eq", "FStar.Reflection.V2.Arith.prop" ]
[]
false
false
false
true
false
let eq e1 e2 =
CompProp e1 C_Eq e2
false
FStar.Reflection.V2.Arith.fst
FStar.Reflection.V2.Arith.ne
val ne : e1: FStar.Reflection.V2.Arith.expr -> e2: FStar.Reflection.V2.Arith.expr -> FStar.Reflection.V2.Arith.prop
let ne e1 e2 = CompProp e1 C_Ne e2
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 34, "end_line": 68, "start_col": 0, "start_line": 68 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e1: FStar.Reflection.V2.Arith.expr -> e2: FStar.Reflection.V2.Arith.expr -> FStar.Reflection.V2.Arith.prop
Prims.Tot
[ "total" ]
[]
[ "FStar.Reflection.V2.Arith.expr", "FStar.Reflection.V2.Arith.CompProp", "FStar.Reflection.V2.Arith.C_Ne", "FStar.Reflection.V2.Arith.prop" ]
[]
false
false
false
true
false
let ne e1 e2 =
CompProp e1 C_Ne e2
false
FStar.Reflection.V2.Arith.fst
FStar.Reflection.V2.Arith.le
val le : e1: FStar.Reflection.V2.Arith.expr -> e2: FStar.Reflection.V2.Arith.expr -> FStar.Reflection.V2.Arith.prop
let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2)
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 49, "end_line": 66, "start_col": 0, "start_line": 66 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e1: FStar.Reflection.V2.Arith.expr -> e2: FStar.Reflection.V2.Arith.expr -> FStar.Reflection.V2.Arith.prop
Prims.Tot
[ "total" ]
[]
[ "FStar.Reflection.V2.Arith.expr", "FStar.Reflection.V2.Arith.CompProp", "FStar.Reflection.V2.Arith.C_Lt", "FStar.Reflection.V2.Arith.Plus", "FStar.Reflection.V2.Arith.Lit", "FStar.Reflection.V2.Arith.prop" ]
[]
false
false
false
true
false
let le e1 e2 =
CompProp e1 C_Lt (Plus (Lit 1) e2)
false
FStar.Reflection.V2.Arith.fst
FStar.Reflection.V2.Arith.return
val return (x: 'a) : tm 'a
val return (x: 'a) : tm 'a
let return (x:'a) : tm 'a = fun i -> Inr (x, i)
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 55, "end_line": 75, "start_col": 8, "start_line": 75 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2) let eq e1 e2 = CompProp e1 C_Eq e2 let ne e1 e2 = CompProp e1 C_Ne e2 let gt e1 e2 = CompProp e1 C_Gt e2 let ge e1 e2 = CompProp (Plus (Lit 1) e1) C_Gt e2 (* Define a traversal monad! Makes exception handling and counter-keeping easy *) private let st = p:(nat * list term){fst p == List.Tot.Base.length (snd p)}
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: 'a -> FStar.Reflection.V2.Arith.tm 'a
Prims.Tot
[ "total" ]
[]
[ "FStar.Reflection.V2.Arith.st", "FStar.Pervasives.Inr", "Prims.string", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.either", "FStar.Reflection.V2.Arith.tm" ]
[]
false
false
false
true
false
let return (x: 'a) : tm 'a =
fun i -> Inr (x, i)
false
Vale.Lib.Seqs.fst
Vale.Lib.Seqs.lemma_list_to_seq
val lemma_list_to_seq (#a:Type) (l:list a) : Lemma (ensures norm [zeta; iota; delta_only [`%list_to_seq_post]] (list_to_seq_post l (list_to_seq l) 0))
val lemma_list_to_seq (#a:Type) (l:list a) : Lemma (ensures norm [zeta; iota; delta_only [`%list_to_seq_post]] (list_to_seq_post l (list_to_seq l) 0))
let lemma_list_to_seq #a l = lemma_list_to_seq_rec l (list_to_seq l) 0
{ "file_name": "vale/code/lib/collections/Vale.Lib.Seqs.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 43, "end_line": 123, "start_col": 0, "start_line": 122 }
module Vale.Lib.Seqs open FStar.Mul let lemma_slice_first_exactly_in_append (#a:Type) (x y:seq a) : Lemma (slice (append x y) 0 (length x) == x) = let xy = append x y in let xy_slice = slice xy 0 (length x) in let x_slice = slice x 0 (length x) in assert(equal xy_slice x_slice); // OBSERVE: extensionality () let lemma_all_but_last_append (#t:Type) (a:seq t) (b:seq t{length b > 0}) : Lemma (all_but_last (append a b) == append a (all_but_last b)) = let ab = all_but_last (append a b) in let app_a_b = append a (all_but_last b) in assert (equal ab app_a_b) // OBSERVE: extensionality let reverse_seq_append (#a:eqtype) (s:seq a) (t:seq a) : Lemma(ensures reverse_seq (append s t) == append (reverse_seq t) (reverse_seq s)) = assert (equal (reverse_seq (append s t)) (append (reverse_seq t) (reverse_seq s))) let reverse_reverse_seq (#a:Type) (s:seq a) : Lemma(ensures reverse_seq (reverse_seq s) == s) = assert (equal (reverse_seq (reverse_seq s)) s) let rec seq_map_i_indexed (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) (i:int) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f (i + j) (index s j)) }) (decreases %[(length s)]) = if length s = 0 then empty else cons (f i (head s)) (seq_map_i_indexed f (tail s) (i + 1)) let seq_map_i (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f j (index s j)) }) = seq_map_i_indexed f s 0 let seq_map_internal_associative (#a:Type) (#b:eqtype) (f:int->a->b) (s:seq a) (pivot:int{0 <= pivot /\ pivot < length s}) : Lemma (let left,right = split s pivot in seq_map_i f s == seq_map_i_indexed f left 0 @| seq_map_i_indexed f right pivot ) = let left,right = split s pivot in let full_map = seq_map_i f s in let part1 = seq_map_i_indexed f left 0 in let part2 = seq_map_i_indexed f right pivot in assert (equal (seq_map_i f s) (seq_map_i_indexed f left 0 @| seq_map_i_indexed f right pivot)); () let seq_map_inverses (#a #b:Type) (f:a -> b) (g:b -> a) (s:seq a) : Lemma (requires forall x . g (f x) == x) (ensures seq_map g (seq_map f s) == s) = let mid = seq_map f s in let final = seq_map g mid in assert (equal s final); () let slice_append_adds (#a:Type) (s:seq a) (i:nat) (j:nat{ i <= j /\ j <= length s }) : Lemma (slice s 0 i @| slice s i j == slice s 0 j) = assert (equal (slice s 0 i @| slice s i j) (slice s 0 j)); () let slice_seq_map_commute (#a #b:Type) (f:a -> b) (s:seq a) (i:nat) (j:nat{ i <= j /\ j <= length s }) : Lemma (slice (seq_map f s) i j == seq_map f (slice s i j)) = assert (equal (slice (seq_map f s) i j) (seq_map f (slice s i j))); () let append_distributes_seq_map (#a #b:Type) (f:a -> b) (s1 s2:seq a) : Lemma (seq_map f (s1 @| s2) == seq_map f s1 @| seq_map f s2) = assert (equal (seq_map f (s1 @| s2)) (seq_map f s1 @| seq_map f s2)); () let seq_map_injective #a #b f s s' = assert (forall (i:nat).{:pattern index s i} i < length s ==> index (seq_map f s) i == f (index s i)); assert (forall (i:nat).{:pattern index s i} i < length s ==> index (seq_map f s') i == f (index s' i)); assert (equal s s') let list_to_seq #a l = Seq.seq_of_list l let reveal_opaque_rec (s:string) = norm_spec [zeta; delta_only [s]] let rec lemma_list_to_seq_rec (#a:Type) (l:list a) (s:seq a) (n:nat) : Lemma (requires n + List.length l == Seq.length s /\ Seq.equal (Seq.slice s n (Seq.length s)) (list_to_seq l)) (ensures list_to_seq_post l s n) (decreases l) = match l with | [] -> () | h::t -> let lem (i:nat) : Lemma (requires i < List.length t) (ensures Seq.index (Seq.slice s (n + 1) (Seq.length s)) i == Seq.index (list_to_seq t) i) [SMTPat (Seq.index (list_to_seq t) i)] = calc (==) { Seq.index (Seq.slice s (n + 1) (Seq.length s)) i; == {} Seq.index (Seq.slice s n (Seq.length s)) (i + 1); == {} Seq.index (list_to_seq l) (i + 1); == {} Seq.index (list_to_seq t) i; } in lemma_list_to_seq_rec t s (n + 1); assert (Seq.index (list_to_seq l) 0 == h); ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Lib.Seqs.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
l: Prims.list a -> FStar.Pervasives.Lemma (ensures FStar.Pervasives.norm [ FStar.Pervasives.zeta; FStar.Pervasives.iota; FStar.Pervasives.delta_only ["Vale.Lib.Seqs.list_to_seq_post"] ] (Vale.Lib.Seqs.list_to_seq_post l (Vale.Lib.Seqs.list_to_seq l) 0))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.list", "Vale.Lib.Seqs.lemma_list_to_seq_rec", "Vale.Lib.Seqs.list_to_seq", "Prims.unit" ]
[]
true
false
true
false
false
let lemma_list_to_seq #a l =
lemma_list_to_seq_rec l (list_to_seq l) 0
false
FStar.Reflection.V2.Arith.fst
FStar.Reflection.V2.Arith.gt
val gt : e1: FStar.Reflection.V2.Arith.expr -> e2: FStar.Reflection.V2.Arith.expr -> FStar.Reflection.V2.Arith.prop
let gt e1 e2 = CompProp e1 C_Gt e2
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 34, "end_line": 69, "start_col": 0, "start_line": 69 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2) let eq e1 e2 = CompProp e1 C_Eq e2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e1: FStar.Reflection.V2.Arith.expr -> e2: FStar.Reflection.V2.Arith.expr -> FStar.Reflection.V2.Arith.prop
Prims.Tot
[ "total" ]
[]
[ "FStar.Reflection.V2.Arith.expr", "FStar.Reflection.V2.Arith.CompProp", "FStar.Reflection.V2.Arith.C_Gt", "FStar.Reflection.V2.Arith.prop" ]
[]
false
false
false
true
false
let gt e1 e2 =
CompProp e1 C_Gt e2
false
FStar.Reflection.V2.Arith.fst
FStar.Reflection.V2.Arith.tm
val tm : a: Type -> Type0
let tm a = st -> Tac (either string (a * st))
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 53, "end_line": 74, "start_col": 8, "start_line": 74 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2) let eq e1 e2 = CompProp e1 C_Eq e2 let ne e1 e2 = CompProp e1 C_Ne e2 let gt e1 e2 = CompProp e1 C_Gt e2 let ge e1 e2 = CompProp (Plus (Lit 1) e1) C_Gt e2 (* Define a traversal monad! Makes exception handling and counter-keeping easy *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Reflection.V2.Arith.st", "FStar.Pervasives.either", "Prims.string", "FStar.Pervasives.Native.tuple2" ]
[]
false
false
false
true
true
let tm a =
st -> Tac (either string (a * st))
false
FStar.Reflection.V2.Arith.fst
FStar.Reflection.V2.Arith.ge
val ge : e1: FStar.Reflection.V2.Arith.expr -> e2: FStar.Reflection.V2.Arith.expr -> FStar.Reflection.V2.Arith.prop
let ge e1 e2 = CompProp (Plus (Lit 1) e1) C_Gt e2
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 49, "end_line": 70, "start_col": 0, "start_line": 70 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2) let eq e1 e2 = CompProp e1 C_Eq e2 let ne e1 e2 = CompProp e1 C_Ne e2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e1: FStar.Reflection.V2.Arith.expr -> e2: FStar.Reflection.V2.Arith.expr -> FStar.Reflection.V2.Arith.prop
Prims.Tot
[ "total" ]
[]
[ "FStar.Reflection.V2.Arith.expr", "FStar.Reflection.V2.Arith.CompProp", "FStar.Reflection.V2.Arith.Plus", "FStar.Reflection.V2.Arith.Lit", "FStar.Reflection.V2.Arith.C_Gt", "FStar.Reflection.V2.Arith.prop" ]
[]
false
false
false
true
false
let ge e1 e2 =
CompProp (Plus (Lit 1) e1) C_Gt e2
false
FStar.Reflection.V2.Arith.fst
FStar.Reflection.V2.Arith.st
val st : Type0
let st = p:(nat * list term){fst p == List.Tot.Base.length (snd p)}
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 75, "end_line": 73, "start_col": 8, "start_line": 73 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2) let eq e1 e2 = CompProp e1 C_Eq e2 let ne e1 e2 = CompProp e1 C_Ne e2 let gt e1 e2 = CompProp e1 C_Gt e2 let ge e1 e2 = CompProp (Plus (Lit 1) e1) C_Gt e2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.tuple2", "Prims.nat", "Prims.list", "FStar.Stubs.Reflection.Types.term", "Prims.eq2", "FStar.Pervasives.Native.fst", "FStar.List.Tot.Base.length", "FStar.Pervasives.Native.snd" ]
[]
false
false
false
true
true
let st =
p: (nat * list term){fst p == List.Tot.Base.length (snd p)}
false
FStar.Reflection.V2.Arith.fst
FStar.Reflection.V2.Arith.lift
val lift : ('a -> Tac 'b) -> ('a -> tm 'b)
val lift : ('a -> Tac 'b) -> ('a -> tm 'b)
let lift f x st = Inr (f x, st)
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 17, "end_line": 83, "start_col": 0, "start_line": 82 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2) let eq e1 e2 = CompProp e1 C_Eq e2 let ne e1 e2 = CompProp e1 C_Ne e2 let gt e1 e2 = CompProp e1 C_Gt e2 let ge e1 e2 = CompProp (Plus (Lit 1) e1) C_Gt e2 (* Define a traversal monad! Makes exception handling and counter-keeping easy *) private let st = p:(nat * list term){fst p == List.Tot.Base.length (snd p)} private let tm a = st -> Tac (either string (a * st)) private let return (x:'a) : tm 'a = fun i -> Inr (x, i) private let (let!) (m : tm 'a) (f : 'a -> tm 'b) : tm 'b = fun i -> match m i with | Inr (x, j) -> f x j | s -> Inl (Inl?.v s) // why? To have a catch-all pattern and thus an easy WP
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: 'a -> FStar.Tactics.Effect.Tac 'b) -> _: 'a -> FStar.Reflection.V2.Arith.tm 'b
Prims.Tot
[ "total" ]
[]
[ "FStar.Reflection.V2.Arith.st", "FStar.Pervasives.Inr", "Prims.string", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.either", "FStar.Pervasives.Native.Mktuple2" ]
[]
false
false
false
false
false
let lift f x st =
Inr (f x, st)
false
FStar.Reflection.V2.Arith.fst
FStar.Reflection.V2.Arith.liftM3
val liftM3 : ('a -> 'b -> 'c -> 'd) -> (tm 'a -> tm 'b -> tm 'c -> tm 'd)
val liftM3 : ('a -> 'b -> 'c -> 'd) -> (tm 'a -> tm 'b -> tm 'c -> tm 'd)
let liftM3 f x y z = let! xx = x in let! yy = y in let! zz = z in return (f xx yy zz)
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 23, "end_line": 101, "start_col": 0, "start_line": 97 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2) let eq e1 e2 = CompProp e1 C_Eq e2 let ne e1 e2 = CompProp e1 C_Ne e2 let gt e1 e2 = CompProp e1 C_Gt e2 let ge e1 e2 = CompProp (Plus (Lit 1) e1) C_Gt e2 (* Define a traversal monad! Makes exception handling and counter-keeping easy *) private let st = p:(nat * list term){fst p == List.Tot.Base.length (snd p)} private let tm a = st -> Tac (either string (a * st)) private let return (x:'a) : tm 'a = fun i -> Inr (x, i) private let (let!) (m : tm 'a) (f : 'a -> tm 'b) : tm 'b = fun i -> match m i with | Inr (x, j) -> f x j | s -> Inl (Inl?.v s) // why? To have a catch-all pattern and thus an easy WP val lift : ('a -> Tac 'b) -> ('a -> tm 'b) let lift f x st = Inr (f x, st) val liftM : ('a -> 'b) -> (tm 'a -> tm 'b) let liftM f x = let! xx = x in return (f xx) val liftM2 : ('a -> 'b -> 'c) -> (tm 'a -> tm 'b -> tm 'c) let liftM2 f x y = let! xx = x in let! yy = y in return (f xx yy)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: 'a -> _: 'b -> _: 'c -> 'd) -> _: FStar.Reflection.V2.Arith.tm 'a -> _: FStar.Reflection.V2.Arith.tm 'b -> _: FStar.Reflection.V2.Arith.tm 'c -> FStar.Reflection.V2.Arith.tm 'd
Prims.Tot
[ "total" ]
[]
[ "FStar.Reflection.V2.Arith.tm", "FStar.Reflection.V2.Arith.op_let_Bang", "FStar.Reflection.V2.Arith.return" ]
[]
false
false
false
true
false
let liftM3 f x y z =
let! xx = x in let! yy = y in let! zz = z in return (f xx yy zz)
false
FStar.Reflection.V2.Arith.fst
FStar.Reflection.V2.Arith.liftM
val liftM : ('a -> 'b) -> (tm 'a -> tm 'b)
val liftM : ('a -> 'b) -> (tm 'a -> tm 'b)
let liftM f x = let! xx = x in return (f xx)
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 17, "end_line": 88, "start_col": 0, "start_line": 86 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2) let eq e1 e2 = CompProp e1 C_Eq e2 let ne e1 e2 = CompProp e1 C_Ne e2 let gt e1 e2 = CompProp e1 C_Gt e2 let ge e1 e2 = CompProp (Plus (Lit 1) e1) C_Gt e2 (* Define a traversal monad! Makes exception handling and counter-keeping easy *) private let st = p:(nat * list term){fst p == List.Tot.Base.length (snd p)} private let tm a = st -> Tac (either string (a * st)) private let return (x:'a) : tm 'a = fun i -> Inr (x, i) private let (let!) (m : tm 'a) (f : 'a -> tm 'b) : tm 'b = fun i -> match m i with | Inr (x, j) -> f x j | s -> Inl (Inl?.v s) // why? To have a catch-all pattern and thus an easy WP val lift : ('a -> Tac 'b) -> ('a -> tm 'b) let lift f x st = Inr (f x, st)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: 'a -> 'b) -> _: FStar.Reflection.V2.Arith.tm 'a -> FStar.Reflection.V2.Arith.tm 'b
Prims.Tot
[ "total" ]
[]
[ "FStar.Reflection.V2.Arith.tm", "FStar.Reflection.V2.Arith.op_let_Bang", "FStar.Reflection.V2.Arith.return" ]
[]
false
false
false
true
false
let liftM f x =
let! xx = x in return (f xx)
false
Tutorial.fst
Tutorial.ex3
val ex3 : x: Prims.nat -> Prims.unit
let ex3 (x : nat) = assert_by_tactic (x + x >= 0 /\ List.length [4;5;1] == 3) tau3
{ "file_name": "examples/tactics/Tutorial.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 64, "end_line": 115, "start_col": 0, "start_line": 114 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Tutorial /// This file presents a walkthrough of the tactics engine in its current /// (July 23rd, 2017) state. It is mostly aimed at users and power users, leaving /// some details about the implementation out of this. open FStar.Tactics.V2 open FStar.List /// **First, what are tactics supposed to be?** /// /// In other dependently-typed theorem provers, they are a way to construct /// (or find) proofs automatically, which can be very tedious. Take a /// goal such as ``a + (b + c) == (c + a) + b``: we can get a proofterm for /// it by applying and composing associativity and commutativity lemmas. /// However, this proofterm is very dependent on the exact goal we're /// trying to prove: any change to the goal will require a change to the /// proof. This is annoying, since no real insight is required for the /// proof. Tactics provide an extensible way to automate these kind of /// proofs, improving robustness of proofs and the user's sanity. In one /// way or another, tactics reflect on the goal they have been called on, /// possibly inspecting the local and global environments, and implement /// a custom behaviour to construct such proof. In the previous example, /// one possibility for a tactic is shuffling the summands on each side /// following some well-defined order, a totally automatable process. /// /// You might be thinking: "doesn't F* already have an SMT solver backend /// for this reason?". Yes, but this does not at all negate the need for /// more automation in proofs. One could want to not call the SMT and stay /// only within F*, or to break down a proof obligation into more manageable /// chunks for the SMT, or even to simply change some SMT options or its /// environment for different subgoals. The main goal is to get more robust /// and faster proofs. /// /// On the other side of the Curry-Howard isomorphism, tactics can also /// be used to construct arbitrary terms, and not necessarily proofs. /// In this sense, they enable "metaprogramming" such as automatically /// generating printers for datatypes, recursors, or for whatever crazy /// boilerplate-like thing you want to do. We can also benefit from that in /// F*. /// /// So, enough talk, **what's the hello world of tactics?** /// The entry point for *proving* in tactics is `assert_by_tactic`, /// which takes a tactic to be run on the goal to prove. val ex1 : unit -> Lemma True let ex1 () = assert_by_tactic True idtac /// Here, ``idtac`` is the identity tactic, which does nothing. Certainly, /// ``True`` is a simple enough goal so this example succeeds. In between, the /// tactic is running with `True` as a goal, in the “logical environment” /// where we need to do the proof. Running the following example will cause /// the exact “proofstate” where the tactic runs to be printed in the /// standard output. val ex2 : unit -> Lemma True let ex2 () = assert_by_tactic True (fun () -> dump "Example 2") /// This yields the following:: /// /// Goal 1/1 /// uu___: unit /// p: pure_post unit /// ---------------------- /// squash l_True /// (*?u18*) _ uu___6626 p /// The output shows that we have only one “active” goal (that we're still working /// on) and no goals that have been already dispatched to the SMT. /// /// Concretely, to prove `True`, the engine is asking us to provide a term /// of type `squash True`. Squashing is the way we do proof-irrelevance in F*, /// and you can simply think of the type `squash phi` as the type of irrelevant /// proofs of `phi`. We call goals that are squashed “irrelevant”. /// .. note:: /// /// For experts: You might notice that ``True`` is already a squash (of /// ``trivial``), so this seems useless. In this case it is, but we squash /// nevertheless for consistency since this might be not so. /// A tactic is not required to completely prove an assertion, and can leave /// any number of goals unsolved, which will be fed to the SMT. Importantly, /// this can only be done on irrelevant goals, as the SMT does not produce /// proof terms! /// As expected, we can also manipulate logical formulas. There is a derived set of /// tactics (FStar.Tactics.Logical) simplifying this task, which is somewhat /// complicated due to squashing. Let's write a tactic to split a conjunction /// and solve one of its subformulas. let tau3 () : Tac unit = Tactics.split (); smt (); trivial ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Tutorial.fst" }
[ { "abbrev": false, "full_module": "FStar.List", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Prims.nat -> Prims.unit
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "FStar.Tactics.Effect.assert_by_tactic", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_Addition", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Prims.Cons", "Prims.Nil", "Tutorial.tau3", "Prims.unit" ]
[]
false
false
false
true
false
let ex3 (x: nat) =
assert_by_tactic (x + x >= 0 /\ List.length [4; 5; 1] == 3) tau3
false
FStar.Reflection.V2.Arith.fst
FStar.Reflection.V2.Arith.fail
val fail : (#a:Type) -> string -> tm a
val fail : (#a:Type) -> string -> tm a
let fail #a s = fun i -> Inl s
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 38, "end_line": 121, "start_col": 8, "start_line": 121 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2) let eq e1 e2 = CompProp e1 C_Eq e2 let ne e1 e2 = CompProp e1 C_Ne e2 let gt e1 e2 = CompProp e1 C_Gt e2 let ge e1 e2 = CompProp (Plus (Lit 1) e1) C_Gt e2 (* Define a traversal monad! Makes exception handling and counter-keeping easy *) private let st = p:(nat * list term){fst p == List.Tot.Base.length (snd p)} private let tm a = st -> Tac (either string (a * st)) private let return (x:'a) : tm 'a = fun i -> Inr (x, i) private let (let!) (m : tm 'a) (f : 'a -> tm 'b) : tm 'b = fun i -> match m i with | Inr (x, j) -> f x j | s -> Inl (Inl?.v s) // why? To have a catch-all pattern and thus an easy WP val lift : ('a -> Tac 'b) -> ('a -> tm 'b) let lift f x st = Inr (f x, st) val liftM : ('a -> 'b) -> (tm 'a -> tm 'b) let liftM f x = let! xx = x in return (f xx) val liftM2 : ('a -> 'b -> 'c) -> (tm 'a -> tm 'b -> tm 'c) let liftM2 f x y = let! xx = x in let! yy = y in return (f xx yy) val liftM3 : ('a -> 'b -> 'c -> 'd) -> (tm 'a -> tm 'b -> tm 'c -> tm 'd) let liftM3 f x y z = let! xx = x in let! yy = y in let! zz = z in return (f xx yy zz) private let rec find_idx (f : 'a -> Tac bool) (l : list 'a) : Tac (option ((n:nat{n < List.Tot.Base.length l}) * 'a)) = match l with | [] -> None | x::xs -> if f x then Some (0, x) else begin match find_idx f xs with | None -> None | Some (i, x) -> Some (i+1, x) end private let atom (t:term) : tm expr = fun (n, atoms) -> match find_idx (term_eq_old t) atoms with | None -> Inr (Atom n t, (n + 1, t::atoms)) | Some (i, t) -> Inr (Atom (n - 1 - i) t, (n, atoms))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: Prims.string -> FStar.Reflection.V2.Arith.tm a
Prims.Tot
[ "total" ]
[]
[ "Prims.string", "FStar.Reflection.V2.Arith.st", "FStar.Pervasives.Inl", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.either" ]
[]
false
false
false
true
false
let fail #a s =
fun i -> Inl s
false
FStar.Reflection.V2.Arith.fst
FStar.Reflection.V2.Arith.liftM2
val liftM2 : ('a -> 'b -> 'c) -> (tm 'a -> tm 'b -> tm 'c)
val liftM2 : ('a -> 'b -> 'c) -> (tm 'a -> tm 'b -> tm 'c)
let liftM2 f x y = let! xx = x in let! yy = y in return (f xx yy)
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 20, "end_line": 94, "start_col": 0, "start_line": 91 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2) let eq e1 e2 = CompProp e1 C_Eq e2 let ne e1 e2 = CompProp e1 C_Ne e2 let gt e1 e2 = CompProp e1 C_Gt e2 let ge e1 e2 = CompProp (Plus (Lit 1) e1) C_Gt e2 (* Define a traversal monad! Makes exception handling and counter-keeping easy *) private let st = p:(nat * list term){fst p == List.Tot.Base.length (snd p)} private let tm a = st -> Tac (either string (a * st)) private let return (x:'a) : tm 'a = fun i -> Inr (x, i) private let (let!) (m : tm 'a) (f : 'a -> tm 'b) : tm 'b = fun i -> match m i with | Inr (x, j) -> f x j | s -> Inl (Inl?.v s) // why? To have a catch-all pattern and thus an easy WP val lift : ('a -> Tac 'b) -> ('a -> tm 'b) let lift f x st = Inr (f x, st) val liftM : ('a -> 'b) -> (tm 'a -> tm 'b) let liftM f x = let! xx = x in return (f xx)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: 'a -> _: 'b -> 'c) -> _: FStar.Reflection.V2.Arith.tm 'a -> _: FStar.Reflection.V2.Arith.tm 'b -> FStar.Reflection.V2.Arith.tm 'c
Prims.Tot
[ "total" ]
[]
[ "FStar.Reflection.V2.Arith.tm", "FStar.Reflection.V2.Arith.op_let_Bang", "FStar.Reflection.V2.Arith.return" ]
[]
false
false
false
true
false
let liftM2 f x y =
let! xx = x in let! yy = y in return (f xx yy)
false
FStar.Reflection.V2.Arith.fst
FStar.Reflection.V2.Arith.is_arith_prop
val is_arith_prop : term -> st -> Tac (either string (prop * st))
val is_arith_prop : term -> st -> Tac (either string (prop * st))
let rec is_arith_prop (t:term) = fun i -> (let! f = lift (fun t -> term_as_formula t) t in match f with | Comp (Eq _) l r -> liftM2 eq (is_arith_expr l) (is_arith_expr r) | Comp (BoolEq _) l r -> liftM2 eq (is_arith_expr l) (is_arith_expr r) | Comp Lt l r -> liftM2 lt (is_arith_expr l) (is_arith_expr r) | Comp Le l r -> liftM2 le (is_arith_expr l) (is_arith_expr r) | And l r -> liftM2 AndProp (is_arith_prop l) (is_arith_prop r) | Or l r -> liftM2 OrProp (is_arith_prop l) (is_arith_prop r) | _ -> let! s = lift term_to_string t in fail ("connector (" ^ s ^ ")")) i
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 41, "end_line": 207, "start_col": 0, "start_line": 196 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2) let eq e1 e2 = CompProp e1 C_Eq e2 let ne e1 e2 = CompProp e1 C_Ne e2 let gt e1 e2 = CompProp e1 C_Gt e2 let ge e1 e2 = CompProp (Plus (Lit 1) e1) C_Gt e2 (* Define a traversal monad! Makes exception handling and counter-keeping easy *) private let st = p:(nat * list term){fst p == List.Tot.Base.length (snd p)} private let tm a = st -> Tac (either string (a * st)) private let return (x:'a) : tm 'a = fun i -> Inr (x, i) private let (let!) (m : tm 'a) (f : 'a -> tm 'b) : tm 'b = fun i -> match m i with | Inr (x, j) -> f x j | s -> Inl (Inl?.v s) // why? To have a catch-all pattern and thus an easy WP val lift : ('a -> Tac 'b) -> ('a -> tm 'b) let lift f x st = Inr (f x, st) val liftM : ('a -> 'b) -> (tm 'a -> tm 'b) let liftM f x = let! xx = x in return (f xx) val liftM2 : ('a -> 'b -> 'c) -> (tm 'a -> tm 'b -> tm 'c) let liftM2 f x y = let! xx = x in let! yy = y in return (f xx yy) val liftM3 : ('a -> 'b -> 'c -> 'd) -> (tm 'a -> tm 'b -> tm 'c -> tm 'd) let liftM3 f x y z = let! xx = x in let! yy = y in let! zz = z in return (f xx yy zz) private let rec find_idx (f : 'a -> Tac bool) (l : list 'a) : Tac (option ((n:nat{n < List.Tot.Base.length l}) * 'a)) = match l with | [] -> None | x::xs -> if f x then Some (0, x) else begin match find_idx f xs with | None -> None | Some (i, x) -> Some (i+1, x) end private let atom (t:term) : tm expr = fun (n, atoms) -> match find_idx (term_eq_old t) atoms with | None -> Inr (Atom n t, (n + 1, t::atoms)) | Some (i, t) -> Inr (Atom (n - 1 - i) t, (n, atoms)) private val fail : (#a:Type) -> string -> tm a private let fail #a s = fun i -> Inl s val as_arith_expr : term -> tm expr #push-options "--initial_fuel 4 --max_fuel 4" let rec as_arith_expr (t:term) = let hd, tl = collect_app_ln t in // Invoke [collect_app_order]: forall (arg, qual) ∈ tl, (arg, qual) << t collect_app_order t; // [precedes_fst_tl]: forall (arg, qual) ∈ tl, arg << t let precedes_fst_tl (arg: term) (q: aqualv) : Lemma (List.Tot.memP (arg, q) tl ==> arg << t) = let _: argv = arg, q in () in Classical.forall_intro_2 (precedes_fst_tl); match inspect_ln hd, tl with | Tv_FVar fv, [(e1, Q_Implicit); (e2, Q_Explicit) ; (e3, Q_Explicit)] -> let qn = inspect_fv fv in let e2' = as_arith_expr e2 in let e3' = as_arith_expr e3 in if qn = land_qn then liftM2 Land e2' e3' else if qn = lxor_qn then liftM2 Lxor e2' e3' else if qn = lor_qn then liftM2 Lor e2' e3' else if qn = shiftr_qn then liftM2 Shr e2' e3' else if qn = shiftl_qn then liftM2 Shl e2' e3' else if qn = udiv_qn then liftM2 Udiv e2' e3' else if qn = umod_qn then liftM2 Umod e2' e3' else if qn = mul_mod_qn then liftM2 MulMod e2' e3' else if qn = ladd_qn then liftM2 Ladd e2' e3' else if qn = lsub_qn then liftM2 Lsub e2' e3' else atom t | Tv_FVar fv, [(l, Q_Explicit); (r, Q_Explicit)] -> let qn = inspect_fv fv in // Have to go through hoops to get F* to typecheck this. // Maybe the do notation is twisting the terms somehow unexpected? let ll = as_arith_expr l in let rr = as_arith_expr r in if qn = add_qn then liftM2 Plus ll rr else if qn = minus_qn then liftM2 Minus ll rr else if qn = mult_qn then liftM2 Mult ll rr else if qn = mult'_qn then liftM2 Mult ll rr else atom t | Tv_FVar fv, [(l, Q_Implicit); (r, Q_Explicit)] -> let qn = inspect_fv fv in let ll = as_arith_expr l in let rr = as_arith_expr r in if qn = nat_bv_qn then liftM NatToBv rr else atom t | Tv_FVar fv, [(a, Q_Explicit)] -> let qn = inspect_fv fv in let aa = as_arith_expr a in if qn = neg_qn then liftM Neg aa else atom t | Tv_Const (C_Int i), _ -> return (Lit i) | _ -> atom t #pop-options val is_arith_expr : term -> tm expr let is_arith_expr t = let! a = as_arith_expr t in match a with | Atom _ t -> begin let hd, tl = collect_app_ref t in match inspect_ln hd, tl with | Tv_FVar _, [] | Tv_BVar _, [] | Tv_Var _, [] -> return a | _ -> let! s = lift term_to_string t in fail ("not an arithmetic expression: (" ^ s ^ ")") end | _ -> return a // Cannot use this... // val is_arith_prop : term -> tm prop
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: FStar.Stubs.Reflection.Types.term -> i: FStar.Reflection.V2.Arith.st -> FStar.Tactics.Effect.Tac (FStar.Pervasives.either Prims.string (FStar.Reflection.V2.Arith.prop * FStar.Reflection.V2.Arith.st))
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.V2.Arith.st", "FStar.Reflection.V2.Arith.op_let_Bang", "FStar.Reflection.V2.Formula.formula", "FStar.Reflection.V2.Arith.prop", "FStar.Reflection.V2.Arith.lift", "FStar.Tactics.NamedView.term", "FStar.Reflection.V2.Formula.term_as_formula", "FStar.Pervasives.Native.option", "FStar.Stubs.Reflection.Types.typ", "FStar.Reflection.V2.Arith.liftM2", "FStar.Reflection.V2.Arith.expr", "FStar.Reflection.V2.Arith.eq", "FStar.Reflection.V2.Arith.is_arith_expr", "FStar.Reflection.V2.Arith.lt", "FStar.Reflection.V2.Arith.le", "FStar.Reflection.V2.Arith.AndProp", "FStar.Reflection.V2.Arith.is_arith_prop", "FStar.Reflection.V2.Arith.OrProp", "Prims.string", "FStar.Stubs.Tactics.V2.Builtins.term_to_string", "FStar.Reflection.V2.Arith.fail", "Prims.op_Hat", "FStar.Reflection.V2.Arith.tm", "FStar.Pervasives.either", "FStar.Pervasives.Native.tuple2" ]
[ "recursion" ]
false
true
false
false
false
let rec is_arith_prop (t: term) =
fun i -> (let! f = lift (fun t -> term_as_formula t) t in match f with | Comp (Eq _) l r -> liftM2 eq (is_arith_expr l) (is_arith_expr r) | Comp (BoolEq _) l r -> liftM2 eq (is_arith_expr l) (is_arith_expr r) | Comp Lt l r -> liftM2 lt (is_arith_expr l) (is_arith_expr r) | Comp Le l r -> liftM2 le (is_arith_expr l) (is_arith_expr r) | And l r -> liftM2 AndProp (is_arith_prop l) (is_arith_prop r) | Or l r -> liftM2 OrProp (is_arith_prop l) (is_arith_prop r) | _ -> let! s = lift term_to_string t in fail ("connector (" ^ s ^ ")")) i
false
FStar.Reflection.V2.Arith.fst
FStar.Reflection.V2.Arith.is_arith_expr
val is_arith_expr : term -> tm expr
val is_arith_expr : term -> tm expr
let is_arith_expr t = let! a = as_arith_expr t in match a with | Atom _ t -> begin let hd, tl = collect_app_ref t in match inspect_ln hd, tl with | Tv_FVar _, [] | Tv_BVar _, [] | Tv_Var _, [] -> return a | _ -> let! s = lift term_to_string t in fail ("not an arithmetic expression: (" ^ s ^ ")") end | _ -> return a
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 17, "end_line": 191, "start_col": 0, "start_line": 179 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2) let eq e1 e2 = CompProp e1 C_Eq e2 let ne e1 e2 = CompProp e1 C_Ne e2 let gt e1 e2 = CompProp e1 C_Gt e2 let ge e1 e2 = CompProp (Plus (Lit 1) e1) C_Gt e2 (* Define a traversal monad! Makes exception handling and counter-keeping easy *) private let st = p:(nat * list term){fst p == List.Tot.Base.length (snd p)} private let tm a = st -> Tac (either string (a * st)) private let return (x:'a) : tm 'a = fun i -> Inr (x, i) private let (let!) (m : tm 'a) (f : 'a -> tm 'b) : tm 'b = fun i -> match m i with | Inr (x, j) -> f x j | s -> Inl (Inl?.v s) // why? To have a catch-all pattern and thus an easy WP val lift : ('a -> Tac 'b) -> ('a -> tm 'b) let lift f x st = Inr (f x, st) val liftM : ('a -> 'b) -> (tm 'a -> tm 'b) let liftM f x = let! xx = x in return (f xx) val liftM2 : ('a -> 'b -> 'c) -> (tm 'a -> tm 'b -> tm 'c) let liftM2 f x y = let! xx = x in let! yy = y in return (f xx yy) val liftM3 : ('a -> 'b -> 'c -> 'd) -> (tm 'a -> tm 'b -> tm 'c -> tm 'd) let liftM3 f x y z = let! xx = x in let! yy = y in let! zz = z in return (f xx yy zz) private let rec find_idx (f : 'a -> Tac bool) (l : list 'a) : Tac (option ((n:nat{n < List.Tot.Base.length l}) * 'a)) = match l with | [] -> None | x::xs -> if f x then Some (0, x) else begin match find_idx f xs with | None -> None | Some (i, x) -> Some (i+1, x) end private let atom (t:term) : tm expr = fun (n, atoms) -> match find_idx (term_eq_old t) atoms with | None -> Inr (Atom n t, (n + 1, t::atoms)) | Some (i, t) -> Inr (Atom (n - 1 - i) t, (n, atoms)) private val fail : (#a:Type) -> string -> tm a private let fail #a s = fun i -> Inl s val as_arith_expr : term -> tm expr #push-options "--initial_fuel 4 --max_fuel 4" let rec as_arith_expr (t:term) = let hd, tl = collect_app_ln t in // Invoke [collect_app_order]: forall (arg, qual) ∈ tl, (arg, qual) << t collect_app_order t; // [precedes_fst_tl]: forall (arg, qual) ∈ tl, arg << t let precedes_fst_tl (arg: term) (q: aqualv) : Lemma (List.Tot.memP (arg, q) tl ==> arg << t) = let _: argv = arg, q in () in Classical.forall_intro_2 (precedes_fst_tl); match inspect_ln hd, tl with | Tv_FVar fv, [(e1, Q_Implicit); (e2, Q_Explicit) ; (e3, Q_Explicit)] -> let qn = inspect_fv fv in let e2' = as_arith_expr e2 in let e3' = as_arith_expr e3 in if qn = land_qn then liftM2 Land e2' e3' else if qn = lxor_qn then liftM2 Lxor e2' e3' else if qn = lor_qn then liftM2 Lor e2' e3' else if qn = shiftr_qn then liftM2 Shr e2' e3' else if qn = shiftl_qn then liftM2 Shl e2' e3' else if qn = udiv_qn then liftM2 Udiv e2' e3' else if qn = umod_qn then liftM2 Umod e2' e3' else if qn = mul_mod_qn then liftM2 MulMod e2' e3' else if qn = ladd_qn then liftM2 Ladd e2' e3' else if qn = lsub_qn then liftM2 Lsub e2' e3' else atom t | Tv_FVar fv, [(l, Q_Explicit); (r, Q_Explicit)] -> let qn = inspect_fv fv in // Have to go through hoops to get F* to typecheck this. // Maybe the do notation is twisting the terms somehow unexpected? let ll = as_arith_expr l in let rr = as_arith_expr r in if qn = add_qn then liftM2 Plus ll rr else if qn = minus_qn then liftM2 Minus ll rr else if qn = mult_qn then liftM2 Mult ll rr else if qn = mult'_qn then liftM2 Mult ll rr else atom t | Tv_FVar fv, [(l, Q_Implicit); (r, Q_Explicit)] -> let qn = inspect_fv fv in let ll = as_arith_expr l in let rr = as_arith_expr r in if qn = nat_bv_qn then liftM NatToBv rr else atom t | Tv_FVar fv, [(a, Q_Explicit)] -> let qn = inspect_fv fv in let aa = as_arith_expr a in if qn = neg_qn then liftM Neg aa else atom t | Tv_Const (C_Int i), _ -> return (Lit i) | _ -> atom t #pop-options
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: FStar.Stubs.Reflection.Types.term -> FStar.Reflection.V2.Arith.tm FStar.Reflection.V2.Arith.expr
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.V2.Arith.op_let_Bang", "FStar.Reflection.V2.Arith.expr", "FStar.Reflection.V2.Arith.as_arith_expr", "Prims.nat", "Prims.l_or", "Prims.eq2", "Prims.precedes", "Prims.list", "FStar.Stubs.Reflection.V2.Data.argv", "FStar.Pervasives.Native.fst", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.term_view", "FStar.Stubs.Reflection.V2.Builtins.inspect_ln", "FStar.Stubs.Reflection.Types.fv", "FStar.Reflection.V2.Arith.return", "FStar.Stubs.Reflection.Types.bv", "FStar.Stubs.Reflection.Types.namedv", "FStar.Pervasives.Native.tuple2", "Prims.string", "FStar.Reflection.V2.Arith.lift", "FStar.Stubs.Tactics.V2.Builtins.term_to_string", "FStar.Reflection.V2.Arith.fail", "Prims.op_Hat", "FStar.Reflection.V2.Arith.tm", "FStar.Reflection.V2.Derived.Lemmas.collect_app_ref" ]
[]
false
false
false
true
false
let is_arith_expr t =
let! a = as_arith_expr t in match a with | Atom _ t -> let hd, tl = collect_app_ref t in (match inspect_ln hd, tl with | Tv_FVar _, [] | Tv_BVar _, [] | Tv_Var _, [] -> return a | _ -> let! s = lift term_to_string t in fail ("not an arithmetic expression: (" ^ s ^ ")")) | _ -> return a
false
Tutorial.fst
Tutorial.ex4
val ex4 : x: Prims.nat -> Prims.unit
let ex4 (x : nat) = assert_by_tactic ((1 + 1 == 2) /\ ((-x <= 0 /\ x + x >= 0) /\ List.length [4;5;1] == 3)) split_all
{ "file_name": "examples/tactics/Tutorial.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 13, "end_line": 197, "start_col": 0, "start_line": 192 }
(* 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 Tutorial /// This file presents a walkthrough of the tactics engine in its current /// (July 23rd, 2017) state. It is mostly aimed at users and power users, leaving /// some details about the implementation out of this. open FStar.Tactics.V2 open FStar.List /// **First, what are tactics supposed to be?** /// /// In other dependently-typed theorem provers, they are a way to construct /// (or find) proofs automatically, which can be very tedious. Take a /// goal such as ``a + (b + c) == (c + a) + b``: we can get a proofterm for /// it by applying and composing associativity and commutativity lemmas. /// However, this proofterm is very dependent on the exact goal we're /// trying to prove: any change to the goal will require a change to the /// proof. This is annoying, since no real insight is required for the /// proof. Tactics provide an extensible way to automate these kind of /// proofs, improving robustness of proofs and the user's sanity. In one /// way or another, tactics reflect on the goal they have been called on, /// possibly inspecting the local and global environments, and implement /// a custom behaviour to construct such proof. In the previous example, /// one possibility for a tactic is shuffling the summands on each side /// following some well-defined order, a totally automatable process. /// /// You might be thinking: "doesn't F* already have an SMT solver backend /// for this reason?". Yes, but this does not at all negate the need for /// more automation in proofs. One could want to not call the SMT and stay /// only within F*, or to break down a proof obligation into more manageable /// chunks for the SMT, or even to simply change some SMT options or its /// environment for different subgoals. The main goal is to get more robust /// and faster proofs. /// /// On the other side of the Curry-Howard isomorphism, tactics can also /// be used to construct arbitrary terms, and not necessarily proofs. /// In this sense, they enable "metaprogramming" such as automatically /// generating printers for datatypes, recursors, or for whatever crazy /// boilerplate-like thing you want to do. We can also benefit from that in /// F*. /// /// So, enough talk, **what's the hello world of tactics?** /// The entry point for *proving* in tactics is `assert_by_tactic`, /// which takes a tactic to be run on the goal to prove. val ex1 : unit -> Lemma True let ex1 () = assert_by_tactic True idtac /// Here, ``idtac`` is the identity tactic, which does nothing. Certainly, /// ``True`` is a simple enough goal so this example succeeds. In between, the /// tactic is running with `True` as a goal, in the “logical environment” /// where we need to do the proof. Running the following example will cause /// the exact “proofstate” where the tactic runs to be printed in the /// standard output. val ex2 : unit -> Lemma True let ex2 () = assert_by_tactic True (fun () -> dump "Example 2") /// This yields the following:: /// /// Goal 1/1 /// uu___: unit /// p: pure_post unit /// ---------------------- /// squash l_True /// (*?u18*) _ uu___6626 p /// The output shows that we have only one “active” goal (that we're still working /// on) and no goals that have been already dispatched to the SMT. /// /// Concretely, to prove `True`, the engine is asking us to provide a term /// of type `squash True`. Squashing is the way we do proof-irrelevance in F*, /// and you can simply think of the type `squash phi` as the type of irrelevant /// proofs of `phi`. We call goals that are squashed “irrelevant”. /// .. note:: /// /// For experts: You might notice that ``True`` is already a squash (of /// ``trivial``), so this seems useless. In this case it is, but we squash /// nevertheless for consistency since this might be not so. /// A tactic is not required to completely prove an assertion, and can leave /// any number of goals unsolved, which will be fed to the SMT. Importantly, /// this can only be done on irrelevant goals, as the SMT does not produce /// proof terms! /// As expected, we can also manipulate logical formulas. There is a derived set of /// tactics (FStar.Tactics.Logical) simplifying this task, which is somewhat /// complicated due to squashing. Let's write a tactic to split a conjunction /// and solve one of its subformulas. let tau3 () : Tac unit = Tactics.split (); smt (); trivial () let ex3 (x : nat) = assert_by_tactic (x + x >= 0 /\ List.length [4;5;1] == 3) tau3 /// First, we defined tau3 as a custom tactic, composed by applying ``split``, /// ``smt`` and ``trivial`` in that order. The ``tactic 'a`` type is a monad, and /// this is F*'s version of do notation for it. /// /// The ``split`` tactic will destruct the original goal into its /// two conjuncts, creating two new goals. /// /// Try adding ``dump "After split";`` just after ``split`` above, and run that code again. Now we see the following:: /// /// After split /// Goal 1/2 /// x: nat /// ------------------- /// squash (x + x >= 0) /// (*?u58*) _ x /// Goal 2/2 /// x: nat /// ------------------------------ /// squash (length [4; 5; 1] == 3) /// (*?u59*) _ x /// /// Further tactic steps are applied to the first goal. For the first one, /// we want to just give it to the smt, so we call into the ``smt`` tactic, /// which always succeeds and marks a goal for SMT discharging. If we were /// to dump the proofstate here, we'd see the first goal was simply moved /// into the "SMT goals" set. /// /// The second conjunct one can be shown true simply by normalization, so we /// can call into the ``trivial`` tactic to take care of it internally. /// /// .. note:: /// /// There is currently no support for a "try SMT" tactic, which would /// return back control if the SMT solver cannot prove the goal. This /// requires some rework in how guards are discharged in F*. /// /// For an automation example, let's write a tactic that will split all /// top-level conjunctions in our goal, trying to discharge them if /// they're trivial. Importantly, we need to be able to inspect the goal /// we're trying to prove from *within* the tactic. This is done via the /// ``cur_goal`` primitive, which returns the goal as ``term``, a reflection of /// F*'s internal term representation. These ``term``\ s are actually opaque, /// and can only be meaningfully used through some *views* defined on them. /// Since we're dealing with a logical formula, the ``formula`` view is the /// most comfortable one. We can decide if our goal is a conjunction in the /// following way: let is_conj () : Tac bool = let g = cur_goal () in match term_as_formula g with | And _ _ -> true | _ -> false /// Now, we want a tactic that will call ``split`` when our goal is a /// conjunction, and then recurse on the conjuncts! The iseq tactic /// proves handy here. Given a list of tactics, ``iseq`` will apply them in /// succession to each of the open goals. let rec split_all () : Tac unit = if is_conj () then begin Tactics.split (); iseq [split_all; split_all] end else let _ = trytac trivial in () /// We can use it for our previous example, or to break down bigger formulas. let ex3' (x : nat) = assert_by_tactic (x + x >= 0 /\ List.length [4;5;1] == 3) split_all
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Tutorial.fst" }
[ { "abbrev": false, "full_module": "FStar.List", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Prims.nat -> Prims.unit
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "FStar.Tactics.Effect.assert_by_tactic", "Prims.l_and", "Prims.eq2", "Prims.int", "Prims.op_Addition", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Minus", "Prims.op_GreaterThanOrEqual", "FStar.List.Tot.Base.length", "Prims.Cons", "Prims.Nil", "Tutorial.split_all", "Prims.unit" ]
[]
false
false
false
true
false
let ex4 (x: nat) =
assert_by_tactic ((1 + 1 == 2) /\ ((- x <= 0 /\ x + x >= 0) /\ List.length [4; 5; 1] == 3)) split_all
false
Tutorial.fst
Tutorial.ex3'
val ex3' : x: Prims.nat -> Prims.unit
let ex3' (x : nat) = assert_by_tactic (x + x >= 0 /\ List.length [4;5;1] == 3) split_all
{ "file_name": "examples/tactics/Tutorial.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 28, "end_line": 190, "start_col": 0, "start_line": 188 }
(* 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 Tutorial /// This file presents a walkthrough of the tactics engine in its current /// (July 23rd, 2017) state. It is mostly aimed at users and power users, leaving /// some details about the implementation out of this. open FStar.Tactics.V2 open FStar.List /// **First, what are tactics supposed to be?** /// /// In other dependently-typed theorem provers, they are a way to construct /// (or find) proofs automatically, which can be very tedious. Take a /// goal such as ``a + (b + c) == (c + a) + b``: we can get a proofterm for /// it by applying and composing associativity and commutativity lemmas. /// However, this proofterm is very dependent on the exact goal we're /// trying to prove: any change to the goal will require a change to the /// proof. This is annoying, since no real insight is required for the /// proof. Tactics provide an extensible way to automate these kind of /// proofs, improving robustness of proofs and the user's sanity. In one /// way or another, tactics reflect on the goal they have been called on, /// possibly inspecting the local and global environments, and implement /// a custom behaviour to construct such proof. In the previous example, /// one possibility for a tactic is shuffling the summands on each side /// following some well-defined order, a totally automatable process. /// /// You might be thinking: "doesn't F* already have an SMT solver backend /// for this reason?". Yes, but this does not at all negate the need for /// more automation in proofs. One could want to not call the SMT and stay /// only within F*, or to break down a proof obligation into more manageable /// chunks for the SMT, or even to simply change some SMT options or its /// environment for different subgoals. The main goal is to get more robust /// and faster proofs. /// /// On the other side of the Curry-Howard isomorphism, tactics can also /// be used to construct arbitrary terms, and not necessarily proofs. /// In this sense, they enable "metaprogramming" such as automatically /// generating printers for datatypes, recursors, or for whatever crazy /// boilerplate-like thing you want to do. We can also benefit from that in /// F*. /// /// So, enough talk, **what's the hello world of tactics?** /// The entry point for *proving* in tactics is `assert_by_tactic`, /// which takes a tactic to be run on the goal to prove. val ex1 : unit -> Lemma True let ex1 () = assert_by_tactic True idtac /// Here, ``idtac`` is the identity tactic, which does nothing. Certainly, /// ``True`` is a simple enough goal so this example succeeds. In between, the /// tactic is running with `True` as a goal, in the “logical environment” /// where we need to do the proof. Running the following example will cause /// the exact “proofstate” where the tactic runs to be printed in the /// standard output. val ex2 : unit -> Lemma True let ex2 () = assert_by_tactic True (fun () -> dump "Example 2") /// This yields the following:: /// /// Goal 1/1 /// uu___: unit /// p: pure_post unit /// ---------------------- /// squash l_True /// (*?u18*) _ uu___6626 p /// The output shows that we have only one “active” goal (that we're still working /// on) and no goals that have been already dispatched to the SMT. /// /// Concretely, to prove `True`, the engine is asking us to provide a term /// of type `squash True`. Squashing is the way we do proof-irrelevance in F*, /// and you can simply think of the type `squash phi` as the type of irrelevant /// proofs of `phi`. We call goals that are squashed “irrelevant”. /// .. note:: /// /// For experts: You might notice that ``True`` is already a squash (of /// ``trivial``), so this seems useless. In this case it is, but we squash /// nevertheless for consistency since this might be not so. /// A tactic is not required to completely prove an assertion, and can leave /// any number of goals unsolved, which will be fed to the SMT. Importantly, /// this can only be done on irrelevant goals, as the SMT does not produce /// proof terms! /// As expected, we can also manipulate logical formulas. There is a derived set of /// tactics (FStar.Tactics.Logical) simplifying this task, which is somewhat /// complicated due to squashing. Let's write a tactic to split a conjunction /// and solve one of its subformulas. let tau3 () : Tac unit = Tactics.split (); smt (); trivial () let ex3 (x : nat) = assert_by_tactic (x + x >= 0 /\ List.length [4;5;1] == 3) tau3 /// First, we defined tau3 as a custom tactic, composed by applying ``split``, /// ``smt`` and ``trivial`` in that order. The ``tactic 'a`` type is a monad, and /// this is F*'s version of do notation for it. /// /// The ``split`` tactic will destruct the original goal into its /// two conjuncts, creating two new goals. /// /// Try adding ``dump "After split";`` just after ``split`` above, and run that code again. Now we see the following:: /// /// After split /// Goal 1/2 /// x: nat /// ------------------- /// squash (x + x >= 0) /// (*?u58*) _ x /// Goal 2/2 /// x: nat /// ------------------------------ /// squash (length [4; 5; 1] == 3) /// (*?u59*) _ x /// /// Further tactic steps are applied to the first goal. For the first one, /// we want to just give it to the smt, so we call into the ``smt`` tactic, /// which always succeeds and marks a goal for SMT discharging. If we were /// to dump the proofstate here, we'd see the first goal was simply moved /// into the "SMT goals" set. /// /// The second conjunct one can be shown true simply by normalization, so we /// can call into the ``trivial`` tactic to take care of it internally. /// /// .. note:: /// /// There is currently no support for a "try SMT" tactic, which would /// return back control if the SMT solver cannot prove the goal. This /// requires some rework in how guards are discharged in F*. /// /// For an automation example, let's write a tactic that will split all /// top-level conjunctions in our goal, trying to discharge them if /// they're trivial. Importantly, we need to be able to inspect the goal /// we're trying to prove from *within* the tactic. This is done via the /// ``cur_goal`` primitive, which returns the goal as ``term``, a reflection of /// F*'s internal term representation. These ``term``\ s are actually opaque, /// and can only be meaningfully used through some *views* defined on them. /// Since we're dealing with a logical formula, the ``formula`` view is the /// most comfortable one. We can decide if our goal is a conjunction in the /// following way: let is_conj () : Tac bool = let g = cur_goal () in match term_as_formula g with | And _ _ -> true | _ -> false /// Now, we want a tactic that will call ``split`` when our goal is a /// conjunction, and then recurse on the conjuncts! The iseq tactic /// proves handy here. Given a list of tactics, ``iseq`` will apply them in /// succession to each of the open goals. let rec split_all () : Tac unit = if is_conj () then begin Tactics.split (); iseq [split_all; split_all] end else let _ = trytac trivial in () /// We can use it for our previous example, or to break down bigger formulas.
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.fst.checked" ], "interface_file": false, "source_file": "Tutorial.fst" }
[ { "abbrev": false, "full_module": "FStar.List", "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Prims.nat -> Prims.unit
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "FStar.Tactics.Effect.assert_by_tactic", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_Addition", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Prims.Cons", "Prims.Nil", "Tutorial.split_all", "Prims.unit" ]
[]
false
false
false
true
false
let ex3' (x: nat) =
assert_by_tactic (x + x >= 0 /\ List.length [4; 5; 1] == 3) split_all
false
Vale.Lib.Seqs.fst
Vale.Lib.Seqs.lemma_list_to_seq_rec
val lemma_list_to_seq_rec (#a: Type) (l: list a) (s: seq a) (n: nat) : Lemma (requires n + List.length l == Seq.length s /\ Seq.equal (Seq.slice s n (Seq.length s)) (list_to_seq l)) (ensures list_to_seq_post l s n) (decreases l)
val lemma_list_to_seq_rec (#a: Type) (l: list a) (s: seq a) (n: nat) : Lemma (requires n + List.length l == Seq.length s /\ Seq.equal (Seq.slice s n (Seq.length s)) (list_to_seq l)) (ensures list_to_seq_post l s n) (decreases l)
let rec lemma_list_to_seq_rec (#a:Type) (l:list a) (s:seq a) (n:nat) : Lemma (requires n + List.length l == Seq.length s /\ Seq.equal (Seq.slice s n (Seq.length s)) (list_to_seq l)) (ensures list_to_seq_post l s n) (decreases l) = match l with | [] -> () | h::t -> let lem (i:nat) : Lemma (requires i < List.length t) (ensures Seq.index (Seq.slice s (n + 1) (Seq.length s)) i == Seq.index (list_to_seq t) i) [SMTPat (Seq.index (list_to_seq t) i)] = calc (==) { Seq.index (Seq.slice s (n + 1) (Seq.length s)) i; == {} Seq.index (Seq.slice s n (Seq.length s)) (i + 1); == {} Seq.index (list_to_seq l) (i + 1); == {} Seq.index (list_to_seq t) i; } in lemma_list_to_seq_rec t s (n + 1); assert (Seq.index (list_to_seq l) 0 == h); ()
{ "file_name": "vale/code/lib/collections/Vale.Lib.Seqs.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 6, "end_line": 120, "start_col": 0, "start_line": 95 }
module Vale.Lib.Seqs open FStar.Mul let lemma_slice_first_exactly_in_append (#a:Type) (x y:seq a) : Lemma (slice (append x y) 0 (length x) == x) = let xy = append x y in let xy_slice = slice xy 0 (length x) in let x_slice = slice x 0 (length x) in assert(equal xy_slice x_slice); // OBSERVE: extensionality () let lemma_all_but_last_append (#t:Type) (a:seq t) (b:seq t{length b > 0}) : Lemma (all_but_last (append a b) == append a (all_but_last b)) = let ab = all_but_last (append a b) in let app_a_b = append a (all_but_last b) in assert (equal ab app_a_b) // OBSERVE: extensionality let reverse_seq_append (#a:eqtype) (s:seq a) (t:seq a) : Lemma(ensures reverse_seq (append s t) == append (reverse_seq t) (reverse_seq s)) = assert (equal (reverse_seq (append s t)) (append (reverse_seq t) (reverse_seq s))) let reverse_reverse_seq (#a:Type) (s:seq a) : Lemma(ensures reverse_seq (reverse_seq s) == s) = assert (equal (reverse_seq (reverse_seq s)) s) let rec seq_map_i_indexed (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) (i:int) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f (i + j) (index s j)) }) (decreases %[(length s)]) = if length s = 0 then empty else cons (f i (head s)) (seq_map_i_indexed f (tail s) (i + 1)) let seq_map_i (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) : Tot (s':seq b { length s' == length s /\ (forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f j (index s j)) }) = seq_map_i_indexed f s 0 let seq_map_internal_associative (#a:Type) (#b:eqtype) (f:int->a->b) (s:seq a) (pivot:int{0 <= pivot /\ pivot < length s}) : Lemma (let left,right = split s pivot in seq_map_i f s == seq_map_i_indexed f left 0 @| seq_map_i_indexed f right pivot ) = let left,right = split s pivot in let full_map = seq_map_i f s in let part1 = seq_map_i_indexed f left 0 in let part2 = seq_map_i_indexed f right pivot in assert (equal (seq_map_i f s) (seq_map_i_indexed f left 0 @| seq_map_i_indexed f right pivot)); () let seq_map_inverses (#a #b:Type) (f:a -> b) (g:b -> a) (s:seq a) : Lemma (requires forall x . g (f x) == x) (ensures seq_map g (seq_map f s) == s) = let mid = seq_map f s in let final = seq_map g mid in assert (equal s final); () let slice_append_adds (#a:Type) (s:seq a) (i:nat) (j:nat{ i <= j /\ j <= length s }) : Lemma (slice s 0 i @| slice s i j == slice s 0 j) = assert (equal (slice s 0 i @| slice s i j) (slice s 0 j)); () let slice_seq_map_commute (#a #b:Type) (f:a -> b) (s:seq a) (i:nat) (j:nat{ i <= j /\ j <= length s }) : Lemma (slice (seq_map f s) i j == seq_map f (slice s i j)) = assert (equal (slice (seq_map f s) i j) (seq_map f (slice s i j))); () let append_distributes_seq_map (#a #b:Type) (f:a -> b) (s1 s2:seq a) : Lemma (seq_map f (s1 @| s2) == seq_map f s1 @| seq_map f s2) = assert (equal (seq_map f (s1 @| s2)) (seq_map f s1 @| seq_map f s2)); () let seq_map_injective #a #b f s s' = assert (forall (i:nat).{:pattern index s i} i < length s ==> index (seq_map f s) i == f (index s i)); assert (forall (i:nat).{:pattern index s i} i < length s ==> index (seq_map f s') i == f (index s' i)); assert (equal s s') let list_to_seq #a l = Seq.seq_of_list l let reveal_opaque_rec (s:string) = norm_spec [zeta; delta_only [s]]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.Lib.Seqs.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
l: Prims.list a -> s: FStar.Seq.Base.seq a -> n: Prims.nat -> FStar.Pervasives.Lemma (requires n + FStar.List.Tot.Base.length l == FStar.Seq.Base.length s /\ FStar.Seq.Base.equal (FStar.Seq.Base.slice s n (FStar.Seq.Base.length s)) (Vale.Lib.Seqs.list_to_seq l)) (ensures Vale.Lib.Seqs.list_to_seq_post l s n) (decreases l)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "Prims.list", "FStar.Seq.Base.seq", "Prims.nat", "Prims.unit", "Prims._assert", "Prims.eq2", "FStar.Seq.Base.index", "Vale.Lib.Seqs.list_to_seq", "Vale.Lib.Seqs.lemma_list_to_seq_rec", "Prims.op_Addition", "Prims.b2t", "Prims.op_LessThan", "FStar.List.Tot.Base.length", "Prims.squash", "FStar.Seq.Base.slice", "FStar.Seq.Base.length", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil", "FStar.Calc.calc_finish", "FStar.Preorder.relation", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.l_and", "Prims.int", "FStar.Seq.Base.equal", "Vale.Lib.Seqs.list_to_seq_post" ]
[ "recursion" ]
false
false
true
false
false
let rec lemma_list_to_seq_rec (#a: Type) (l: list a) (s: seq a) (n: nat) : Lemma (requires n + List.length l == Seq.length s /\ Seq.equal (Seq.slice s n (Seq.length s)) (list_to_seq l)) (ensures list_to_seq_post l s n) (decreases l) =
match l with | [] -> () | h :: t -> let lem (i: nat) : Lemma (requires i < List.length t) (ensures Seq.index (Seq.slice s (n + 1) (Seq.length s)) i == Seq.index (list_to_seq t) i) [SMTPat (Seq.index (list_to_seq t) i)] = calc ( == ) { Seq.index (Seq.slice s (n + 1) (Seq.length s)) i; ( == ) { () } Seq.index (Seq.slice s n (Seq.length s)) (i + 1); ( == ) { () } Seq.index (list_to_seq l) (i + 1); ( == ) { () } Seq.index (list_to_seq t) i; } in lemma_list_to_seq_rec t s (n + 1); assert (Seq.index (list_to_seq l) 0 == h); ()
false
Hacl.Impl.Box.fst
Hacl.Impl.Box.box_beforenm
val box_beforenm: k:lbuffer uint8 32ul -> pk:lbuffer uint8 32ul -> sk:lbuffer uint8 32ul -> Stack size_t (requires fun h -> live h k /\ live h pk /\ live h sk /\ disjoint k pk /\ disjoint k sk) (ensures fun h0 r h1 -> modifies (loc k) h0 h1 /\ (let key = Spec.box_beforenm (as_seq h0 pk) (as_seq h0 sk) in match r with | 0ul -> Some? key /\ as_seq h1 k == Some?.v key | _ -> None? key))
val box_beforenm: k:lbuffer uint8 32ul -> pk:lbuffer uint8 32ul -> sk:lbuffer uint8 32ul -> Stack size_t (requires fun h -> live h k /\ live h pk /\ live h sk /\ disjoint k pk /\ disjoint k sk) (ensures fun h0 r h1 -> modifies (loc k) h0 h1 /\ (let key = Spec.box_beforenm (as_seq h0 pk) (as_seq h0 sk) in match r with | 0ul -> Some? key /\ as_seq h1 k == Some?.v key | _ -> None? key))
let box_beforenm k pk sk = push_frame(); let n0 = create 16ul (u8 0) in let r = Hacl.Curve25519_51.ecdh k sk pk in let res = if r then ( Hacl.Salsa20.hsalsa20 k k n0; 0ul) else 0xfffffffful in pop_frame(); res
{ "file_name": "code/nacl-box/Hacl.Impl.Box.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 46, "start_col": 0, "start_line": 35 }
module Hacl.Impl.Box open FStar.HyperStack.All open FStar.HyperStack open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Impl.SecretBox module ST = FStar.HyperStack.ST module Spec = Spec.Box module LSeq = Lib.Sequence #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" val box_beforenm: k:lbuffer uint8 32ul -> pk:lbuffer uint8 32ul -> sk:lbuffer uint8 32ul -> Stack size_t (requires fun h -> live h k /\ live h pk /\ live h sk /\ disjoint k pk /\ disjoint k sk) (ensures fun h0 r h1 -> modifies (loc k) h0 h1 /\ (let key = Spec.box_beforenm (as_seq h0 pk) (as_seq h0 sk) in match r with | 0ul -> Some? key /\ as_seq h1 k == Some?.v key | _ -> None? key))
{ "checked_file": "/", "dependencies": [ "Spec.Box.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Salsa20.fst.checked", "Hacl.Impl.SecretBox.fst.checked", "Hacl.Curve25519_51.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Box.fst" }
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Spec.Box", "short_module": "Spec" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SecretBox", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
k: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> pk: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> sk: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> FStar.HyperStack.ST.Stack Lib.IntTypes.size_t
FStar.HyperStack.ST.Stack
[]
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.size_t", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Lib.IntTypes.int_t", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Salsa20.hsalsa20", "Prims.bool", "Hacl.Curve25519_51.ecdh", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.create", "Lib.IntTypes.u8", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let box_beforenm k pk sk =
push_frame (); let n0 = create 16ul (u8 0) in let r = Hacl.Curve25519_51.ecdh k sk pk in let res = if r then (Hacl.Salsa20.hsalsa20 k k n0; 0ul) else 0xfffffffful in pop_frame (); res
false
FStar.Reflection.V2.Arith.fst
FStar.Reflection.V2.Arith.compare_expr
val compare_expr (e1 e2: expr) : O.order
val compare_expr (e1 e2: expr) : O.order
let rec compare_expr (e1 e2 : expr) : O.order = match e1, e2 with | Lit i, Lit j -> O.compare_int i j | Atom _ t, Atom _ s -> compare_term t s | Plus l1 l2, Plus r1 r2 | Minus l1 l2, Minus r1 r2 | Mult l1 l2, Mult r1 r2 -> O.lex (compare_expr l1 r1) (fun () -> compare_expr l2 r2) | Neg e1, Neg e2 -> compare_expr e1 e2 | Lit _, _ -> O.Lt | _, Lit _ -> O.Gt | Atom _ _, _ -> O.Lt | _, Atom _ _ -> O.Gt | Plus _ _, _ -> O.Lt | _, Plus _ _ -> O.Gt | Mult _ _, _ -> O.Lt | _, Mult _ _ -> O.Gt | Neg _, _ -> O.Lt | _, Neg _ -> O.Gt | _ -> O.Gt
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 15, "end_line": 249, "start_col": 0, "start_line": 236 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2) let eq e1 e2 = CompProp e1 C_Eq e2 let ne e1 e2 = CompProp e1 C_Ne e2 let gt e1 e2 = CompProp e1 C_Gt e2 let ge e1 e2 = CompProp (Plus (Lit 1) e1) C_Gt e2 (* Define a traversal monad! Makes exception handling and counter-keeping easy *) private let st = p:(nat * list term){fst p == List.Tot.Base.length (snd p)} private let tm a = st -> Tac (either string (a * st)) private let return (x:'a) : tm 'a = fun i -> Inr (x, i) private let (let!) (m : tm 'a) (f : 'a -> tm 'b) : tm 'b = fun i -> match m i with | Inr (x, j) -> f x j | s -> Inl (Inl?.v s) // why? To have a catch-all pattern and thus an easy WP val lift : ('a -> Tac 'b) -> ('a -> tm 'b) let lift f x st = Inr (f x, st) val liftM : ('a -> 'b) -> (tm 'a -> tm 'b) let liftM f x = let! xx = x in return (f xx) val liftM2 : ('a -> 'b -> 'c) -> (tm 'a -> tm 'b -> tm 'c) let liftM2 f x y = let! xx = x in let! yy = y in return (f xx yy) val liftM3 : ('a -> 'b -> 'c -> 'd) -> (tm 'a -> tm 'b -> tm 'c -> tm 'd) let liftM3 f x y z = let! xx = x in let! yy = y in let! zz = z in return (f xx yy zz) private let rec find_idx (f : 'a -> Tac bool) (l : list 'a) : Tac (option ((n:nat{n < List.Tot.Base.length l}) * 'a)) = match l with | [] -> None | x::xs -> if f x then Some (0, x) else begin match find_idx f xs with | None -> None | Some (i, x) -> Some (i+1, x) end private let atom (t:term) : tm expr = fun (n, atoms) -> match find_idx (term_eq_old t) atoms with | None -> Inr (Atom n t, (n + 1, t::atoms)) | Some (i, t) -> Inr (Atom (n - 1 - i) t, (n, atoms)) private val fail : (#a:Type) -> string -> tm a private let fail #a s = fun i -> Inl s val as_arith_expr : term -> tm expr #push-options "--initial_fuel 4 --max_fuel 4" let rec as_arith_expr (t:term) = let hd, tl = collect_app_ln t in // Invoke [collect_app_order]: forall (arg, qual) ∈ tl, (arg, qual) << t collect_app_order t; // [precedes_fst_tl]: forall (arg, qual) ∈ tl, arg << t let precedes_fst_tl (arg: term) (q: aqualv) : Lemma (List.Tot.memP (arg, q) tl ==> arg << t) = let _: argv = arg, q in () in Classical.forall_intro_2 (precedes_fst_tl); match inspect_ln hd, tl with | Tv_FVar fv, [(e1, Q_Implicit); (e2, Q_Explicit) ; (e3, Q_Explicit)] -> let qn = inspect_fv fv in let e2' = as_arith_expr e2 in let e3' = as_arith_expr e3 in if qn = land_qn then liftM2 Land e2' e3' else if qn = lxor_qn then liftM2 Lxor e2' e3' else if qn = lor_qn then liftM2 Lor e2' e3' else if qn = shiftr_qn then liftM2 Shr e2' e3' else if qn = shiftl_qn then liftM2 Shl e2' e3' else if qn = udiv_qn then liftM2 Udiv e2' e3' else if qn = umod_qn then liftM2 Umod e2' e3' else if qn = mul_mod_qn then liftM2 MulMod e2' e3' else if qn = ladd_qn then liftM2 Ladd e2' e3' else if qn = lsub_qn then liftM2 Lsub e2' e3' else atom t | Tv_FVar fv, [(l, Q_Explicit); (r, Q_Explicit)] -> let qn = inspect_fv fv in // Have to go through hoops to get F* to typecheck this. // Maybe the do notation is twisting the terms somehow unexpected? let ll = as_arith_expr l in let rr = as_arith_expr r in if qn = add_qn then liftM2 Plus ll rr else if qn = minus_qn then liftM2 Minus ll rr else if qn = mult_qn then liftM2 Mult ll rr else if qn = mult'_qn then liftM2 Mult ll rr else atom t | Tv_FVar fv, [(l, Q_Implicit); (r, Q_Explicit)] -> let qn = inspect_fv fv in let ll = as_arith_expr l in let rr = as_arith_expr r in if qn = nat_bv_qn then liftM NatToBv rr else atom t | Tv_FVar fv, [(a, Q_Explicit)] -> let qn = inspect_fv fv in let aa = as_arith_expr a in if qn = neg_qn then liftM Neg aa else atom t | Tv_Const (C_Int i), _ -> return (Lit i) | _ -> atom t #pop-options val is_arith_expr : term -> tm expr let is_arith_expr t = let! a = as_arith_expr t in match a with | Atom _ t -> begin let hd, tl = collect_app_ref t in match inspect_ln hd, tl with | Tv_FVar _, [] | Tv_BVar _, [] | Tv_Var _, [] -> return a | _ -> let! s = lift term_to_string t in fail ("not an arithmetic expression: (" ^ s ^ ")") end | _ -> return a // Cannot use this... // val is_arith_prop : term -> tm prop val is_arith_prop : term -> st -> Tac (either string (prop * st)) let rec is_arith_prop (t:term) = fun i -> (let! f = lift (fun t -> term_as_formula t) t in match f with | Comp (Eq _) l r -> liftM2 eq (is_arith_expr l) (is_arith_expr r) | Comp (BoolEq _) l r -> liftM2 eq (is_arith_expr l) (is_arith_expr r) | Comp Lt l r -> liftM2 lt (is_arith_expr l) (is_arith_expr r) | Comp Le l r -> liftM2 le (is_arith_expr l) (is_arith_expr r) | And l r -> liftM2 AndProp (is_arith_prop l) (is_arith_prop r) | Or l r -> liftM2 OrProp (is_arith_prop l) (is_arith_prop r) | _ -> let! s = lift term_to_string t in fail ("connector (" ^ s ^ ")")) i // Run the monadic computations, disregard the counter let run_tm (m : tm 'a) : Tac (either string 'a) = match m (0, []) with | Inr (x, _) -> Inr x | s -> Inl (Inl?.v s) // why? To have a catch-all pattern and thus an easy WP let rec expr_to_string (e:expr) : string = match e with | Atom i _ -> "a"^(string_of_int i) | Lit i -> string_of_int i | Plus l r -> "(" ^ (expr_to_string l) ^ " + " ^ (expr_to_string r) ^ ")" | Minus l r -> "(" ^ (expr_to_string l) ^ " - " ^ (expr_to_string r) ^ ")" | Mult l r -> "(" ^ (expr_to_string l) ^ " * " ^ (expr_to_string r) ^ ")" | Neg l -> "(- " ^ (expr_to_string l) ^ ")" | Land l r -> "(" ^ (expr_to_string l) ^ " & " ^ (expr_to_string r) ^ ")" | Lor l r -> "(" ^ (expr_to_string l) ^ " | " ^ (expr_to_string r) ^ ")" | Lxor l r -> "(" ^ (expr_to_string l) ^ " ^ " ^ (expr_to_string r) ^ ")" | Ladd l r -> "(" ^ (expr_to_string l) ^ " >> " ^ (expr_to_string r) ^ ")" | Lsub l r -> "(" ^ (expr_to_string l) ^ " >> " ^ (expr_to_string r) ^ ")" | Shl l r -> "(" ^ (expr_to_string l) ^ " << " ^ (expr_to_string r) ^ ")" | Shr l r -> "(" ^ (expr_to_string l) ^ " >> " ^ (expr_to_string r) ^ ")" | NatToBv l -> "(" ^ "to_vec " ^ (expr_to_string l) ^ ")" | Udiv l r -> "(" ^ (expr_to_string l) ^ " / " ^ (expr_to_string r) ^ ")" | Umod l r -> "(" ^ (expr_to_string l) ^ " % " ^ (expr_to_string r) ^ ")" | MulMod l r -> "(" ^ (expr_to_string l) ^ " ** " ^ (expr_to_string r) ^ ")"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e1: FStar.Reflection.V2.Arith.expr -> e2: FStar.Reflection.V2.Arith.expr -> FStar.Order.order
Prims.Tot
[ "total" ]
[]
[ "FStar.Reflection.V2.Arith.expr", "FStar.Pervasives.Native.Mktuple2", "Prims.int", "FStar.Order.compare_int", "Prims.nat", "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.V2.Compare.compare_term", "FStar.Order.lex", "FStar.Reflection.V2.Arith.compare_expr", "Prims.unit", "FStar.Order.order", "FStar.Order.Lt", "FStar.Order.Gt", "FStar.Pervasives.Native.tuple2" ]
[ "recursion" ]
false
false
false
true
false
let rec compare_expr (e1 e2: expr) : O.order =
match e1, e2 with | Lit i, Lit j -> O.compare_int i j | Atom _ t, Atom _ s -> compare_term t s | Plus l1 l2, Plus r1 r2 | Minus l1 l2, Minus r1 r2 | Mult l1 l2, Mult r1 r2 -> O.lex (compare_expr l1 r1) (fun () -> compare_expr l2 r2) | Neg e1, Neg e2 -> compare_expr e1 e2 | Lit _, _ -> O.Lt | _, Lit _ -> O.Gt | Atom _ _, _ -> O.Lt | _, Atom _ _ -> O.Gt | Plus _ _, _ -> O.Lt | _, Plus _ _ -> O.Gt | Mult _ _, _ -> O.Lt | _, Mult _ _ -> O.Gt | Neg _, _ -> O.Lt | _, Neg _ -> O.Gt | _ -> O.Gt
false
FStar.Reflection.V2.Arith.fst
FStar.Reflection.V2.Arith.run_tm
val run_tm (m: tm 'a) : Tac (either string 'a)
val run_tm (m: tm 'a) : Tac (either string 'a)
let run_tm (m : tm 'a) : Tac (either string 'a) = match m (0, []) with | Inr (x, _) -> Inr x | s -> Inl (Inl?.v s)
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 25, "end_line": 214, "start_col": 0, "start_line": 211 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2) let eq e1 e2 = CompProp e1 C_Eq e2 let ne e1 e2 = CompProp e1 C_Ne e2 let gt e1 e2 = CompProp e1 C_Gt e2 let ge e1 e2 = CompProp (Plus (Lit 1) e1) C_Gt e2 (* Define a traversal monad! Makes exception handling and counter-keeping easy *) private let st = p:(nat * list term){fst p == List.Tot.Base.length (snd p)} private let tm a = st -> Tac (either string (a * st)) private let return (x:'a) : tm 'a = fun i -> Inr (x, i) private let (let!) (m : tm 'a) (f : 'a -> tm 'b) : tm 'b = fun i -> match m i with | Inr (x, j) -> f x j | s -> Inl (Inl?.v s) // why? To have a catch-all pattern and thus an easy WP val lift : ('a -> Tac 'b) -> ('a -> tm 'b) let lift f x st = Inr (f x, st) val liftM : ('a -> 'b) -> (tm 'a -> tm 'b) let liftM f x = let! xx = x in return (f xx) val liftM2 : ('a -> 'b -> 'c) -> (tm 'a -> tm 'b -> tm 'c) let liftM2 f x y = let! xx = x in let! yy = y in return (f xx yy) val liftM3 : ('a -> 'b -> 'c -> 'd) -> (tm 'a -> tm 'b -> tm 'c -> tm 'd) let liftM3 f x y z = let! xx = x in let! yy = y in let! zz = z in return (f xx yy zz) private let rec find_idx (f : 'a -> Tac bool) (l : list 'a) : Tac (option ((n:nat{n < List.Tot.Base.length l}) * 'a)) = match l with | [] -> None | x::xs -> if f x then Some (0, x) else begin match find_idx f xs with | None -> None | Some (i, x) -> Some (i+1, x) end private let atom (t:term) : tm expr = fun (n, atoms) -> match find_idx (term_eq_old t) atoms with | None -> Inr (Atom n t, (n + 1, t::atoms)) | Some (i, t) -> Inr (Atom (n - 1 - i) t, (n, atoms)) private val fail : (#a:Type) -> string -> tm a private let fail #a s = fun i -> Inl s val as_arith_expr : term -> tm expr #push-options "--initial_fuel 4 --max_fuel 4" let rec as_arith_expr (t:term) = let hd, tl = collect_app_ln t in // Invoke [collect_app_order]: forall (arg, qual) ∈ tl, (arg, qual) << t collect_app_order t; // [precedes_fst_tl]: forall (arg, qual) ∈ tl, arg << t let precedes_fst_tl (arg: term) (q: aqualv) : Lemma (List.Tot.memP (arg, q) tl ==> arg << t) = let _: argv = arg, q in () in Classical.forall_intro_2 (precedes_fst_tl); match inspect_ln hd, tl with | Tv_FVar fv, [(e1, Q_Implicit); (e2, Q_Explicit) ; (e3, Q_Explicit)] -> let qn = inspect_fv fv in let e2' = as_arith_expr e2 in let e3' = as_arith_expr e3 in if qn = land_qn then liftM2 Land e2' e3' else if qn = lxor_qn then liftM2 Lxor e2' e3' else if qn = lor_qn then liftM2 Lor e2' e3' else if qn = shiftr_qn then liftM2 Shr e2' e3' else if qn = shiftl_qn then liftM2 Shl e2' e3' else if qn = udiv_qn then liftM2 Udiv e2' e3' else if qn = umod_qn then liftM2 Umod e2' e3' else if qn = mul_mod_qn then liftM2 MulMod e2' e3' else if qn = ladd_qn then liftM2 Ladd e2' e3' else if qn = lsub_qn then liftM2 Lsub e2' e3' else atom t | Tv_FVar fv, [(l, Q_Explicit); (r, Q_Explicit)] -> let qn = inspect_fv fv in // Have to go through hoops to get F* to typecheck this. // Maybe the do notation is twisting the terms somehow unexpected? let ll = as_arith_expr l in let rr = as_arith_expr r in if qn = add_qn then liftM2 Plus ll rr else if qn = minus_qn then liftM2 Minus ll rr else if qn = mult_qn then liftM2 Mult ll rr else if qn = mult'_qn then liftM2 Mult ll rr else atom t | Tv_FVar fv, [(l, Q_Implicit); (r, Q_Explicit)] -> let qn = inspect_fv fv in let ll = as_arith_expr l in let rr = as_arith_expr r in if qn = nat_bv_qn then liftM NatToBv rr else atom t | Tv_FVar fv, [(a, Q_Explicit)] -> let qn = inspect_fv fv in let aa = as_arith_expr a in if qn = neg_qn then liftM Neg aa else atom t | Tv_Const (C_Int i), _ -> return (Lit i) | _ -> atom t #pop-options val is_arith_expr : term -> tm expr let is_arith_expr t = let! a = as_arith_expr t in match a with | Atom _ t -> begin let hd, tl = collect_app_ref t in match inspect_ln hd, tl with | Tv_FVar _, [] | Tv_BVar _, [] | Tv_Var _, [] -> return a | _ -> let! s = lift term_to_string t in fail ("not an arithmetic expression: (" ^ s ^ ")") end | _ -> return a // Cannot use this... // val is_arith_prop : term -> tm prop val is_arith_prop : term -> st -> Tac (either string (prop * st)) let rec is_arith_prop (t:term) = fun i -> (let! f = lift (fun t -> term_as_formula t) t in match f with | Comp (Eq _) l r -> liftM2 eq (is_arith_expr l) (is_arith_expr r) | Comp (BoolEq _) l r -> liftM2 eq (is_arith_expr l) (is_arith_expr r) | Comp Lt l r -> liftM2 lt (is_arith_expr l) (is_arith_expr r) | Comp Le l r -> liftM2 le (is_arith_expr l) (is_arith_expr r) | And l r -> liftM2 AndProp (is_arith_prop l) (is_arith_prop r) | Or l r -> liftM2 OrProp (is_arith_prop l) (is_arith_prop r) | _ -> let! s = lift term_to_string t in fail ("connector (" ^ s ^ ")")) i
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m: FStar.Reflection.V2.Arith.tm 'a -> FStar.Tactics.Effect.Tac (FStar.Pervasives.either Prims.string 'a)
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Reflection.V2.Arith.tm", "FStar.Reflection.V2.Arith.st", "FStar.Pervasives.Inr", "Prims.string", "FStar.Pervasives.either", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Inl", "FStar.Pervasives.__proj__Inl__item__v", "FStar.Pervasives.Native.Mktuple2", "Prims.nat", "Prims.list", "FStar.Stubs.Reflection.Types.term", "Prims.Nil" ]
[]
false
true
false
false
false
let run_tm (m: tm 'a) : Tac (either string 'a) =
match m (0, []) with | Inr (x, _) -> Inr x | s -> Inl (Inl?.v s)
false
FStar.Reflection.V2.Arith.fst
FStar.Reflection.V2.Arith.atom
val atom (t: term) : tm expr
val atom (t: term) : tm expr
let atom (t:term) : tm expr = fun (n, atoms) -> match find_idx (term_eq_old t) atoms with | None -> Inr (Atom n t, (n + 1, t::atoms)) | Some (i, t) -> Inr (Atom (n - 1 - i) t, (n, atoms))
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 57, "end_line": 118, "start_col": 8, "start_line": 115 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2) let eq e1 e2 = CompProp e1 C_Eq e2 let ne e1 e2 = CompProp e1 C_Ne e2 let gt e1 e2 = CompProp e1 C_Gt e2 let ge e1 e2 = CompProp (Plus (Lit 1) e1) C_Gt e2 (* Define a traversal monad! Makes exception handling and counter-keeping easy *) private let st = p:(nat * list term){fst p == List.Tot.Base.length (snd p)} private let tm a = st -> Tac (either string (a * st)) private let return (x:'a) : tm 'a = fun i -> Inr (x, i) private let (let!) (m : tm 'a) (f : 'a -> tm 'b) : tm 'b = fun i -> match m i with | Inr (x, j) -> f x j | s -> Inl (Inl?.v s) // why? To have a catch-all pattern and thus an easy WP val lift : ('a -> Tac 'b) -> ('a -> tm 'b) let lift f x st = Inr (f x, st) val liftM : ('a -> 'b) -> (tm 'a -> tm 'b) let liftM f x = let! xx = x in return (f xx) val liftM2 : ('a -> 'b -> 'c) -> (tm 'a -> tm 'b -> tm 'c) let liftM2 f x y = let! xx = x in let! yy = y in return (f xx yy) val liftM3 : ('a -> 'b -> 'c -> 'd) -> (tm 'a -> tm 'b -> tm 'c -> tm 'd) let liftM3 f x y z = let! xx = x in let! yy = y in let! zz = z in return (f xx yy zz) private let rec find_idx (f : 'a -> Tac bool) (l : list 'a) : Tac (option ((n:nat{n < List.Tot.Base.length l}) * 'a)) = match l with | [] -> None | x::xs -> if f x then Some (0, x) else begin match find_idx f xs with | None -> None | Some (i, x) -> Some (i+1, x) end
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: FStar.Stubs.Reflection.Types.term -> FStar.Reflection.V2.Arith.tm FStar.Reflection.V2.Arith.expr
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.V2.Arith.st", "Prims.nat", "Prims.list", "FStar.Pervasives.Inr", "Prims.string", "FStar.Pervasives.Native.tuple2", "FStar.Reflection.V2.Arith.expr", "FStar.Pervasives.Native.Mktuple2", "FStar.Reflection.V2.Arith.Atom", "Prims.op_Addition", "Prims.Cons", "Prims.b2t", "Prims.op_LessThan", "FStar.List.Tot.Base.length", "Prims.op_Subtraction", "FStar.Pervasives.either", "FStar.Pervasives.Native.option", "FStar.Reflection.V2.Arith.find_idx", "FStar.Stubs.Tactics.V2.Builtins.term_eq_old", "FStar.Reflection.V2.Arith.tm" ]
[]
false
false
false
true
false
let atom (t: term) : tm expr =
fun (n, atoms) -> match find_idx (term_eq_old t) atoms with | None -> Inr (Atom n t, (n + 1, t :: atoms)) | Some (i, t) -> Inr (Atom (n - 1 - i) t, (n, atoms))
false
FStar.Reflection.V2.Arith.fst
FStar.Reflection.V2.Arith.find_idx
val find_idx (f: ('a -> Tac bool)) (l: list 'a) : Tac (option ((n: nat{n < List.Tot.Base.length l}) * 'a))
val find_idx (f: ('a -> Tac bool)) (l: list 'a) : Tac (option ((n: nat{n < List.Tot.Base.length l}) * 'a))
let rec find_idx (f : 'a -> Tac bool) (l : list 'a) : Tac (option ((n:nat{n < List.Tot.Base.length l}) * 'a)) = match l with | [] -> None | x::xs -> if f x then Some (0, x) else begin match find_idx f xs with | None -> None | Some (i, x) -> Some (i+1, x) end
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 16, "end_line": 113, "start_col": 8, "start_line": 104 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2) let eq e1 e2 = CompProp e1 C_Eq e2 let ne e1 e2 = CompProp e1 C_Ne e2 let gt e1 e2 = CompProp e1 C_Gt e2 let ge e1 e2 = CompProp (Plus (Lit 1) e1) C_Gt e2 (* Define a traversal monad! Makes exception handling and counter-keeping easy *) private let st = p:(nat * list term){fst p == List.Tot.Base.length (snd p)} private let tm a = st -> Tac (either string (a * st)) private let return (x:'a) : tm 'a = fun i -> Inr (x, i) private let (let!) (m : tm 'a) (f : 'a -> tm 'b) : tm 'b = fun i -> match m i with | Inr (x, j) -> f x j | s -> Inl (Inl?.v s) // why? To have a catch-all pattern and thus an easy WP val lift : ('a -> Tac 'b) -> ('a -> tm 'b) let lift f x st = Inr (f x, st) val liftM : ('a -> 'b) -> (tm 'a -> tm 'b) let liftM f x = let! xx = x in return (f xx) val liftM2 : ('a -> 'b -> 'c) -> (tm 'a -> tm 'b -> tm 'c) let liftM2 f x y = let! xx = x in let! yy = y in return (f xx yy) val liftM3 : ('a -> 'b -> 'c -> 'd) -> (tm 'a -> tm 'b -> tm 'c -> tm 'd) let liftM3 f x y z = let! xx = x in let! yy = y in let! zz = z in return (f xx yy zz)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: 'a -> FStar.Tactics.Effect.Tac Prims.bool) -> l: Prims.list 'a -> FStar.Tactics.Effect.Tac (FStar.Pervasives.Native.option (n: Prims.nat{n < FStar.List.Tot.Base.length l} * 'a))
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.bool", "Prims.list", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.tuple2", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.List.Tot.Base.length", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.Mktuple2", "Prims.op_Addition", "FStar.Reflection.V2.Arith.find_idx" ]
[ "recursion" ]
false
true
false
false
false
let rec find_idx (f: ('a -> Tac bool)) (l: list 'a) : Tac (option ((n: nat{n < List.Tot.Base.length l}) * 'a)) =
match l with | [] -> None | x :: xs -> if f x then Some (0, x) else match find_idx f xs with | None -> None | Some (i, x) -> Some (i + 1, x)
false
FStar.Reflection.V2.Arith.fst
FStar.Reflection.V2.Arith.as_arith_expr
val as_arith_expr : term -> tm expr
val as_arith_expr : term -> tm expr
let rec as_arith_expr (t:term) = let hd, tl = collect_app_ln t in // Invoke [collect_app_order]: forall (arg, qual) ∈ tl, (arg, qual) << t collect_app_order t; // [precedes_fst_tl]: forall (arg, qual) ∈ tl, arg << t let precedes_fst_tl (arg: term) (q: aqualv) : Lemma (List.Tot.memP (arg, q) tl ==> arg << t) = let _: argv = arg, q in () in Classical.forall_intro_2 (precedes_fst_tl); match inspect_ln hd, tl with | Tv_FVar fv, [(e1, Q_Implicit); (e2, Q_Explicit) ; (e3, Q_Explicit)] -> let qn = inspect_fv fv in let e2' = as_arith_expr e2 in let e3' = as_arith_expr e3 in if qn = land_qn then liftM2 Land e2' e3' else if qn = lxor_qn then liftM2 Lxor e2' e3' else if qn = lor_qn then liftM2 Lor e2' e3' else if qn = shiftr_qn then liftM2 Shr e2' e3' else if qn = shiftl_qn then liftM2 Shl e2' e3' else if qn = udiv_qn then liftM2 Udiv e2' e3' else if qn = umod_qn then liftM2 Umod e2' e3' else if qn = mul_mod_qn then liftM2 MulMod e2' e3' else if qn = ladd_qn then liftM2 Ladd e2' e3' else if qn = lsub_qn then liftM2 Lsub e2' e3' else atom t | Tv_FVar fv, [(l, Q_Explicit); (r, Q_Explicit)] -> let qn = inspect_fv fv in // Have to go through hoops to get F* to typecheck this. // Maybe the do notation is twisting the terms somehow unexpected? let ll = as_arith_expr l in let rr = as_arith_expr r in if qn = add_qn then liftM2 Plus ll rr else if qn = minus_qn then liftM2 Minus ll rr else if qn = mult_qn then liftM2 Mult ll rr else if qn = mult'_qn then liftM2 Mult ll rr else atom t | Tv_FVar fv, [(l, Q_Implicit); (r, Q_Explicit)] -> let qn = inspect_fv fv in let ll = as_arith_expr l in let rr = as_arith_expr r in if qn = nat_bv_qn then liftM NatToBv rr else atom t | Tv_FVar fv, [(a, Q_Explicit)] -> let qn = inspect_fv fv in let aa = as_arith_expr a in if qn = neg_qn then liftM Neg aa else atom t | Tv_Const (C_Int i), _ -> return (Lit i) | _ -> atom t
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 14, "end_line": 175, "start_col": 0, "start_line": 125 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2) let eq e1 e2 = CompProp e1 C_Eq e2 let ne e1 e2 = CompProp e1 C_Ne e2 let gt e1 e2 = CompProp e1 C_Gt e2 let ge e1 e2 = CompProp (Plus (Lit 1) e1) C_Gt e2 (* Define a traversal monad! Makes exception handling and counter-keeping easy *) private let st = p:(nat * list term){fst p == List.Tot.Base.length (snd p)} private let tm a = st -> Tac (either string (a * st)) private let return (x:'a) : tm 'a = fun i -> Inr (x, i) private let (let!) (m : tm 'a) (f : 'a -> tm 'b) : tm 'b = fun i -> match m i with | Inr (x, j) -> f x j | s -> Inl (Inl?.v s) // why? To have a catch-all pattern and thus an easy WP val lift : ('a -> Tac 'b) -> ('a -> tm 'b) let lift f x st = Inr (f x, st) val liftM : ('a -> 'b) -> (tm 'a -> tm 'b) let liftM f x = let! xx = x in return (f xx) val liftM2 : ('a -> 'b -> 'c) -> (tm 'a -> tm 'b -> tm 'c) let liftM2 f x y = let! xx = x in let! yy = y in return (f xx yy) val liftM3 : ('a -> 'b -> 'c -> 'd) -> (tm 'a -> tm 'b -> tm 'c -> tm 'd) let liftM3 f x y z = let! xx = x in let! yy = y in let! zz = z in return (f xx yy zz) private let rec find_idx (f : 'a -> Tac bool) (l : list 'a) : Tac (option ((n:nat{n < List.Tot.Base.length l}) * 'a)) = match l with | [] -> None | x::xs -> if f x then Some (0, x) else begin match find_idx f xs with | None -> None | Some (i, x) -> Some (i+1, x) end private let atom (t:term) : tm expr = fun (n, atoms) -> match find_idx (term_eq_old t) atoms with | None -> Inr (Atom n t, (n + 1, t::atoms)) | Some (i, t) -> Inr (Atom (n - 1 - i) t, (n, atoms)) private val fail : (#a:Type) -> string -> tm a private let fail #a s = fun i -> Inl s val as_arith_expr : term -> tm expr
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 4, "initial_ifuel": 1, "max_fuel": 4, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: FStar.Stubs.Reflection.Types.term -> FStar.Reflection.V2.Arith.tm FStar.Reflection.V2.Arith.expr
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "Prims.list", "FStar.Stubs.Reflection.V2.Data.argv", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.term_view", "FStar.Pervasives.Native.tuple2", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Stubs.Reflection.V2.Builtins.inspect_ln", "FStar.Stubs.Reflection.Types.fv", "Prims.op_Equality", "Prims.string", "FStar.Reflection.Const.land_qn", "FStar.Reflection.V2.Arith.liftM2", "FStar.Reflection.V2.Arith.expr", "FStar.Reflection.V2.Arith.Land", "Prims.bool", "FStar.Reflection.Const.lxor_qn", "FStar.Reflection.V2.Arith.Lxor", "FStar.Reflection.Const.lor_qn", "FStar.Reflection.V2.Arith.Lor", "FStar.Reflection.Const.shiftr_qn", "FStar.Reflection.V2.Arith.Shr", "FStar.Reflection.Const.shiftl_qn", "FStar.Reflection.V2.Arith.Shl", "FStar.Reflection.Const.udiv_qn", "FStar.Reflection.V2.Arith.Udiv", "FStar.Reflection.Const.umod_qn", "FStar.Reflection.V2.Arith.Umod", "FStar.Reflection.Const.mul_mod_qn", "FStar.Reflection.V2.Arith.MulMod", "FStar.Reflection.Const.ladd_qn", "FStar.Reflection.V2.Arith.Ladd", "FStar.Reflection.Const.lsub_qn", "FStar.Reflection.V2.Arith.Lsub", "FStar.Reflection.V2.Arith.atom", "FStar.Reflection.V2.Arith.tm", "FStar.Reflection.V2.Arith.as_arith_expr", "FStar.Stubs.Reflection.Types.name", "FStar.Stubs.Reflection.V2.Builtins.inspect_fv", "FStar.Reflection.Const.add_qn", "FStar.Reflection.V2.Arith.Plus", "FStar.Reflection.Const.minus_qn", "FStar.Reflection.V2.Arith.Minus", "FStar.Reflection.Const.mult_qn", "FStar.Reflection.V2.Arith.Mult", "FStar.Reflection.Const.mult'_qn", "FStar.Reflection.Const.nat_bv_qn", "FStar.Reflection.V2.Arith.liftM", "FStar.Reflection.V2.Arith.NatToBv", "FStar.Reflection.Const.neg_qn", "FStar.Reflection.V2.Arith.Neg", "Prims.int", "FStar.Reflection.V2.Arith.return", "FStar.Reflection.V2.Arith.Lit", "Prims.unit", "FStar.Classical.forall_intro_2", "Prims.l_imp", "FStar.List.Tot.Base.memP", "Prims.precedes", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Reflection.V2.Derived.Lemmas.collect_app_order", "FStar.Reflection.V2.Derived.collect_app_ln" ]
[ "recursion" ]
false
false
false
true
false
let rec as_arith_expr (t: term) =
let hd, tl = collect_app_ln t in collect_app_order t; let precedes_fst_tl (arg: term) (q: aqualv) : Lemma (List.Tot.memP (arg, q) tl ==> arg << t) = let _:argv = arg, q in () in Classical.forall_intro_2 (precedes_fst_tl); match inspect_ln hd, tl with | Tv_FVar fv, [e1, Q_Implicit ; e2, Q_Explicit ; e3, Q_Explicit] -> let qn = inspect_fv fv in let e2' = as_arith_expr e2 in let e3' = as_arith_expr e3 in if qn = land_qn then liftM2 Land e2' e3' else if qn = lxor_qn then liftM2 Lxor e2' e3' else if qn = lor_qn then liftM2 Lor e2' e3' else if qn = shiftr_qn then liftM2 Shr e2' e3' else if qn = shiftl_qn then liftM2 Shl e2' e3' else if qn = udiv_qn then liftM2 Udiv e2' e3' else if qn = umod_qn then liftM2 Umod e2' e3' else if qn = mul_mod_qn then liftM2 MulMod e2' e3' else if qn = ladd_qn then liftM2 Ladd e2' e3' else if qn = lsub_qn then liftM2 Lsub e2' e3' else atom t | Tv_FVar fv, [l, Q_Explicit ; r, Q_Explicit] -> let qn = inspect_fv fv in let ll = as_arith_expr l in let rr = as_arith_expr r in if qn = add_qn then liftM2 Plus ll rr else if qn = minus_qn then liftM2 Minus ll rr else if qn = mult_qn then liftM2 Mult ll rr else if qn = mult'_qn then liftM2 Mult ll rr else atom t | Tv_FVar fv, [l, Q_Implicit ; r, Q_Explicit] -> let qn = inspect_fv fv in let ll = as_arith_expr l in let rr = as_arith_expr r in if qn = nat_bv_qn then liftM NatToBv rr else atom t | Tv_FVar fv, [a, Q_Explicit] -> let qn = inspect_fv fv in let aa = as_arith_expr a in if qn = neg_qn then liftM Neg aa else atom t | Tv_Const (C_Int i), _ -> return (Lit i) | _ -> atom t
false
FStar.Reflection.V2.Arith.fst
FStar.Reflection.V2.Arith.expr_to_string
val expr_to_string (e: expr) : string
val expr_to_string (e: expr) : string
let rec expr_to_string (e:expr) : string = match e with | Atom i _ -> "a"^(string_of_int i) | Lit i -> string_of_int i | Plus l r -> "(" ^ (expr_to_string l) ^ " + " ^ (expr_to_string r) ^ ")" | Minus l r -> "(" ^ (expr_to_string l) ^ " - " ^ (expr_to_string r) ^ ")" | Mult l r -> "(" ^ (expr_to_string l) ^ " * " ^ (expr_to_string r) ^ ")" | Neg l -> "(- " ^ (expr_to_string l) ^ ")" | Land l r -> "(" ^ (expr_to_string l) ^ " & " ^ (expr_to_string r) ^ ")" | Lor l r -> "(" ^ (expr_to_string l) ^ " | " ^ (expr_to_string r) ^ ")" | Lxor l r -> "(" ^ (expr_to_string l) ^ " ^ " ^ (expr_to_string r) ^ ")" | Ladd l r -> "(" ^ (expr_to_string l) ^ " >> " ^ (expr_to_string r) ^ ")" | Lsub l r -> "(" ^ (expr_to_string l) ^ " >> " ^ (expr_to_string r) ^ ")" | Shl l r -> "(" ^ (expr_to_string l) ^ " << " ^ (expr_to_string r) ^ ")" | Shr l r -> "(" ^ (expr_to_string l) ^ " >> " ^ (expr_to_string r) ^ ")" | NatToBv l -> "(" ^ "to_vec " ^ (expr_to_string l) ^ ")" | Udiv l r -> "(" ^ (expr_to_string l) ^ " / " ^ (expr_to_string r) ^ ")" | Umod l r -> "(" ^ (expr_to_string l) ^ " % " ^ (expr_to_string r) ^ ")" | MulMod l r -> "(" ^ (expr_to_string l) ^ " ** " ^ (expr_to_string r) ^ ")"
{ "file_name": "ulib/FStar.Reflection.V2.Arith.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 80, "end_line": 234, "start_col": 0, "start_line": 216 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Arith open FStar.Tactics.V2 open FStar.Reflection.V2 module O = FStar.Order (* * Simple decision procedure to decide if a term is an "arithmetic * proposition", by which we mean a simple relation between two * arithmetic expressions (each representing integers or naturals) * * Main use case: deciding, in a tactic, if a goal is an arithmetic * expression and applying a custom decision procedure there (instead of * feeding to the SMT solver) *) noeq type expr = | Lit : int -> expr // atom, contains both a numerical ID and the actual term encountered | Atom : nat -> term -> expr | Plus : expr -> expr -> expr | Mult : expr -> expr -> expr | Minus : expr -> expr -> expr | Land : expr -> expr -> expr | Lxor : expr -> expr -> expr | Lor : expr -> expr -> expr | Ladd : expr -> expr -> expr | Lsub : expr -> expr -> expr | Shl : expr -> expr -> expr | Shr : expr -> expr -> expr | Neg : expr -> expr | Udiv : expr -> expr -> expr | Umod : expr -> expr -> expr | MulMod : expr -> expr -> expr | NatToBv : expr -> expr // | Div : expr -> expr -> expr // Add this one? noeq type connective = | C_Lt | C_Eq | C_Gt | C_Ne noeq type prop = | CompProp : expr -> connective -> expr -> prop | AndProp : prop -> prop -> prop | OrProp : prop -> prop -> prop | NotProp : prop -> prop let lt e1 e2 = CompProp e1 C_Lt e2 let le e1 e2 = CompProp e1 C_Lt (Plus (Lit 1) e2) let eq e1 e2 = CompProp e1 C_Eq e2 let ne e1 e2 = CompProp e1 C_Ne e2 let gt e1 e2 = CompProp e1 C_Gt e2 let ge e1 e2 = CompProp (Plus (Lit 1) e1) C_Gt e2 (* Define a traversal monad! Makes exception handling and counter-keeping easy *) private let st = p:(nat * list term){fst p == List.Tot.Base.length (snd p)} private let tm a = st -> Tac (either string (a * st)) private let return (x:'a) : tm 'a = fun i -> Inr (x, i) private let (let!) (m : tm 'a) (f : 'a -> tm 'b) : tm 'b = fun i -> match m i with | Inr (x, j) -> f x j | s -> Inl (Inl?.v s) // why? To have a catch-all pattern and thus an easy WP val lift : ('a -> Tac 'b) -> ('a -> tm 'b) let lift f x st = Inr (f x, st) val liftM : ('a -> 'b) -> (tm 'a -> tm 'b) let liftM f x = let! xx = x in return (f xx) val liftM2 : ('a -> 'b -> 'c) -> (tm 'a -> tm 'b -> tm 'c) let liftM2 f x y = let! xx = x in let! yy = y in return (f xx yy) val liftM3 : ('a -> 'b -> 'c -> 'd) -> (tm 'a -> tm 'b -> tm 'c -> tm 'd) let liftM3 f x y z = let! xx = x in let! yy = y in let! zz = z in return (f xx yy zz) private let rec find_idx (f : 'a -> Tac bool) (l : list 'a) : Tac (option ((n:nat{n < List.Tot.Base.length l}) * 'a)) = match l with | [] -> None | x::xs -> if f x then Some (0, x) else begin match find_idx f xs with | None -> None | Some (i, x) -> Some (i+1, x) end private let atom (t:term) : tm expr = fun (n, atoms) -> match find_idx (term_eq_old t) atoms with | None -> Inr (Atom n t, (n + 1, t::atoms)) | Some (i, t) -> Inr (Atom (n - 1 - i) t, (n, atoms)) private val fail : (#a:Type) -> string -> tm a private let fail #a s = fun i -> Inl s val as_arith_expr : term -> tm expr #push-options "--initial_fuel 4 --max_fuel 4" let rec as_arith_expr (t:term) = let hd, tl = collect_app_ln t in // Invoke [collect_app_order]: forall (arg, qual) ∈ tl, (arg, qual) << t collect_app_order t; // [precedes_fst_tl]: forall (arg, qual) ∈ tl, arg << t let precedes_fst_tl (arg: term) (q: aqualv) : Lemma (List.Tot.memP (arg, q) tl ==> arg << t) = let _: argv = arg, q in () in Classical.forall_intro_2 (precedes_fst_tl); match inspect_ln hd, tl with | Tv_FVar fv, [(e1, Q_Implicit); (e2, Q_Explicit) ; (e3, Q_Explicit)] -> let qn = inspect_fv fv in let e2' = as_arith_expr e2 in let e3' = as_arith_expr e3 in if qn = land_qn then liftM2 Land e2' e3' else if qn = lxor_qn then liftM2 Lxor e2' e3' else if qn = lor_qn then liftM2 Lor e2' e3' else if qn = shiftr_qn then liftM2 Shr e2' e3' else if qn = shiftl_qn then liftM2 Shl e2' e3' else if qn = udiv_qn then liftM2 Udiv e2' e3' else if qn = umod_qn then liftM2 Umod e2' e3' else if qn = mul_mod_qn then liftM2 MulMod e2' e3' else if qn = ladd_qn then liftM2 Ladd e2' e3' else if qn = lsub_qn then liftM2 Lsub e2' e3' else atom t | Tv_FVar fv, [(l, Q_Explicit); (r, Q_Explicit)] -> let qn = inspect_fv fv in // Have to go through hoops to get F* to typecheck this. // Maybe the do notation is twisting the terms somehow unexpected? let ll = as_arith_expr l in let rr = as_arith_expr r in if qn = add_qn then liftM2 Plus ll rr else if qn = minus_qn then liftM2 Minus ll rr else if qn = mult_qn then liftM2 Mult ll rr else if qn = mult'_qn then liftM2 Mult ll rr else atom t | Tv_FVar fv, [(l, Q_Implicit); (r, Q_Explicit)] -> let qn = inspect_fv fv in let ll = as_arith_expr l in let rr = as_arith_expr r in if qn = nat_bv_qn then liftM NatToBv rr else atom t | Tv_FVar fv, [(a, Q_Explicit)] -> let qn = inspect_fv fv in let aa = as_arith_expr a in if qn = neg_qn then liftM Neg aa else atom t | Tv_Const (C_Int i), _ -> return (Lit i) | _ -> atom t #pop-options val is_arith_expr : term -> tm expr let is_arith_expr t = let! a = as_arith_expr t in match a with | Atom _ t -> begin let hd, tl = collect_app_ref t in match inspect_ln hd, tl with | Tv_FVar _, [] | Tv_BVar _, [] | Tv_Var _, [] -> return a | _ -> let! s = lift term_to_string t in fail ("not an arithmetic expression: (" ^ s ^ ")") end | _ -> return a // Cannot use this... // val is_arith_prop : term -> tm prop val is_arith_prop : term -> st -> Tac (either string (prop * st)) let rec is_arith_prop (t:term) = fun i -> (let! f = lift (fun t -> term_as_formula t) t in match f with | Comp (Eq _) l r -> liftM2 eq (is_arith_expr l) (is_arith_expr r) | Comp (BoolEq _) l r -> liftM2 eq (is_arith_expr l) (is_arith_expr r) | Comp Lt l r -> liftM2 lt (is_arith_expr l) (is_arith_expr r) | Comp Le l r -> liftM2 le (is_arith_expr l) (is_arith_expr r) | And l r -> liftM2 AndProp (is_arith_prop l) (is_arith_prop r) | Or l r -> liftM2 OrProp (is_arith_prop l) (is_arith_prop r) | _ -> let! s = lift term_to_string t in fail ("connector (" ^ s ^ ")")) i // Run the monadic computations, disregard the counter let run_tm (m : tm 'a) : Tac (either string 'a) = match m (0, []) with | Inr (x, _) -> Inr x | s -> Inl (Inl?.v s) // why? To have a catch-all pattern and thus an easy WP
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Order.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Arith.fst" }
[ { "abbrev": true, "full_module": "FStar.Order", "short_module": "O" }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e: FStar.Reflection.V2.Arith.expr -> Prims.string
Prims.Tot
[ "total" ]
[]
[ "FStar.Reflection.V2.Arith.expr", "Prims.nat", "FStar.Stubs.Reflection.Types.term", "Prims.op_Hat", "Prims.string_of_int", "Prims.int", "FStar.Reflection.V2.Arith.expr_to_string", "Prims.string" ]
[ "recursion" ]
false
false
false
true
false
let rec expr_to_string (e: expr) : string =
match e with | Atom i _ -> "a" ^ (string_of_int i) | Lit i -> string_of_int i | Plus l r -> "(" ^ (expr_to_string l) ^ " + " ^ (expr_to_string r) ^ ")" | Minus l r -> "(" ^ (expr_to_string l) ^ " - " ^ (expr_to_string r) ^ ")" | Mult l r -> "(" ^ (expr_to_string l) ^ " * " ^ (expr_to_string r) ^ ")" | Neg l -> "(- " ^ (expr_to_string l) ^ ")" | Land l r -> "(" ^ (expr_to_string l) ^ " & " ^ (expr_to_string r) ^ ")" | Lor l r -> "(" ^ (expr_to_string l) ^ " | " ^ (expr_to_string r) ^ ")" | Lxor l r -> "(" ^ (expr_to_string l) ^ " ^ " ^ (expr_to_string r) ^ ")" | Ladd l r -> "(" ^ (expr_to_string l) ^ " >> " ^ (expr_to_string r) ^ ")" | Lsub l r -> "(" ^ (expr_to_string l) ^ " >> " ^ (expr_to_string r) ^ ")" | Shl l r -> "(" ^ (expr_to_string l) ^ " << " ^ (expr_to_string r) ^ ")" | Shr l r -> "(" ^ (expr_to_string l) ^ " >> " ^ (expr_to_string r) ^ ")" | NatToBv l -> "(" ^ "to_vec " ^ (expr_to_string l) ^ ")" | Udiv l r -> "(" ^ (expr_to_string l) ^ " / " ^ (expr_to_string r) ^ ")" | Umod l r -> "(" ^ (expr_to_string l) ^ " % " ^ (expr_to_string r) ^ ")" | MulMod l r -> "(" ^ (expr_to_string l) ^ " ** " ^ (expr_to_string r) ^ ")"
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.eternal_region_pred
val eternal_region_pred (m1 m2: mem) : Type0
val eternal_region_pred (m1 m2: mem) : Type0
let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 97, "end_line": 28, "start_col": 8, "start_line": 26 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m1: FStar.Monotonic.HyperStack.mem -> m2: FStar.Monotonic.HyperStack.mem -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "Prims.l_Forall", "FStar.Monotonic.HyperHeap.rid", "Prims.l_imp", "Prims.l_and", "Prims.b2t", "FStar.Monotonic.HyperStack.is_eternal_region_hs", "FStar.HyperStack.ST.contains_region", "FStar.Monotonic.HyperStack.is_heap_color", "FStar.Monotonic.HyperHeap.color" ]
[]
false
false
false
true
true
let eternal_region_pred (m1 m2: mem) : Type0 =
forall (r: HS.rid). {:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.rid_ctr_pred
val rid_ctr_pred (m1 m2: mem) : Type0
val rid_ctr_pred (m1 m2: mem) : Type0
let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 78, "end_line": 31, "start_col": 8, "start_line": 31 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m1: FStar.Monotonic.HyperStack.mem -> m2: FStar.Monotonic.HyperStack.mem -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Monotonic.HyperStack.get_rid_ctr" ]
[]
false
false
false
true
true
let rid_ctr_pred (m1 m2: mem) : Type0 =
get_rid_ctr m1 <= get_rid_ctr m2
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.rid_last_component_pred
val rid_last_component_pred (m1 m2: mem) : Type0
val rid_last_component_pred (m1 m2: mem) : Type0
let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r))
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 31, "end_line": 43, "start_col": 8, "start_line": 40 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m1: FStar.Monotonic.HyperStack.mem -> m2: FStar.Monotonic.HyperStack.mem -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "Prims.l_Forall", "FStar.Monotonic.HyperHeap.rid", "Prims.l_imp", "Prims.l_and", "Prims.l_not", "Prims.b2t", "FStar.HyperStack.ST.contains_region", "Prims.op_LessThan", "FStar.Monotonic.HyperHeap.rid_last_component", "FStar.Monotonic.HyperStack.get_rid_ctr" ]
[]
false
false
false
true
true
let rid_last_component_pred (m1 m2: mem) : Type0 =
forall (r: HS.rid). {:pattern (m1 `contains_region` r)} ((~(m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~(m2 `contains_region` r))
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.eternal_refs_pred
val eternal_refs_pred (m1 m2: mem) : Type0
val eternal_refs_pred (m1 m2: mem) : Type0
let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r)))
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 107, "end_line": 52, "start_col": 8, "start_line": 46 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m1: FStar.Monotonic.HyperStack.mem -> m2: FStar.Monotonic.HyperStack.mem -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "Prims.l_Forall", "FStar.Preorder.preorder", "FStar.Monotonic.HyperStack.mreference", "Prims.l_or", "Prims.b2t", "FStar.Monotonic.HyperStack.is_mm", "Prims.l_imp", "Prims.l_and", "FStar.Monotonic.HyperStack.contains", "FStar.Monotonic.HyperStack.is_eternal_region_hs", "FStar.Monotonic.HyperStack.frameOf", "FStar.HyperStack.ST.contains_region", "FStar.Monotonic.HyperStack.sel" ]
[]
false
false
false
true
true
let eternal_refs_pred (m1 m2: mem) : Type0 =
forall (a: Type) (rel: preorder a) (r: HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r)))
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.next_ref_addr_in_a_region_pred
val next_ref_addr_in_a_region_pred (m1 m2: mem) : Type0
val next_ref_addr_in_a_region_pred (m1 m2: mem) : Type0
let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True)
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 14, "end_line": 65, "start_col": 8, "start_line": 58 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m1: FStar.Monotonic.HyperStack.mem -> m2: FStar.Monotonic.HyperStack.mem -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "Prims.l_Forall", "FStar.Monotonic.HyperHeap.rid", "Prims.l_imp", "Prims.b2t", "FStar.HyperStack.ST.contains_region", "Prims.op_LessThanOrEqual", "FStar.Monotonic.Heap.next_addr", "FStar.Monotonic.Heap.heap", "FStar.Map.sel", "FStar.Monotonic.HyperStack.get_hmap", "Prims.bool", "Prims.l_True", "Prims.logical" ]
[]
false
false
false
true
true
let next_ref_addr_in_a_region_pred (m1 m2: mem) : Type0 =
forall (r: HS.rid). {:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True)
false
Hacl.HPKE.Curve51_CP32_SHA512.fsti
Hacl.HPKE.Curve51_CP32_SHA512.cs
val cs:S.ciphersuite
val cs:S.ciphersuite
let cs:S.ciphersuite = (DH.DH_Curve25519, Hash.SHA2_256, S.Seal AEAD.CHACHA20_POLY1305, Hash.SHA2_512)
{ "file_name": "code/hpke/Hacl.HPKE.Curve51_CP32_SHA512.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 102, "end_line": 10, "start_col": 0, "start_line": 10 }
module Hacl.HPKE.Curve51_CP32_SHA512 open Hacl.Impl.HPKE module S = Spec.Agile.HPKE module DH = Spec.Agile.DH module AEAD = Spec.Agile.AEAD module Hash = Spec.Agile.Hash
{ "checked_file": "/", "dependencies": [ "Spec.Agile.HPKE.fsti.checked", "Spec.Agile.Hash.fsti.checked", "Spec.Agile.DH.fst.checked", "Spec.Agile.AEAD.fsti.checked", "prims.fst.checked", "Hacl.Impl.HPKE.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.HPKE.Curve51_CP32_SHA512.fsti" }
[ { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "Spec.Agile.AEAD", "short_module": "AEAD" }, { "abbrev": true, "full_module": "Spec.Agile.DH", "short_module": "DH" }, { "abbrev": true, "full_module": "Spec.Agile.HPKE", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.HPKE", "short_module": null }, { "abbrev": false, "full_module": "Hacl.HPKE", "short_module": null }, { "abbrev": false, "full_module": "Hacl.HPKE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Spec.Agile.HPKE.ciphersuite
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.Mktuple4", "Spec.Agile.DH.algorithm", "Spec.Agile.HPKE.hash_algorithm", "Spec.Agile.HPKE.aead", "Spec.Hash.Definitions.hash_alg", "Spec.Agile.DH.DH_Curve25519", "Spec.Hash.Definitions.SHA2_256", "Spec.Agile.HPKE.Seal", "Spec.Agile.AEAD.CHACHA20_POLY1305", "Spec.Hash.Definitions.SHA2_512" ]
[]
false
false
false
true
false
let cs:S.ciphersuite =
(DH.DH_Curve25519, Hash.SHA2_256, S.Seal AEAD.CHACHA20_POLY1305, Hash.SHA2_512)
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.unused_ref_next_addr_pred
val unused_ref_next_addr_pred (m1 m2: mem) : Type0
val unused_ref_next_addr_pred (m1 m2: mem) : Type0
let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2)))
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 32, "end_line": 74, "start_col": 8, "start_line": 68 }
(* 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.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m1: FStar.Monotonic.HyperStack.mem -> m2: FStar.Monotonic.HyperStack.mem -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "Prims.l_Forall", "FStar.Monotonic.HyperHeap.rid", "Prims.l_imp", "Prims.b2t", "FStar.HyperStack.ST.contains_region", "FStar.Preorder.preorder", "FStar.Monotonic.HyperStack.mreference", "Prims.l_and", "Prims.eq2", "FStar.Monotonic.HyperStack.frameOf", "FStar.Monotonic.HyperStack.unused_in", "Prims.op_LessThan", "FStar.Monotonic.HyperStack.as_addr", "FStar.Monotonic.Heap.next_addr", "FStar.Monotonic.Heap.heap", "FStar.Map.sel", "FStar.Monotonic.HyperStack.get_hmap" ]
[]
false
false
false
true
true
let unused_ref_next_addr_pred (m1 m2: mem) : Type0 =
forall (rid: HS.rid). {:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a: Type0) (rel: preorder a) (r: HS.mreference a rel). {:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2)))
false
CQueue.fst
CQueue.llist_fragment_head_cons_change_phead
val llist_fragment_head_cons_change_phead (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) (phead' : ref (ccell_ptrvalue a)) : SteelGhost unit opened (llist_fragment_head l phead head) (fun _ -> llist_fragment_head l phead' head) (fun _ -> Cons? l) (fun h _ h' -> h' (llist_fragment_head l phead' head) == h (llist_fragment_head l phead head))
val llist_fragment_head_cons_change_phead (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) (phead' : ref (ccell_ptrvalue a)) : SteelGhost unit opened (llist_fragment_head l phead head) (fun _ -> llist_fragment_head l phead' head) (fun _ -> Cons? l) (fun h _ h' -> h' (llist_fragment_head l phead' head) == h (llist_fragment_head l phead head))
let llist_fragment_head_cons_change_phead l phead head phead' = let u = elim_llist_fragment_head_cons l phead head in let head2 : ccell_lvalue _ = head in change_equal_slprop (ccell head) (ccell head2); change_equal_slprop (llist_fragment_head u.ll_uncons_tl u.ll_uncons_pnext u.ll_uncons_next) (llist_fragment_head u.ll_uncons_tl (ccell_next head2) u.ll_uncons_next); let l' = intro_llist_fragment_head_cons phead' head2 u.ll_uncons_next u.ll_uncons_tl in change_equal_slprop (llist_fragment_head l' phead' head2) (llist_fragment_head l phead' head)
{ "file_name": "share/steel/examples/steel/CQueue.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 39, "end_line": 1155, "start_col": 0, "start_line": 1141 }
module CQueue open CQueue.LList #set-options "--ide_id_info_off" //Re-define squash, since this module explicitly //replies on proving equalities of the form `t_of v == squash p` //which are delicate in the presence of optimizations that //unfold `Prims.squash (p /\ q)`to _:unit{p /\ q} //See Issue #2496 let squash (p:Type u#a) : Type0 = squash p (* BEGIN library *) let intro_vrewrite_no_norm (#opened:inames) (v: vprop) (#t: Type) (f: (t_of v) -> GTot t) : SteelGhost unit opened v (fun _ -> vrewrite v f) (fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v)) = intro_vrewrite v f let elim_vrewrite_no_norm (#opened:inames) (v: vprop) (#t: Type) (f: ((t_of v) -> GTot t)) : SteelGhost unit opened (vrewrite v f) (fun _ -> v) (fun _ -> True) (fun h _ h' -> h (vrewrite v f) == f (h' v)) = elim_vrewrite v f let vconst_sel (#a: Type) (x: a) : Tot (selector a (hp_of emp)) = fun _ -> x [@@ __steel_reduce__] let vconst' (#a: Type) (x: a) : GTot vprop' = { hp = hp_of emp; t = a; sel = vconst_sel x; } [@@ __steel_reduce__] let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x) let intro_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened emp (fun _ -> vconst x) (fun _ -> True) (fun _ _ h' -> h' (vconst x) == x) = change_slprop_rel emp (vconst x) (fun _ y -> y == x) (fun _ -> ()) let elim_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened (vconst x) (fun _ -> emp) (fun _ -> True) (fun h _ _ -> h (vconst x) == x) = change_slprop_rel (vconst x) emp (fun y _ -> y == x) (fun _ -> ()) let vpure_sel' (p: prop) : Tot (selector' (squash p) (Steel.Memory.pure p)) = fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m let vpure_sel (p: prop) : Tot (selector (squash p) (Steel.Memory.pure p)) = vpure_sel' p [@@ __steel_reduce__] let vpure' (p: prop) : GTot vprop' = { hp = Steel.Memory.pure p; t = squash p; sel = vpure_sel p; } [@@ __steel_reduce__] let vpure (p: prop) : Tot vprop = VUnit (vpure' p) let intro_vpure (#opened: _) (p: prop) : SteelGhost unit opened emp (fun _ -> vpure p) (fun _ -> p) (fun _ _ h' -> p) = change_slprop_rel emp (vpure p) (fun _ _ -> p) (fun m -> pure_interp p m) let elim_vpure (#opened: _) (p: prop) : SteelGhost unit opened (vpure p) (fun _ -> emp) (fun _ -> True) (fun _ _ _ -> p) = change_slprop_rel (vpure p) emp (fun _ _ -> p) (fun m -> pure_interp p m; reveal_emp (); intro_emp m) val intro_vdep2 (#opened:inames) (v: vprop) (q: vprop) (x: t_of v) (p: (t_of v -> Tot vprop)) : SteelGhost unit opened (v `star` q) (fun _ -> vdep v p) (requires (fun h -> q == p x /\ x == h v )) (ensures (fun h _ h' -> let x2 = h' (vdep v p) in q == p (h v) /\ dfst x2 == (h v) /\ dsnd x2 == (h q) )) let intro_vdep2 v q x p = intro_vdep v q p let vbind0_payload (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) (x: t_of a) : Tot vprop = vpure (t == t_of (b x)) `star` b x let vbind0_rewrite (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) (x: normal (t_of (vdep a (vbind0_payload a t b)))) : Tot t = snd (dsnd x) [@@__steel_reduce__; __reduce__] let vbind0 (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : Tot vprop = a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b let vbind_hp // necessary to hide the attribute on hp_of (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : Tot (slprop u#1) = hp_of (vbind0 a t b) let vbind_sel // same for hp_sel (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : GTot (selector t (vbind_hp a t b)) = sel_of (vbind0 a t b) [@@__steel_reduce__] let vbind' (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : GTot vprop' = { hp = vbind_hp a t b; t = t; sel = vbind_sel a t b; } [@@__steel_reduce__] let vbind (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : Tot vprop = VUnit (vbind' a t b) let intro_vbind (#opened: _) (a: vprop) (b' : vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : SteelGhost unit opened (a `star` b') (fun _ -> vbind a t b) (fun h -> t_of b' == t /\ b' == b (h a)) (fun h _ h' -> t_of b' == t /\ b' == b (h a) /\ h' (vbind a t b) == h b' ) = intro_vpure (t == t_of b'); intro_vdep a (vpure (t == t_of b') `star` b') (vbind0_payload a t b); intro_vrewrite (a `vdep` vbind0_payload a t b) (vbind0_rewrite a t b); change_slprop_rel (vbind0 a t b) (vbind a t b) (fun x y -> x == y) (fun _ -> ()) let elim_vbind (#opened: _) (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : SteelGhost (Ghost.erased (t_of a)) opened (vbind a t b) (fun res -> a `star` b (Ghost.reveal res)) (fun h -> True) (fun h res h' -> h' a == Ghost.reveal res /\ t == t_of (b (Ghost.reveal res)) /\ h' (b (Ghost.reveal res)) == h (vbind a t b) ) = change_slprop_rel (vbind a t b) (vbind0 a t b) (fun x y -> x == y) (fun _ -> ()); elim_vrewrite (a `vdep` vbind0_payload a t b) (vbind0_rewrite a t b); let res = elim_vdep a (vbind0_payload a t b) in change_equal_slprop (vbind0_payload a t b (Ghost.reveal res)) (vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res)); elim_vpure (t == t_of (b (Ghost.reveal res))); res let (==) (#a:_) (x y: a) : prop = x == y let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma (requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2])) (ensures (hd1 == hd2 /\ tl1 == tl2)) [SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])] = L.lemma_snoc_unsnoc (hd1, tl1); L.lemma_snoc_unsnoc (hd2, tl2) [@"opaque_to_smt"] let unsnoc (#a: Type) (l: list a) : Pure (list a & a) (requires (Cons? l)) (ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l)) = L.lemma_unsnoc_snoc l; L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)]; L.unsnoc l let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' < L.length l)) = fst (unsnoc l) let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l) [@@"opaque_to_smt"] let snoc (#a: Type) (l: list a) (x: a) : Pure (list a) (requires True) (ensures (fun l' -> Cons? l' /\ unsnoc_hd l' == l /\ unsnoc_tl l' == x )) = let l' = L.snoc (l, x) in L.append_length l [x]; snoc_inj l (unsnoc_hd l') x (unsnoc_tl l'); l' let snoc_unsnoc (#a: Type) (l: list a) : Lemma (requires (Cons? l)) (ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l)) = () unfold let coerce (#a: Type) (x: a) (b: Type) : Pure b (requires (a == b)) (ensures (fun y -> a == b /\ x == y)) = x (* END library *) let t a = cllist_lvalue a let v (a: Type0) = list a let datas (#a: Type0) (l: v a) : Tot (list a) = l (* view from the tail *) let llist_fragment_tail_cons_data_refine (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (d: a) : Tot prop = d == unsnoc_tl (Ghost.reveal l) [@@ __steel_reduce__] let llist_fragment_tail_cons_lvalue_payload (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (c: ccell_lvalue a) : Tot vprop = vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l let ccell_is_lvalue_refine (a: Type) (c: ccell_ptrvalue a) : Tot prop = ccell_ptrvalue_is_null c == false [@@ __steel_reduce__ ] let llist_fragment_tail_cons_next_payload (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (ptail: ref (ccell_ptrvalue a)) : Tot vprop = vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l [@@ __steel_reduce__ ] let llist_fragment_tail_cons_rewrite (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) }) (x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l)))) : Tot (ref (ccell_ptrvalue a)) = let (| _, (| c, _ |) |) = x in ccell_next c let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Pure vprop (requires True) (ensures (fun v -> t_of v == ref (ccell_ptrvalue a))) (decreases (Ghost.reveal (L.length l))) = if Nil? l then vconst phead else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) let llist_fragment_tail_eq (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Lemma (llist_fragment_tail l phead == ( if Nil? l then vconst phead else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) )) = assert_norm (llist_fragment_tail l phead == ( if Nil? l then vconst phead else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) )) let llist_fragment_tail_eq_cons (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Lemma (requires (Cons? l)) (ensures (Cons? l /\ llist_fragment_tail l phead == ( llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) ))) = llist_fragment_tail_eq l phead unfold let sel_llist_fragment_tail (#a:Type) (#p:vprop) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_tail l phead) /\ True) }) : GTot (ref (ccell_ptrvalue a)) = coerce (h (llist_fragment_tail l phead)) (ref (ccell_ptrvalue a)) val intro_llist_fragment_tail_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : SteelGhost unit opened emp (fun _ -> llist_fragment_tail l phead) (fun _ -> Nil? l) (fun _ _ h' -> sel_llist_fragment_tail l phead h' == phead) let intro_llist_fragment_tail_nil l phead = intro_vconst phead; change_equal_slprop (vconst phead) (llist_fragment_tail l phead) val elim_llist_fragment_tail_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : SteelGhost unit opened (llist_fragment_tail l phead) (fun _ -> emp) (fun _ -> Nil? l) (fun h _ _ -> sel_llist_fragment_tail l phead h == phead) let elim_llist_fragment_tail_nil l phead = change_equal_slprop (llist_fragment_tail l phead) (vconst phead); elim_vconst phead val intro_llist_fragment_tail_snoc (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (ptail: Ghost.erased (ref (ccell_ptrvalue a))) (tail: Ghost.erased (ccell_lvalue a)) : SteelGhost (Ghost.erased (list a)) opened (llist_fragment_tail l phead `star` vptr ptail `star` vptr (ccell_data tail)) (fun res -> llist_fragment_tail res phead) (fun h -> sel_llist_fragment_tail l phead h == Ghost.reveal ptail /\ sel ptail h == Ghost.reveal tail ) (fun h res h' -> Ghost.reveal res == snoc (Ghost.reveal l) (sel (ccell_data tail) h) /\ sel_llist_fragment_tail res phead h' == ccell_next tail ) #push-options "--z3rlimit 16" let intro_llist_fragment_tail_snoc #_ #a l phead ptail tail = let d = gget (vptr (ccell_data tail)) in let l' : (l' : Ghost.erased (list a) { Cons? (Ghost.reveal l') }) = Ghost.hide (snoc (Ghost.reveal l) (Ghost.reveal d)) in intro_vrefine (vptr (ccell_data tail)) (llist_fragment_tail_cons_data_refine l'); intro_vrefine (vptr ptail) (ccell_is_lvalue_refine a); intro_vdep (vptr ptail `vrefine` ccell_is_lvalue_refine a) (vptr (ccell_data tail) `vrefine` llist_fragment_tail_cons_data_refine l') (llist_fragment_tail_cons_lvalue_payload l'); change_equal_slprop (llist_fragment_tail l phead) (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead); intro_vdep (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead) (vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l') (llist_fragment_tail_cons_next_payload l'); intro_vrewrite_no_norm (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l') (llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead)); llist_fragment_tail_eq_cons l' phead; change_equal_slprop (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l' `vrewrite` llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead)) (llist_fragment_tail l' phead); let g' = gget (llist_fragment_tail l' phead) in assert (Ghost.reveal g' == ccell_next tail); noop (); l' #pop-options [@@erasable] noeq type ll_unsnoc_t (a: Type) = { ll_unsnoc_l: list a; ll_unsnoc_ptail: ref (ccell_ptrvalue a); ll_unsnoc_tail: ccell_lvalue a; } val elim_llist_fragment_tail_snoc (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : SteelGhost (ll_unsnoc_t a) opened (llist_fragment_tail l phead) (fun res -> llist_fragment_tail res.ll_unsnoc_l phead `star` vptr res.ll_unsnoc_ptail `star` vptr (ccell_data res.ll_unsnoc_tail)) (fun _ -> Cons? l) (fun h res h' -> Cons? l /\ Ghost.reveal res.ll_unsnoc_l == unsnoc_hd l /\ sel res.ll_unsnoc_ptail h' == res.ll_unsnoc_tail /\ sel (ccell_data res.ll_unsnoc_tail) h'== unsnoc_tl l /\ sel_llist_fragment_tail res.ll_unsnoc_l phead h' == res.ll_unsnoc_ptail /\ sel_llist_fragment_tail l phead h == (ccell_next res.ll_unsnoc_tail) ) #push-options "--z3rlimit 32" #restart-solver let elim_llist_fragment_tail_snoc #_ #a l phead = let l0 : (l0: Ghost.erased (list a) { Cons? l0 }) = Ghost.hide (Ghost.reveal l) in llist_fragment_tail_eq_cons l0 phead; change_equal_slprop (llist_fragment_tail l phead) (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0 `vrewrite` llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)); elim_vrewrite_no_norm (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0) (llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)); let ptail = elim_vdep (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead) (llist_fragment_tail_cons_next_payload l0) in let ptail0 : Ghost.erased (ref (ccell_ptrvalue a)) = ptail in change_equal_slprop (llist_fragment_tail_cons_next_payload l0 (Ghost.reveal ptail)) (vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l0); let tail = elim_vdep (vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a) (llist_fragment_tail_cons_lvalue_payload l0) in elim_vrefine (vptr (Ghost.reveal ptail0)) (ccell_is_lvalue_refine a); let res = { ll_unsnoc_l = unsnoc_hd l0; ll_unsnoc_ptail = Ghost.reveal ptail0; ll_unsnoc_tail = Ghost.reveal tail; } in change_equal_slprop (vptr (Ghost.reveal ptail0)) (vptr res.ll_unsnoc_ptail); change_equal_slprop (llist_fragment_tail_cons_lvalue_payload l0 (Ghost.reveal tail)) (vptr (ccell_data res.ll_unsnoc_tail) `vrefine` llist_fragment_tail_cons_data_refine l0); elim_vrefine (vptr (ccell_data res.ll_unsnoc_tail)) (llist_fragment_tail_cons_data_refine l0); change_equal_slprop (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead) (llist_fragment_tail res.ll_unsnoc_l phead); res #pop-options let rec llist_fragment_tail_append (#opened: _) (#a: Type) (phead0: ref (ccell_ptrvalue a)) (l1: Ghost.erased (list a)) (phead1: Ghost.erased (ref (ccell_ptrvalue a))) (l2: Ghost.erased (list a)) : SteelGhost (Ghost.erased (list a)) opened (llist_fragment_tail l1 phead0 `star` llist_fragment_tail l2 phead1) (fun res -> llist_fragment_tail res phead0) (fun h -> Ghost.reveal phead1 == (sel_llist_fragment_tail l1 phead0) h ) (fun h res h' -> Ghost.reveal res == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\ (sel_llist_fragment_tail res phead0) h' == (sel_llist_fragment_tail l2 phead1) h ) (decreases (L.length (Ghost.reveal l2))) = let g1 = gget (llist_fragment_tail l1 phead0) in assert (Ghost.reveal phead1 == Ghost.reveal g1); if Nil? l2 then begin L.append_l_nil (Ghost.reveal l1); elim_llist_fragment_tail_nil l2 phead1; l1 end else begin let res = elim_llist_fragment_tail_snoc l2 (Ghost.reveal phead1) in let d = gget (vptr (ccell_data res.ll_unsnoc_tail)) in L.append_assoc (Ghost.reveal l1) (Ghost.reveal res.ll_unsnoc_l) [Ghost.reveal d]; let l3 = llist_fragment_tail_append phead0 l1 phead1 res.ll_unsnoc_l in intro_llist_fragment_tail_snoc l3 phead0 res.ll_unsnoc_ptail res.ll_unsnoc_tail end let queue_tail_refine (#a: Type) (tail1: ref (ccell_ptrvalue a)) (tail2: ref (ccell_ptrvalue a)) (tl: normal (t_of (vptr tail2))) : Tot prop = ccell_ptrvalue_is_null tl == true /\ tail1 == tail2 [@@__steel_reduce__] let queue_tail_dep2 (#a: Type) (x: t a) (l: Ghost.erased (list a)) (tail1: t_of (llist_fragment_tail l (cllist_head x))) (tail2: ref (ccell_ptrvalue a)) : Tot vprop = vptr tail2 `vrefine` queue_tail_refine tail1 tail2 [@@__steel_reduce__] let queue_tail_dep1 (#a: Type) (x: t a) (l: Ghost.erased (list a)) (tail1: t_of (llist_fragment_tail l (cllist_head x))) : Tot vprop = vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail1 [@@__steel_reduce__; __reduce__] let queue_tail (#a: Type) (x: t a) (l: Ghost.erased (list a)) : Tot vprop = llist_fragment_tail l (cllist_head x) `vdep` queue_tail_dep1 x l val intro_queue_tail (#opened: _) (#a: Type) (x: t a) (l: Ghost.erased (list a)) (tail: ref (ccell_ptrvalue a)) : SteelGhost unit opened (llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail) (fun _ -> queue_tail x l) (fun h -> sel_llist_fragment_tail l (cllist_head x) h == tail /\ sel (cllist_tail x) h == tail /\ ccell_ptrvalue_is_null (sel tail h) ) (fun _ _ _ -> True) let intro_queue_tail x l tail = intro_vrefine (vptr tail) (queue_tail_refine tail tail); intro_vdep2 (vptr (cllist_tail x)) (vptr tail `vrefine` queue_tail_refine tail tail) tail (queue_tail_dep2 x l tail); intro_vdep2 (llist_fragment_tail l (cllist_head x)) (vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail) tail (queue_tail_dep1 x l) val elim_queue_tail (#opened: _) (#a: Type) (x: t a) (l: Ghost.erased (list a)) : SteelGhost (Ghost.erased (ref (ccell_ptrvalue a))) opened (queue_tail x l) (fun tail -> llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail) (fun h -> True) (fun _ tail h -> sel_llist_fragment_tail l (cllist_head x) h == Ghost.reveal tail /\ sel (cllist_tail x) h == Ghost.reveal tail /\ ccell_ptrvalue_is_null (h (vptr tail)) ) let elim_queue_tail #_ #a x l = let tail0 = elim_vdep (llist_fragment_tail l (cllist_head x)) (queue_tail_dep1 x l) in let tail : Ghost.erased (ref (ccell_ptrvalue a)) = tail0 in change_equal_slprop (queue_tail_dep1 x l (Ghost.reveal tail0)) (vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail0); let tail2 = elim_vdep (vptr (cllist_tail x)) (queue_tail_dep2 x l tail0) in let tail3 : Ghost.erased (ref (ccell_ptrvalue a)) = tail2 in change_equal_slprop (queue_tail_dep2 x l tail0 (Ghost.reveal tail2)) (vptr tail3 `vrefine` queue_tail_refine tail0 tail3); elim_vrefine (vptr tail3) (queue_tail_refine tail0 tail3); change_equal_slprop (vptr tail3) (vptr tail); tail (* view from the head *) let llist_fragment_head_data_refine (#a: Type) (d: a) (c: vcell a) : Tot prop = c.vcell_data == d let llist_fragment_head_payload (#a: Type) (head: ccell_ptrvalue a) (d: a) (llist_fragment_head: (ref (ccell_ptrvalue a) -> ccell_ptrvalue a -> Tot vprop)) (x: t_of (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine d))) : Tot vprop = llist_fragment_head (ccell_next (fst x)) (snd x).vcell_next let rec llist_fragment_head (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : Tot vprop (decreases (Ghost.reveal l)) = if Nil? l then vconst (phead, head) else vbind (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l)))) (ref (ccell_ptrvalue a) & ccell_ptrvalue a) (llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l)))) let t_of_llist_fragment_head (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : Lemma (t_of (llist_fragment_head l phead head) == ref (ccell_ptrvalue a) & ccell_ptrvalue a) = () unfold let sel_llist_fragment_head (#a:Type) (#p:vprop) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) (h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_head l phead head) /\ True) }) : GTot (ref (ccell_ptrvalue a) & ccell_ptrvalue a) = coerce (h (llist_fragment_head l phead head)) (ref (ccell_ptrvalue a) & ccell_ptrvalue a) val intro_llist_fragment_head_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : SteelGhost unit opened emp (fun _ -> llist_fragment_head l phead head) (fun _ -> Nil? l) (fun _ _ h' -> sel_llist_fragment_head l phead head h' == (phead, head)) let intro_llist_fragment_head_nil l phead head = intro_vconst (phead, head); change_equal_slprop (vconst (phead, head)) (llist_fragment_head l phead head) val elim_llist_fragment_head_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : SteelGhost unit opened (llist_fragment_head l phead head) (fun _ -> emp) (fun _ -> Nil? l) (fun h _ _ -> sel_llist_fragment_head l phead head h == (phead, head)) let elim_llist_fragment_head_nil l phead head = change_equal_slprop (llist_fragment_head l phead head) (vconst (phead, head)); elim_vconst (phead, head) let llist_fragment_head_eq_cons (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : Lemma (requires (Cons? (Ghost.reveal l))) (ensures ( llist_fragment_head l phead head == vbind (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l)))) (ref (ccell_ptrvalue a) & ccell_ptrvalue a) (llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l)))) )) = assert_norm (llist_fragment_head l phead head == ( if Nil? l then vconst (phead, head) else vbind (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd (Ghost.reveal l)))) (ref (ccell_ptrvalue a) & ccell_ptrvalue a) (llist_fragment_head_payload head (L.hd (Ghost.reveal l)) (llist_fragment_head (L.tl (Ghost.reveal l)))) )) val intro_llist_fragment_head_cons (#opened: _) (#a: Type) (phead: ref (ccell_ptrvalue a)) (head: ccell_lvalue a) (next: (ccell_ptrvalue a)) (tl: Ghost.erased (list a)) : SteelGhost (Ghost.erased (list a)) opened (ccell head `star` llist_fragment_head tl (ccell_next head) next) (fun res -> llist_fragment_head res phead head) (fun h -> (h (ccell head)).vcell_next == next) (fun h res h' -> Ghost.reveal res == (h (ccell head)).vcell_data :: Ghost.reveal tl /\ h' (llist_fragment_head res phead head) == h (llist_fragment_head tl (ccell_next head) next) ) let intro_llist_fragment_head_cons #_ #a phead head next tl = let vc = gget (ccell head) in let l' : (l' : Ghost.erased (list a) { Cons? l' }) = Ghost.hide (vc.vcell_data :: tl) in intro_ccell_is_lvalue head; intro_vrefine (ccell head) (llist_fragment_head_data_refine (L.hd l')); intro_vbind (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l'))) (llist_fragment_head tl (ccell_next head) next) (ref (ccell_ptrvalue a) & ccell_ptrvalue a) (llist_fragment_head_payload head (L.hd l') (llist_fragment_head (L.tl l'))); llist_fragment_head_eq_cons l' phead head; change_equal_slprop (vbind (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l'))) (ref (ccell_ptrvalue a) & ccell_ptrvalue a) (llist_fragment_head_payload head (L.hd l') (llist_fragment_head (L.tl l')))) (llist_fragment_head l' phead head); l' [@@erasable] noeq type ll_uncons_t (a: Type) = { ll_uncons_pnext: Ghost.erased (ref (ccell_ptrvalue a)); ll_uncons_next: Ghost.erased (ccell_ptrvalue a); ll_uncons_tl: Ghost.erased (list a); } val elim_llist_fragment_head_cons (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : SteelGhost (ll_uncons_t a) opened (llist_fragment_head l phead head) (fun res -> ccell head `star` llist_fragment_head res.ll_uncons_tl res.ll_uncons_pnext res.ll_uncons_next) (fun _ -> Cons? (Ghost.reveal l)) (fun h res h' -> ccell_ptrvalue_is_null head == false /\ Ghost.reveal l == (h' (ccell head)).vcell_data :: Ghost.reveal res.ll_uncons_tl /\ Ghost.reveal res.ll_uncons_pnext == ccell_next head /\ Ghost.reveal res.ll_uncons_next == (h' (ccell head)).vcell_next /\ h' (llist_fragment_head res.ll_uncons_tl res.ll_uncons_pnext res.ll_uncons_next) == h (llist_fragment_head l phead head) ) let elim_llist_fragment_head_cons #_ #a l0 phead head = let l : (l : Ghost.erased (list a) { Cons? l }) = l0 in change_equal_slprop (llist_fragment_head l0 phead head) (llist_fragment_head l phead head); llist_fragment_head_eq_cons l phead head; change_equal_slprop (llist_fragment_head l phead head) (vbind (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l))) (ref (ccell_ptrvalue a) & ccell_ptrvalue a) (llist_fragment_head_payload head (L.hd l) (llist_fragment_head (L.tl l)))); let x = elim_vbind (ccell_is_lvalue head `star` (ccell head `vrefine` llist_fragment_head_data_refine (L.hd l))) (ref (ccell_ptrvalue a) & ccell_ptrvalue a) (llist_fragment_head_payload head (L.hd l) (llist_fragment_head (L.tl l))) in let head2 = gget (ccell_is_lvalue head) in elim_ccell_is_lvalue head; elim_vrefine (ccell head) (llist_fragment_head_data_refine (L.hd l)); let vhead2 = gget (ccell head) in let res = { ll_uncons_pnext = ccell_next head2; ll_uncons_next = vhead2.vcell_next; ll_uncons_tl = L.tl l; } in change_equal_slprop (llist_fragment_head_payload head (L.hd l) (llist_fragment_head (L.tl l)) (Ghost.reveal x)) (llist_fragment_head res.ll_uncons_tl res.ll_uncons_pnext res.ll_uncons_next); res let rec llist_fragment_head_append (#opened: _) (#a: Type) (l1: Ghost.erased (list a)) (phead1: ref (ccell_ptrvalue a)) (head1: ccell_ptrvalue a) (l2: Ghost.erased (list a)) (phead2: ref (ccell_ptrvalue a)) (head2: ccell_ptrvalue a) : SteelGhost (Ghost.erased (list a)) opened (llist_fragment_head l1 phead1 head1 `star` llist_fragment_head l2 phead2 head2) (fun l -> llist_fragment_head l phead1 head1) (fun h -> sel_llist_fragment_head l1 phead1 head1 h == (Ghost.reveal phead2, Ghost.reveal head2)) (fun h l h' -> Ghost.reveal l == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\ h' (llist_fragment_head l phead1 head1) == h (llist_fragment_head l2 phead2 head2) ) (decreases (Ghost.reveal l1)) = if Nil? l1 then begin elim_llist_fragment_head_nil l1 phead1 head1; change_equal_slprop (llist_fragment_head l2 phead2 head2) (llist_fragment_head l2 phead1 head1); l2 end else begin let u = elim_llist_fragment_head_cons l1 phead1 head1 in let head1' : Ghost.erased (ccell_lvalue a) = head1 in let l3 = llist_fragment_head_append u.ll_uncons_tl u.ll_uncons_pnext u.ll_uncons_next l2 phead2 head2 in change_equal_slprop (llist_fragment_head l3 u.ll_uncons_pnext u.ll_uncons_next) (llist_fragment_head l3 (ccell_next head1') u.ll_uncons_next); change_equal_slprop (ccell head1) (ccell head1'); let l4 = intro_llist_fragment_head_cons phead1 head1' u.ll_uncons_next l3 in change_equal_slprop (llist_fragment_head l4 phead1 head1') (llist_fragment_head l4 phead1 head1); l4 end let rec llist_fragment_head_to_tail (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : SteelGhost (Ghost.erased (ref (ccell_ptrvalue a))) opened (vptr phead `star` llist_fragment_head l phead head) (fun res -> llist_fragment_tail l phead `star` vptr res) (fun h -> h (vptr phead) == head) (fun h res h' -> let v = sel_llist_fragment_head l phead head h in fst v == Ghost.reveal res /\ fst v == sel_llist_fragment_tail l phead h' /\ snd v == h' (vptr res) ) (decreases (L.length (Ghost.reveal l))) = if Nil? l then begin let ptail = Ghost.hide phead in let gh = gget (vptr phead) in assert (Ghost.reveal gh == head); elim_llist_fragment_head_nil l phead head; intro_llist_fragment_tail_nil l phead; change_equal_slprop (vptr phead) (vptr ptail); ptail end else begin intro_llist_fragment_tail_nil [] phead; change_equal_slprop (vptr phead) (vptr (Ghost.reveal (Ghost.hide phead))); let uc = elim_llist_fragment_head_cons l phead head in let head' = elim_ccell_ghost head in change_equal_slprop (vptr (ccell_next head')) (vptr uc.ll_uncons_pnext); let lc = intro_llist_fragment_tail_snoc [] phead phead head' in let ptail = llist_fragment_head_to_tail uc.ll_uncons_tl uc.ll_uncons_pnext uc.ll_uncons_next in let l' = llist_fragment_tail_append phead lc uc.ll_uncons_pnext uc.ll_uncons_tl in change_equal_slprop (llist_fragment_tail l' phead) (llist_fragment_tail l phead); ptail end #push-options "--z3rlimit 16" #restart-solver let rec llist_fragment_tail_to_head (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (ptail: ref (ccell_ptrvalue a)) : SteelGhost (Ghost.erased (ccell_ptrvalue a)) opened (llist_fragment_tail l phead `star` vptr ptail) (fun head -> vptr phead `star` llist_fragment_head l phead (Ghost.reveal head)) (fun h -> Ghost.reveal ptail == sel_llist_fragment_tail l phead h) (fun h head h' -> let v = sel_llist_fragment_head l phead head h' in fst v == ptail /\ snd v == h (vptr ptail) /\ h' (vptr phead) == Ghost.reveal head ) (decreases (L.length (Ghost.reveal l))) = if Nil? l then begin let g = gget (llist_fragment_tail l phead) in assert (Ghost.reveal g == ptail); elim_llist_fragment_tail_nil l phead; change_equal_slprop (vptr ptail) (vptr phead); let head = gget (vptr phead) in intro_llist_fragment_head_nil l phead head; head end else begin let us = elim_llist_fragment_tail_snoc l phead in let tail = gget (vptr ptail) in assert (ccell_next us.ll_unsnoc_tail == ptail); intro_llist_fragment_head_nil [] (ccell_next us.ll_unsnoc_tail) tail; change_equal_slprop (vptr ptail) (vptr (ccell_next us.ll_unsnoc_tail)); intro_ccell us.ll_unsnoc_tail; let lc = intro_llist_fragment_head_cons us.ll_unsnoc_ptail us.ll_unsnoc_tail tail [] in let head = llist_fragment_tail_to_head us.ll_unsnoc_l phead us.ll_unsnoc_ptail in let g = gget (llist_fragment_head us.ll_unsnoc_l phead head) in let g : Ghost.erased (ref (ccell_ptrvalue a) & ccell_ptrvalue a) = Ghost.hide (Ghost.reveal g) in assert (Ghost.reveal g == (Ghost.reveal us.ll_unsnoc_ptail, Ghost.reveal us.ll_unsnoc_tail)); let l' = llist_fragment_head_append us.ll_unsnoc_l phead head lc us.ll_unsnoc_ptail us.ll_unsnoc_tail in change_equal_slprop (llist_fragment_head l' phead head) (llist_fragment_head l phead head); head end #pop-options val llist_fragment_head_is_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) : SteelGhost unit opened (llist_fragment_head l phead head) (fun _ -> llist_fragment_head l phead head) (fun h -> ccell_ptrvalue_is_null (snd (sel_llist_fragment_head l phead head h)) == true) (fun h _ h' -> Nil? l == ccell_ptrvalue_is_null head /\ h' (llist_fragment_head l phead head) == h (llist_fragment_head l phead head) ) let llist_fragment_head_is_nil l phead head = if Nil? l then begin elim_llist_fragment_head_nil l phead head; assert (ccell_ptrvalue_is_null head == true); intro_llist_fragment_head_nil l phead head end else begin let r = elim_llist_fragment_head_cons l phead head in let head2 : ccell_lvalue _ = head in change_equal_slprop (llist_fragment_head r.ll_uncons_tl r.ll_uncons_pnext r.ll_uncons_next) (llist_fragment_head r.ll_uncons_tl (ccell_next head2) r.ll_uncons_next); change_equal_slprop (ccell head) (ccell head2); let l' = intro_llist_fragment_head_cons phead head2 r.ll_uncons_next r.ll_uncons_tl in change_equal_slprop (llist_fragment_head l' phead head2) (llist_fragment_head l phead head) end val llist_fragment_head_cons_change_phead (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (head: ccell_ptrvalue a) (phead' : ref (ccell_ptrvalue a)) : SteelGhost unit opened (llist_fragment_head l phead head) (fun _ -> llist_fragment_head l phead' head) (fun _ -> Cons? l) (fun h _ h' -> h' (llist_fragment_head l phead' head) == h (llist_fragment_head l phead head))
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "CQueue.LList.fsti.checked" ], "interface_file": true, "source_file": "CQueue.fst" }
[ { "abbrev": false, "full_module": "CQueue.LList", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
l: FStar.Ghost.erased (Prims.list a) -> phead: Steel.Reference.ref (CQueue.Cell.ccell_ptrvalue a) -> head: CQueue.Cell.ccell_ptrvalue a -> phead': Steel.Reference.ref (CQueue.Cell.ccell_ptrvalue a) -> Steel.Effect.Atomic.SteelGhost Prims.unit
Steel.Effect.Atomic.SteelGhost
[]
[]
[ "Steel.Memory.inames", "FStar.Ghost.erased", "Prims.list", "Steel.Reference.ref", "CQueue.Cell.ccell_ptrvalue", "Steel.Effect.Atomic.change_equal_slprop", "CQueue.llist_fragment_head", "Prims.unit", "CQueue.intro_llist_fragment_head_cons", "FStar.Ghost.reveal", "CQueue.__proj__Mkll_uncons_t__item__ll_uncons_next", "CQueue.__proj__Mkll_uncons_t__item__ll_uncons_tl", "CQueue.__proj__Mkll_uncons_t__item__ll_uncons_pnext", "CQueue.Cell.ccell_next", "CQueue.Cell.ccell", "CQueue.Cell.ccell_lvalue", "CQueue.ll_uncons_t", "CQueue.elim_llist_fragment_head_cons" ]
[]
false
true
false
false
false
let llist_fragment_head_cons_change_phead l phead head phead' =
let u = elim_llist_fragment_head_cons l phead head in let head2:ccell_lvalue _ = head in change_equal_slprop (ccell head) (ccell head2); change_equal_slprop (llist_fragment_head u.ll_uncons_tl u.ll_uncons_pnext u.ll_uncons_next) (llist_fragment_head u.ll_uncons_tl (ccell_next head2) u.ll_uncons_next); let l' = intro_llist_fragment_head_cons phead' head2 u.ll_uncons_next u.ll_uncons_tl in change_equal_slprop (llist_fragment_head l' phead' head2) (llist_fragment_head l phead' head)
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.mm_refs_pred
val mm_refs_pred (m1 m2: mem) : Type0
val mm_refs_pred (m1 m2: mem) : Type0
let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2))
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 29, "end_line": 82, "start_col": 8, "start_line": 77 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m1: FStar.Monotonic.HyperStack.mem -> m2: FStar.Monotonic.HyperStack.mem -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "Prims.l_Forall", "FStar.Preorder.preorder", "FStar.Monotonic.HyperStack.mreference", "Prims.l_or", "Prims.b2t", "Prims.op_Negation", "FStar.Monotonic.HyperStack.is_mm", "Prims.l_imp", "FStar.Monotonic.HyperStack.contains", "Prims.l_and", "FStar.Monotonic.HyperStack.sel", "FStar.Monotonic.HyperStack.unused_in" ]
[]
false
false
false
true
true
let mm_refs_pred (m1 m2: mem) : Type0 =
forall (a: Type) (rel: preorder a) (r: HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2))
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.ref_contains_pred
val ref_contains_pred (#a:Type) (#rel:preorder a) (r:HS.mreference a rel) :mem_predicate
val ref_contains_pred (#a:Type) (#rel:preorder a) (r:HS.mreference a rel) :mem_predicate
let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r)))
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 47, "end_line": 102, "start_col": 0, "start_line": 95 }
(* 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.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Monotonic.HyperStack.mreference a rel -> FStar.HyperStack.ST.mem_predicate
Prims.Tot
[ "total" ]
[]
[ "FStar.Preorder.preorder", "FStar.Monotonic.HyperStack.mreference", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.Monotonic.HyperHeap.rid_last_component", "FStar.Monotonic.HyperStack.get_rid_ctr", "Prims.l_imp", "FStar.HyperStack.ST.contains_region", "FStar.Monotonic.HyperStack.as_addr", "FStar.Monotonic.Heap.next_addr", "FStar.Map.sel", "FStar.Monotonic.HyperHeap.rid", "FStar.Monotonic.Heap.heap", "FStar.Monotonic.HyperStack.get_hmap", "FStar.Monotonic.HyperStack.is_mm", "Prims.l_or", "FStar.Monotonic.HyperStack.contains", "FStar.Monotonic.HyperStack.unused_in", "Prims.op_Negation", "FStar.Monotonic.HyperStack.frameOf" ]
[]
false
false
false
false
false
let ref_contains_pred #_ #_ r =
fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ((HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r)))
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.region_contains_pred
val region_contains_pred (r:HS.rid) :mem_predicate
val region_contains_pred (r:HS.rid) :mem_predicate
let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 69, "end_line": 93, "start_col": 0, "start_line": 92 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Monotonic.HyperHeap.rid -> FStar.HyperStack.ST.mem_predicate
Prims.Tot
[ "total" ]
[]
[ "FStar.Monotonic.HyperHeap.rid", "FStar.Monotonic.HyperStack.mem", "Prims.l_or", "Prims.b2t", "Prims.op_Negation", "FStar.Monotonic.HyperStack.is_eternal_region_hs", "FStar.HyperStack.ST.contains_region" ]
[]
false
false
false
true
false
let region_contains_pred r =
fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.stable
val stable (p:mem_predicate) :Type0
val stable (p:mem_predicate) :Type0
let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 99, "end_line": 104, "start_col": 0, "start_line": 104 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: FStar.HyperStack.ST.mem_predicate -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.HyperStack.ST.mem_predicate", "Prims.l_Forall", "FStar.Monotonic.HyperStack.mem", "Prims.l_imp", "Prims.l_and", "FStar.HyperStack.ST.mem_rel" ]
[]
false
false
false
true
true
let stable p =
forall (h1: mem) (h2: mem). {:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.witnessed
val witnessed (p:mem_predicate) :Type0
val witnessed (p:mem_predicate) :Type0
let witnessed p = W.witnessed mem_rel p
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 39, "end_line": 106, "start_col": 0, "start_line": 106 }
(* 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.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: FStar.HyperStack.ST.mem_predicate -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.HyperStack.ST.mem_predicate", "FStar.Monotonic.Witnessed.witnessed", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.mem_rel" ]
[]
false
false
false
true
true
let witnessed p =
W.witnessed mem_rel p
false
Pulse.Checker.Bind.fst
Pulse.Checker.Bind.check_tot_bind
val check_tot_bind (g:env) (pre:term) (pre_typing:tot_typing g pre tm_vprop) (post_hint:post_hint_opt g) (res_ppname:ppname) (t:st_term { Tm_TotBind? t.term }) (check:check_t) : T.Tac (checker_result_t g pre post_hint)
val check_tot_bind (g:env) (pre:term) (pre_typing:tot_typing g pre tm_vprop) (post_hint:post_hint_opt g) (res_ppname:ppname) (t:st_term { Tm_TotBind? t.term }) (check:check_t) : T.Tac (checker_result_t g pre post_hint)
let check_tot_bind (g:env) (pre:term) (pre_typing:tot_typing g pre tm_vprop) (post_hint:post_hint_opt g) (res_ppname:ppname) (t:st_term { Tm_TotBind? t.term }) (check:check_t) : T.Tac (checker_result_t g pre post_hint) = let g = Pulse.Typing.Env.push_context g "check_tot_bind" t.range in if None? post_hint then fail g (Some t.range) "check_tot_bind: post hint is not set, please add an annotation"; let Tm_TotBind { binder=b; head=e1; body=e2 } = t.term in match Pulse.Checker.Base.is_stateful_application g e1 with | Some st_app -> ( let t = { t with term = Tm_Bind { binder=b; head=st_app; body=e2 } } in check_bind g pre pre_typing post_hint res_ppname t check ) | None -> ( let head = Tm_Return { expected_type = b.binder_ty; term = e1; insert_eq = true } in let head = { term = head; range = e1.range; effect_tag = default_effect_hint } in let t = { t with term = Tm_Bind { binder=b; head; body=e2 } } in check_bind g pre pre_typing post_hint res_ppname t check )
{ "file_name": "lib/steel/pulse/Pulse.Checker.Bind.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 3, "end_line": 158, "start_col": 0, "start_line": 130 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.Bind open Pulse.Syntax open Pulse.Typing open Pulse.Typing.Combinators open Pulse.Checker.Base open Pulse.Checker.Pure open Pulse.Checker.Prover module T = FStar.Tactics.V2 module P = Pulse.Syntax.Printer module Metatheory = Pulse.Typing.Metatheory module PS = Pulse.Checker.Prover.Substs module Abs = Pulse.Checker.Abs #push-options "--query_stats --z3rlimit_factor 4 --split_queries no" let check_bind_fn (g:env) (ctxt:vprop) (ctxt_typing:tot_typing g ctxt tm_vprop) (post_hint:post_hint_opt g) (res_ppname:ppname) (t:st_term {Tm_Bind? t.term}) (check:check_t) : T.Tac (checker_result_t g ctxt post_hint) = let Tm_Bind { binder; head; body } = t.term in match head.term with | Tm_Abs _ -> ( let (| t, c, head_typing |) = Abs.check_abs g head check in if not (C_Tot? c) then fail g (Some t.range) "check_bind_fn: head is not a total abstraction"; if None? post_hint then fail g (Some t.range) "check_bind: please annotate the postcondition"; let x = fresh g in let b = { binder with binder_ty = comp_res c } in let g' = push_binding g x (binder.binder_ppname) b.binder_ty in let ctxt_typing' : tot_typing g' ctxt tm_vprop = Metatheory.tot_typing_weakening_single ctxt_typing x b.binder_ty in let r = check g' _ ctxt_typing' post_hint res_ppname (open_st_term_nv body (binder.binder_ppname, x)) in let body_typing = apply_checker_result_k #_ #_ #(Some?.v post_hint) r res_ppname in let k = Pulse.Checker.Base.continuation_elaborator_with_bind_fn ctxt_typing b head_typing (binder.binder_ppname, x) in let d = k post_hint body_typing in checker_result_for_st_typing d res_ppname ) | _ -> fail g (Some t.range) "check_bind_fn: head is not an abstraction" #pop-options #push-options "--z3rlimit_factor 4 --fuel 1 --ifuel 1" let check_bind (g:env) (ctxt:vprop) (ctxt_typing:tot_typing g ctxt tm_vprop) (post_hint:post_hint_opt g) (res_ppname:ppname) (t:st_term {Tm_Bind? t.term}) (check:check_t) : T.Tac (checker_result_t g ctxt post_hint) = let g = Pulse.Typing.Env.push_context g "check_bind" t.range in debug_prover g (fun _ -> Printf.sprintf "checking bind:\n%s\n" (P.st_term_to_string t)); if None? post_hint then fail g (Some t.range) "check_bind: post hint is not set, please add an annotation"; let Tm_Bind { binder; head=e1; body=e2 } = t.term in if Tm_Admit? e1.term then ( //Discard the continuation if the head is an admit check g ctxt ctxt_typing post_hint res_ppname e1 ) else if Tm_Abs? e1.term then ( check_bind_fn g ctxt ctxt_typing post_hint res_ppname t check ) else ( let (| x, g1, _, (| ctxt', ctxt'_typing |), k1 |) = let r = check g ctxt ctxt_typing None binder.binder_ppname e1 in (* Check that the type matches the annotation, if any *) let ty = binder.binder_ty in begin match ty.t with | Tm_Unknown -> () | _ -> let (| ty, _, _ |) = compute_tot_term_type g ty in //elaborate it first let (| _, _, (| _, t, _ |), _, _ |) = r in // TODO: once we have the rename operation then we should // ditch this check and just elaborate the bind // let x : ty = stapp in ... // to // let x0 = stapp in // let x : t = x0 in // rename x0 x; ... // to leverage the pure case if not (eq_tm ty t) then fail g (Some e1.range) (Printf.sprintf "Type mismatch: expected %s, got %s" (P.term_to_string ty) (P.term_to_string t)) end; r in let g1 = reset_context g1 g in let d : st_typing_in_ctxt g1 ctxt' post_hint = let ppname = mk_ppname_no_range "_bind_c" in let r = check g1 ctxt' ctxt'_typing post_hint ppname (open_st_term_nv e2 (binder.binder_ppname, x)) in apply_checker_result_k #_ #_ #(Some?.v post_hint) r ppname in let d : st_typing_in_ctxt g ctxt post_hint = k1 post_hint d in checker_result_for_st_typing d res_ppname )
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.fst.checked", "Pulse.Checker.Pure.fsti.checked", "Pulse.Checker.Prover.Substs.fsti.checked", "Pulse.Checker.Prover.fsti.checked", "Pulse.Checker.Base.fsti.checked", "Pulse.Checker.Abs.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Bind.fst" }
[ { "abbrev": true, "full_module": "Pulse.Checker.Abs", "short_module": "Abs" }, { "abbrev": true, "full_module": "Pulse.Checker.Prover.Substs", "short_module": "PS" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker.Prover", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Typing.Env.env -> pre: Pulse.Syntax.Base.term -> pre_typing: Pulse.Typing.tot_typing g pre Pulse.Syntax.Base.tm_vprop -> post_hint: Pulse.Typing.post_hint_opt g -> res_ppname: Pulse.Syntax.Base.ppname -> t: Pulse.Syntax.Base.st_term{Tm_TotBind? (Mkst_term?.term t)} -> check: Pulse.Checker.Base.check_t -> FStar.Tactics.Effect.Tac (Pulse.Checker.Base.checker_result_t g pre post_hint)
FStar.Tactics.Effect.Tac
[]
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.term", "Pulse.Typing.tot_typing", "Pulse.Syntax.Base.tm_vprop", "Pulse.Typing.post_hint_opt", "Pulse.Syntax.Base.ppname", "Pulse.Syntax.Base.st_term", "Prims.b2t", "Pulse.Syntax.Base.uu___is_Tm_TotBind", "Pulse.Syntax.Base.__proj__Mkst_term__item__term", "Pulse.Checker.Base.check_t", "Pulse.Syntax.Base.binder", "Pulse.Checker.Bind.check_bind", "Pulse.Checker.Base.checker_result_t", "Pulse.Syntax.Base.Mkst_term", "Pulse.Syntax.Base.Tm_Bind", "Pulse.Syntax.Base.Mkst_term'__Tm_Bind__payload", "Pulse.Syntax.Base.__proj__Mkst_term__item__range", "Pulse.Syntax.Base.__proj__Mkst_term__item__effect_tag", "Pulse.Syntax.Base.__proj__Mkterm__item__range", "Pulse.Syntax.Base.default_effect_hint", "Pulse.Syntax.Base.st_term'", "Pulse.Syntax.Base.Tm_Return", "Pulse.Syntax.Base.Mkst_term'__Tm_Return__payload", "Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ty", "FStar.Pervasives.Native.option", "Pulse.Checker.Base.is_stateful_application", "Prims.unit", "FStar.Pervasives.Native.uu___is_None", "Pulse.Typing.post_hint_t", "Pulse.Typing.Env.fail", "FStar.Pervasives.Native.Some", "Pulse.Syntax.Base.range", "Prims.bool", "Prims.eq2", "Pulse.Typing.Env.push_context" ]
[]
false
true
false
false
false
let check_tot_bind (g: env) (pre: term) (pre_typing: tot_typing g pre tm_vprop) (post_hint: post_hint_opt g) (res_ppname: ppname) (t: st_term{Tm_TotBind? t.term}) (check: check_t) : T.Tac (checker_result_t g pre post_hint) =
let g = Pulse.Typing.Env.push_context g "check_tot_bind" t.range in if None? post_hint then fail g (Some t.range) "check_tot_bind: post hint is not set, please add an annotation"; let Tm_TotBind { binder = b ; head = e1 ; body = e2 } = t.term in match Pulse.Checker.Base.is_stateful_application g e1 with | Some st_app -> (let t = { t with term = Tm_Bind ({ binder = b; head = st_app; body = e2 }) } in check_bind g pre pre_typing post_hint res_ppname t check) | None -> (let head = Tm_Return ({ expected_type = b.binder_ty; term = e1; insert_eq = true }) in let head = { term = head; range = e1.range; effect_tag = default_effect_hint } in let t = { t with term = Tm_Bind ({ binder = b; head = head; body = e2 }) } in check_bind g pre pre_typing post_hint res_ppname t check)
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.mem_rel
val mem_rel :preorder mem
val mem_rel :preorder mem
let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 97, "end_line": 89, "start_col": 0, "start_line": 85 }
(* 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.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Preorder.preorder FStar.Monotonic.HyperStack.mem
Prims.Tot
[ "total" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "FStar.HyperStack.ST.eternal_region_pred", "FStar.HyperStack.ST.rid_ctr_pred", "FStar.HyperStack.ST.rid_last_component_pred", "FStar.HyperStack.ST.eternal_refs_pred", "FStar.HyperStack.ST.next_ref_addr_in_a_region_pred", "FStar.HyperStack.ST.unused_ref_next_addr_pred", "FStar.HyperStack.ST.mm_refs_pred", "Prims.logical", "Prims.unit", "FStar.Monotonic.HyperStack.lemma_next_addr_contained_refs_addr", "FStar.Monotonic.HyperStack.lemma_rid_ctr_pred", "FStar.Preorder.preorder" ]
[]
false
false
false
true
false
let mem_rel:preorder mem =
HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1: mem) (m2: mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2
false
Steel.ST.Array.fst
Steel.ST.Array.ghost_join
val ghost_join (#opened: _) (#elt: Type) (#x1 #x2: Seq.seq elt) (#p: P.perm) (a1 a2: array elt) (h: squash (adjacent a1 a2)) : STGhostT unit opened (pts_to a1 p x1 `star` pts_to a2 p x2) (fun res -> pts_to (merge a1 a2) p (x1 `Seq.append` x2))
val ghost_join (#opened: _) (#elt: Type) (#x1 #x2: Seq.seq elt) (#p: P.perm) (a1 a2: array elt) (h: squash (adjacent a1 a2)) : STGhostT unit opened (pts_to a1 p x1 `star` pts_to a2 p x2) (fun res -> pts_to (merge a1 a2) p (x1 `Seq.append` x2))
let ghost_join #_ #_ #x1 #x2 #p a1 a2 h = rewrite (pts_to a1 _ _) (H.pts_to a1 p (seq_map raise x1)); rewrite (pts_to a2 _ _) (H.pts_to a2 p (seq_map raise x2)); H.ghost_join a1 a2 h; assert (seq_map raise (x1 `Seq.append` x2) `Seq.equal` (seq_map raise x1 `Seq.append` seq_map raise x2)); rewrite (H.pts_to _ _ _) (H.pts_to (merge a1 a2) p (seq_map raise (x1 `Seq.append` x2))); rewrite (H.pts_to _ _ _) (pts_to (merge a1 a2) _ _)
{ "file_name": "lib/steel/Steel.ST.Array.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 30, "end_line": 202, "start_col": 0, "start_line": 187 }
(* Copyright 2020, 2021, 2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Array module US = FStar.SizeT /// Lifting a value of universe 0 to universe 1. We use /// FStar.Universe, since FStar.Extraction.Krml is set to extract /// those functions to identity. inline_for_extraction [@@ noextract_to "krml"] let raise_t (t: Type0) : Type u#1 = FStar.Universe.raise_t t inline_for_extraction [@@noextract_to "krml"] let raise (#t: Type) (x: t) : Tot (raise_t t) = FStar.Universe.raise_val x inline_for_extraction [@@noextract_to "krml"] let lower (#t: Type) (x: raise_t t) : Tot t = FStar.Universe.downgrade_val x /// A map operation on sequences. Here we only need Ghost versions, /// because such sequences are only used in vprops or with their /// selectors. let rec seq_map (#t: Type u#a) (#t' : Type u#b) (f: (t -> GTot t')) (s: Seq.seq t) : Ghost (Seq.seq t') (requires True) (ensures (fun s' -> Seq.length s' == Seq.length s /\ (forall i . {:pattern (Seq.index s' i)} Seq.index s' i == f (Seq.index s i)) )) (decreases (Seq.length s)) = if Seq.length s = 0 then Seq.empty else Seq.cons (f (Seq.index s 0)) (seq_map f (Seq.slice s 1 (Seq.length s))) let seq_map_append (#t: Type u#a) (#t': Type u#b) (f: (t -> GTot t')) (s1 s2: Seq.seq t) : Lemma (seq_map f (s1 `Seq.append` s2) `Seq.equal` (seq_map f s1 `Seq.append` seq_map f s2)) = () let seq_map_raise_inj (#elt: Type0) (s1 s2: Seq.seq elt) : Lemma (requires (seq_map raise s1 == seq_map raise s2)) (ensures (s1 == s2)) [SMTPat (seq_map raise s1); SMTPat (seq_map raise s2)] = assert (seq_map lower (seq_map raise s1) `Seq.equal` s1); assert (seq_map lower (seq_map raise s2) `Seq.equal` s2) /// Implementation of the interface /// base, ptr, array, pts_to module H = Steel.ST.HigherArray let base_t elt = H.base_t (raise_t elt) let base_len b = H.base_len b let ptr elt = H.ptr (raise_t elt) let null_ptr elt = H.null_ptr (raise_t elt) let is_null_ptr p = H.is_null_ptr p let base p = H.base p let offset p = H.offset p let ptr_base_offset_inj p1 p2 = H.ptr_base_offset_inj p1 p2 let base_len_null_ptr elt = H.base_len_null_ptr (raise_t elt) let length_fits a = H.length_fits a let pts_to a p s = H.pts_to a p (seq_map raise s) let pts_to_length a s = H.pts_to_length a _ let h_array_eq' (#t: Type u#1) (a1 a2: H.array t) : Lemma (requires ( dfst a1 == dfst a2 /\ (Ghost.reveal (dsnd a1) <: nat) == Ghost.reveal (dsnd a2) )) (ensures ( a1 == a2 )) = () let pts_to_not_null #_ #t #p a s = let _ = H.pts_to_not_null #_ #_ #p a (seq_map raise s) in assert (a =!= H.null #(raise_t t)); Classical.move_requires (h_array_eq' a) (H.null #(raise_t t)); noop () let pts_to_inj a p1 s1 p2 s2 = H.pts_to_inj a p1 (seq_map raise s1) p2 (seq_map raise s2) /// Non-selector operations. let malloc x n = let res = H.malloc (raise x) n in assert (seq_map raise (Seq.create (US.v n) x) `Seq.equal` Seq.create (US.v n) (raise x)); rewrite (H.pts_to res _ _) (pts_to res _ _); return res let free #_ x = let s = elim_exists () in rewrite (pts_to x _ _) (H.pts_to x P.full_perm (seq_map raise s)); H.free x let share #_ #_ #x a p p1 p2 = rewrite (pts_to a _ _) (H.pts_to a p (seq_map raise x)); H.share a p p1 p2; rewrite (H.pts_to a p1 _) (pts_to a p1 x); rewrite (H.pts_to a p2 _) (pts_to a p2 x) let gather #_ #_ a #x1 p1 #x2 p2 = rewrite (pts_to a p1 _) (H.pts_to a p1 (seq_map raise x1)); rewrite (pts_to a p2 _) (H.pts_to a p2 (seq_map raise x2)); H.gather a p1 p2; rewrite (H.pts_to a _ _) (pts_to _ _ _) let index #_ #p a #s i = rewrite (pts_to a _ _) (H.pts_to a p (seq_map raise s)); let res = H.index a i in rewrite (H.pts_to _ _ _) (pts_to _ _ _); return (lower res) let upd #_ a #s i v = rewrite (pts_to a _ _) (H.pts_to a P.full_perm (seq_map raise s)); H.upd a i (raise v); assert (seq_map raise (Seq.upd s (US.v i) v) `Seq.equal` Seq.upd (seq_map raise s) (US.v i) (raise v)); rewrite (H.pts_to _ _ _) (pts_to _ _ _)
{ "checked_file": "/", "dependencies": [ "Steel.ST.Reference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.ST.HigherArray.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Array.fst" }
[ { "abbrev": true, "full_module": "Steel.ST.HigherArray", "short_module": "H" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": true, "full_module": "FStar.PtrdiffT", "short_module": "UP" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a1: Steel.ST.Array.array elt -> a2: Steel.ST.Array.array elt -> h: Prims.squash (Steel.ST.Array.adjacent a1 a2) -> Steel.ST.Effect.Ghost.STGhostT Prims.unit
Steel.ST.Effect.Ghost.STGhostT
[]
[]
[ "Steel.Memory.inames", "FStar.Seq.Base.seq", "Steel.FractionalPermission.perm", "Steel.ST.Array.array", "Prims.squash", "Steel.ST.Array.adjacent", "Steel.ST.Util.rewrite", "Steel.ST.HigherArray.pts_to", "Steel.ST.Array.raise_t", "Steel.ST.Array.merge", "FStar.Ghost.hide", "Steel.ST.Array.seq_map", "Steel.ST.Array.raise", "FStar.Seq.Base.append", "Steel.ST.Array.pts_to", "Prims.unit", "Steel.ST.HigherArray.merge", "Steel.ST.HigherArray.array", "Prims._assert", "FStar.Seq.Base.equal", "Steel.ST.HigherArray.ghost_join" ]
[]
false
true
false
false
false
let ghost_join #_ #_ #x1 #x2 #p a1 a2 h =
rewrite (pts_to a1 _ _) (H.pts_to a1 p (seq_map raise x1)); rewrite (pts_to a2 _ _) (H.pts_to a2 p (seq_map raise x2)); H.ghost_join a1 a2 h; assert ((seq_map raise (x1 `Seq.append` x2)) `Seq.equal` ((seq_map raise x1) `Seq.append` (seq_map raise x2))); rewrite (H.pts_to _ _ _) (H.pts_to (merge a1 a2) p (seq_map raise (x1 `Seq.append` x2))); rewrite (H.pts_to _ _ _) (pts_to (merge a1 a2) _ _)
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.same_refs_in_all_regions
val same_refs_in_all_regions (m0 m1:mem) :Type0
val same_refs_in_all_regions (m0 m1:mem) :Type0
let same_refs_in_all_regions m0 m1 = same_refs_common contained_region m0 m1
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 76, "end_line": 117, "start_col": 0, "start_line": 117 }
(* 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.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2 let witnessed p = W.witnessed mem_rel p (* TODO: we should derive these using DM4F *) let gst_get _ = admit () let gst_put _ = admit () let gst_witness _ = admit () let gst_recall _ = admit () let lemma_functoriality p q = W.lemma_witnessed_weakening mem_rel p q
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m0: FStar.Monotonic.HyperStack.mem -> m1: FStar.Monotonic.HyperStack.mem -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.same_refs_common", "FStar.HyperStack.ST.contained_region" ]
[]
false
false
false
true
true
let same_refs_in_all_regions m0 m1 =
same_refs_common contained_region m0 m1
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.same_refs_in_stack_regions
val same_refs_in_stack_regions (m0 m1:mem) :Type0
val same_refs_in_stack_regions (m0 m1:mem) :Type0
let same_refs_in_stack_regions m0 m1 = same_refs_common contained_stack_region m0 m1
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 84, "end_line": 118, "start_col": 0, "start_line": 118 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2 let witnessed p = W.witnessed mem_rel p (* TODO: we should derive these using DM4F *) let gst_get _ = admit () let gst_put _ = admit () let gst_witness _ = admit () let gst_recall _ = admit () let lemma_functoriality p q = W.lemma_witnessed_weakening mem_rel p q
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m0: FStar.Monotonic.HyperStack.mem -> m1: FStar.Monotonic.HyperStack.mem -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.same_refs_common", "FStar.HyperStack.ST.contained_stack_region" ]
[]
false
false
false
true
true
let same_refs_in_stack_regions m0 m1 =
same_refs_common contained_stack_region m0 m1
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.same_refs_in_non_tip_regions
val same_refs_in_non_tip_regions (m0 m1:mem) :Type0
val same_refs_in_non_tip_regions (m0 m1:mem) :Type0
let same_refs_in_non_tip_regions m0 m1 = same_refs_common contained_non_tip_region m0 m1
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 88, "end_line": 119, "start_col": 0, "start_line": 119 }
(* 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.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2 let witnessed p = W.witnessed mem_rel p (* TODO: we should derive these using DM4F *) let gst_get _ = admit () let gst_put _ = admit () let gst_witness _ = admit () let gst_recall _ = admit () let lemma_functoriality p q = W.lemma_witnessed_weakening mem_rel p q let same_refs_in_all_regions m0 m1 = same_refs_common contained_region m0 m1
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m0: FStar.Monotonic.HyperStack.mem -> m1: FStar.Monotonic.HyperStack.mem -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.same_refs_common", "FStar.HyperStack.ST.contained_non_tip_region" ]
[]
false
false
false
true
true
let same_refs_in_non_tip_regions m0 m1 =
same_refs_common contained_non_tip_region m0 m1
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.same_refs_in_non_tip_stack_regions
val same_refs_in_non_tip_stack_regions (m0 m1:mem) :Type0
val same_refs_in_non_tip_stack_regions (m0 m1:mem) :Type0
let same_refs_in_non_tip_stack_regions m0 m1 = same_refs_common contained_non_tip_stack_region m0 m1
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 100, "end_line": 120, "start_col": 0, "start_line": 120 }
(* 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.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2 let witnessed p = W.witnessed mem_rel p (* TODO: we should derive these using DM4F *) let gst_get _ = admit () let gst_put _ = admit () let gst_witness _ = admit () let gst_recall _ = admit () let lemma_functoriality p q = W.lemma_witnessed_weakening mem_rel p q let same_refs_in_all_regions m0 m1 = same_refs_common contained_region m0 m1 let same_refs_in_stack_regions m0 m1 = same_refs_common contained_stack_region m0 m1
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m0: FStar.Monotonic.HyperStack.mem -> m1: FStar.Monotonic.HyperStack.mem -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.same_refs_common", "FStar.HyperStack.ST.contained_non_tip_stack_region" ]
[]
false
false
false
true
true
let same_refs_in_non_tip_stack_regions m0 m1 =
same_refs_common contained_non_tip_stack_region m0 m1
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.lemma_functoriality
val lemma_functoriality (p:mem_predicate{witnessed p}) (q:mem_predicate{(forall (h:mem). p h ==> q h)}) : Lemma (witnessed q)
val lemma_functoriality (p:mem_predicate{witnessed p}) (q:mem_predicate{(forall (h:mem). p h ==> q h)}) : Lemma (witnessed q)
let lemma_functoriality p q = W.lemma_witnessed_weakening mem_rel p q
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 69, "end_line": 115, "start_col": 0, "start_line": 115 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2 let witnessed p = W.witnessed mem_rel p (* TODO: we should derive these using DM4F *) let gst_get _ = admit () let gst_put _ = admit () let gst_witness _ = admit () let gst_recall _ = admit ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: FStar.HyperStack.ST.mem_predicate{FStar.HyperStack.ST.witnessed p} -> q: FStar.HyperStack.ST.mem_predicate{forall (h: FStar.Monotonic.HyperStack.mem). p h ==> q h} -> FStar.Pervasives.Lemma (ensures FStar.HyperStack.ST.witnessed q)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.HyperStack.ST.mem_predicate", "FStar.HyperStack.ST.witnessed", "Prims.l_Forall", "FStar.Monotonic.HyperStack.mem", "Prims.l_imp", "FStar.Monotonic.Witnessed.lemma_witnessed_weakening", "FStar.HyperStack.ST.mem_rel", "Prims.unit" ]
[]
true
false
true
false
false
let lemma_functoriality p q =
W.lemma_witnessed_weakening mem_rel p q
false
Hacl.Impl.Box.fst
Hacl.Impl.Box.box_open_easy
val box_open_easy: mlen:size_t{v mlen + 16 <= max_size_t} -> m:lbuffer uint8 mlen -> pk:lbuffer uint8 32ul -> sk:lbuffer uint8 32ul -> n:lbuffer uint8 24ul -> c:lbuffer uint8 (mlen +! 16ul) -> Stack size_t (requires fun h -> live h c /\ live h m /\ live h pk /\ live h sk /\ live h n /\ disjoint m c /\ disjoint m n /\ disjoint c n) (ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\ (let msg = Spec.box_open_easy (as_seq h0 pk) (as_seq h0 sk) (as_seq h0 n) (as_seq h0 c) in match r with | 0ul -> Some? msg /\ as_seq h1 m == Some?.v msg | _ -> None? msg))
val box_open_easy: mlen:size_t{v mlen + 16 <= max_size_t} -> m:lbuffer uint8 mlen -> pk:lbuffer uint8 32ul -> sk:lbuffer uint8 32ul -> n:lbuffer uint8 24ul -> c:lbuffer uint8 (mlen +! 16ul) -> Stack size_t (requires fun h -> live h c /\ live h m /\ live h pk /\ live h sk /\ live h n /\ disjoint m c /\ disjoint m n /\ disjoint c n) (ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\ (let msg = Spec.box_open_easy (as_seq h0 pk) (as_seq h0 sk) (as_seq h0 n) (as_seq h0 c) in match r with | 0ul -> Some? msg /\ as_seq h1 m == Some?.v msg | _ -> None? msg))
let box_open_easy mlen m pk sk n c = let tag = sub c 0ul 16ul in let cip = sub c 16ul mlen in box_open_detached mlen m pk sk n cip tag
{ "file_name": "code/nacl-box/Hacl.Impl.Box.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 42, "end_line": 251, "start_col": 0, "start_line": 248 }
module Hacl.Impl.Box open FStar.HyperStack.All open FStar.HyperStack open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Impl.SecretBox module ST = FStar.HyperStack.ST module Spec = Spec.Box module LSeq = Lib.Sequence #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" val box_beforenm: k:lbuffer uint8 32ul -> pk:lbuffer uint8 32ul -> sk:lbuffer uint8 32ul -> Stack size_t (requires fun h -> live h k /\ live h pk /\ live h sk /\ disjoint k pk /\ disjoint k sk) (ensures fun h0 r h1 -> modifies (loc k) h0 h1 /\ (let key = Spec.box_beforenm (as_seq h0 pk) (as_seq h0 sk) in match r with | 0ul -> Some? key /\ as_seq h1 k == Some?.v key | _ -> None? key)) [@CInline] let box_beforenm k pk sk = push_frame(); let n0 = create 16ul (u8 0) in let r = Hacl.Curve25519_51.ecdh k sk pk in let res = if r then ( Hacl.Salsa20.hsalsa20 k k n0; 0ul) else 0xfffffffful in pop_frame(); res val box_detached_afternm: mlen:size_t -> c:lbuffer uint8 mlen -> tag:lbuffer uint8 16ul -> k:lbuffer uint8 32ul -> n:lbuffer uint8 24ul -> m:lbuffer uint8 mlen -> Stack size_t (requires fun h -> live h c /\ live h m /\ live h k /\ live h n /\ live h tag /\ disjoint tag c /\ disjoint tag m /\ eq_or_disjoint m c /\ disjoint n m /\ disjoint n c) (ensures fun h0 r h1 -> modifies (loc c |+| loc tag) h0 h1 /\ r == 0ul /\ (as_seq h1 tag, as_seq h1 c) == Spec.box_detached_afternm (as_seq h0 k) (as_seq h0 n) (as_seq h0 m)) [@CInline] let box_detached_afternm mlen c tag k n m = secretbox_detached mlen c tag k n m; 0ul #set-options "--z3rlimit 100" val box_detached: mlen:size_t -> c:lbuffer uint8 mlen -> tag:lbuffer uint8 16ul -> sk:lbuffer uint8 32ul -> pk:lbuffer uint8 32ul -> n:lbuffer uint8 24ul -> m:lbuffer uint8 mlen -> Stack size_t (requires fun h -> live h c /\ live h m /\ live h sk /\ live h pk /\ live h n /\ live h tag /\ disjoint tag c /\ disjoint tag m /\ eq_or_disjoint m c /\ disjoint n m /\ disjoint n c) (ensures fun h0 r h1 -> modifies (loc c |+| loc tag) h0 h1 /\ (let tag_cipher = Spec.box_detached (as_seq h0 sk) (as_seq h0 pk) (as_seq h0 n) (as_seq h0 m) in match r with | 0ul -> Some? tag_cipher /\ (let (tag_s, cipher_s) = Some?.v tag_cipher in (as_seq h1 tag, as_seq h1 c) == (tag_s, cipher_s)) | _ -> None? tag_cipher)) [@CInline] let box_detached mlen c tag sk pk n m = push_frame(); let k = create 32ul (u8 0) in let r = box_beforenm k pk sk in let res = if r =. size 0 then box_detached_afternm mlen c tag k n m else 0xfffffffful in pop_frame (); res val box_open_detached_afternm: mlen:size_t -> m:lbuffer uint8 mlen -> k:lbuffer uint8 32ul -> n:lbuffer uint8 24ul -> c:lbuffer uint8 mlen -> tag:lbuffer uint8 16ul -> Stack size_t (requires fun h -> live h c /\ live h m /\ live h k /\ live h n /\ live h tag /\ disjoint tag c /\ eq_or_disjoint m c /\ disjoint tag m /\ disjoint m n /\ disjoint c n) (ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\ (let msg = Spec.box_open_detached_afternm (as_seq h0 k) (as_seq h0 n) (as_seq h0 tag) (as_seq h0 c) in match r with | 0ul -> Some? msg /\ as_seq h1 m == Some?.v msg | _ -> None? msg)) [@CInline] let box_open_detached_afternm mlen m k n c tag = secretbox_open_detached mlen m k n c tag val box_open_detached: mlen:size_t -> m:lbuffer uint8 mlen -> pk:lbuffer uint8 32ul -> sk:lbuffer uint8 32ul -> n:lbuffer uint8 24ul -> c:lbuffer uint8 mlen -> tag:lbuffer uint8 16ul -> Stack size_t (requires fun h -> live h c /\ live h m /\ live h pk /\ live h sk /\ live h n /\ live h tag /\ disjoint tag c /\ eq_or_disjoint m c /\ disjoint tag m /\ disjoint m n /\ disjoint c n) (ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\ (let msg = Spec.box_open_detached (as_seq h0 pk) (as_seq h0 sk) (as_seq h0 n) (as_seq h0 tag) (as_seq h0 c) in match r with | 0ul -> Some? msg /\ as_seq h1 m == Some?.v msg | _ -> None? msg)) [@CInline] let box_open_detached mlen m pk sk n c tag = push_frame(); let k = create 32ul (u8 0) in let r = box_beforenm k pk sk in let res = if r =. size 0 then box_open_detached_afternm mlen m k n c tag else 0xfffffffful in pop_frame(); res val box_easy_afternm: mlen:size_t{v mlen + 16 <= max_size_t} -> c:lbuffer uint8 (mlen +! 16ul) -> k:lbuffer uint8 32ul -> n:lbuffer uint8 24ul -> m:lbuffer uint8 mlen -> Stack size_t (requires fun h -> live h c /\ live h m /\ live h k /\ live h n /\ disjoint m c /\ disjoint n m /\ disjoint n c) (ensures fun h0 r h1 -> modifies (loc c) h0 h1 /\ as_seq h1 c == Spec.box_easy_afternm (as_seq h0 k) (as_seq h0 n) (as_seq h0 m)) [@CInline] let box_easy_afternm mlen c k n m = let tag = sub c 0ul 16ul in let cip = sub c 16ul mlen in let res = box_detached_afternm mlen cip tag k n m in let h1 = ST.get () in FStar.Seq.Properties.lemma_split (as_seq h1 c) 16; res val box_easy: mlen:size_t{v mlen + 16 <= max_size_t} -> c:lbuffer uint8 (mlen +! 16ul) -> sk:lbuffer uint8 32ul -> pk:lbuffer uint8 32ul -> n:lbuffer uint8 24ul -> m:lbuffer uint8 mlen -> Stack size_t (requires fun h -> live h c /\ live h m /\ live h pk /\ live h sk /\ live h n /\ disjoint m c /\ disjoint n m /\ disjoint n c) (ensures fun h0 r h1 -> modifies (loc c) h0 h1 /\ (let cipher = Spec.box_easy (as_seq h0 sk) (as_seq h0 pk) (as_seq h0 n) (as_seq h0 m) in match r with | 0ul -> Some? cipher /\ as_seq h1 c == Some?.v cipher | _ -> None? cipher)) [@CInline] let box_easy mlen c sk pk n m = let tag = sub c 0ul 16ul in let cip = sub c 16ul mlen in let res = box_detached mlen cip tag sk pk n m in let h1 = ST.get () in FStar.Seq.Properties.lemma_split (as_seq h1 c) 16; res val box_open_easy_afternm: mlen:size_t{v mlen + 16 <= max_size_t} -> m:lbuffer uint8 mlen -> k:lbuffer uint8 32ul -> n:lbuffer uint8 24ul -> c:lbuffer uint8 (mlen +! 16ul) -> Stack size_t (requires fun h -> live h c /\ live h m /\ live h k /\ live h n /\ disjoint m c /\ disjoint m n /\ disjoint c n) (ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\ (let msg = Spec.box_open_easy_afternm (as_seq h0 k) (as_seq h0 n) (as_seq h0 c) in match r with | 0ul -> Some? msg /\ as_seq h1 m == Some?.v msg | _ -> None? msg)) [@CInline] let box_open_easy_afternm mlen m k n c = let tag = sub c 0ul 16ul in let cip = sub c 16ul mlen in box_open_detached_afternm mlen m k n cip tag val box_open_easy: mlen:size_t{v mlen + 16 <= max_size_t} -> m:lbuffer uint8 mlen -> pk:lbuffer uint8 32ul -> sk:lbuffer uint8 32ul -> n:lbuffer uint8 24ul -> c:lbuffer uint8 (mlen +! 16ul) -> Stack size_t (requires fun h -> live h c /\ live h m /\ live h pk /\ live h sk /\ live h n /\ disjoint m c /\ disjoint m n /\ disjoint c n) (ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\ (let msg = Spec.box_open_easy (as_seq h0 pk) (as_seq h0 sk) (as_seq h0 n) (as_seq h0 c) in match r with | 0ul -> Some? msg /\ as_seq h1 m == Some?.v msg | _ -> None? msg))
{ "checked_file": "/", "dependencies": [ "Spec.Box.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Salsa20.fst.checked", "Hacl.Impl.SecretBox.fst.checked", "Hacl.Curve25519_51.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Box.fst" }
[ { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Spec.Box", "short_module": "Spec" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.SecretBox", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
mlen: Lib.IntTypes.size_t{Lib.IntTypes.v mlen + 16 <= Lib.IntTypes.max_size_t} -> m: Lib.Buffer.lbuffer Lib.IntTypes.uint8 mlen -> pk: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> sk: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> n: Lib.Buffer.lbuffer Lib.IntTypes.uint8 24ul -> c: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (mlen +! 16ul) -> FStar.HyperStack.ST.Stack Lib.IntTypes.size_t
FStar.HyperStack.ST.Stack
[]
[]
[ "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.IntTypes.max_size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.op_Plus_Bang", "Hacl.Impl.Box.box_open_detached", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.sub", "FStar.UInt32.uint_to_t", "FStar.UInt32.t" ]
[]
false
true
false
false
false
let box_open_easy mlen m pk sk n c =
let tag = sub c 0ul 16ul in let cip = sub c 16ul mlen in box_open_detached mlen m pk sk n cip tag
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.pop_frame
val pop_frame (_:unit) :Unsafe unit (requires (fun m -> poppable m)) (ensures (fun (m0:mem) _ (m1:mem) -> poppable m0 /\ m1 == pop m0 /\ popped m0 m1))
val pop_frame (_:unit) :Unsafe unit (requires (fun m -> poppable m)) (ensures (fun (m0:mem) _ (m1:mem) -> poppable m0 /\ m1 == pop m0 /\ popped m0 m1))
let pop_frame _ = let m1 = pop (gst_get ()) in gst_put m1
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 12, "end_line": 139, "start_col": 0, "start_line": 137 }
(* 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.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2 let witnessed p = W.witnessed mem_rel p (* TODO: we should derive these using DM4F *) let gst_get _ = admit () let gst_put _ = admit () let gst_witness _ = admit () let gst_recall _ = admit () let lemma_functoriality p q = W.lemma_witnessed_weakening mem_rel p q let same_refs_in_all_regions m0 m1 = same_refs_common contained_region m0 m1 let same_refs_in_stack_regions m0 m1 = same_refs_common contained_stack_region m0 m1 let same_refs_in_non_tip_regions m0 m1 = same_refs_common contained_non_tip_region m0 m1 let same_refs_in_non_tip_stack_regions m0 m1 = same_refs_common contained_non_tip_stack_region m0 m1 let lemma_same_refs_in_all_regions_intro _ _ = () let lemma_same_refs_in_all_regions_elim _ _ _ = () let lemma_same_refs_in_stack_regions_intro _ _ = () let lemma_same_refs_in_stack_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_regions_intro _ _ = () let lemma_same_refs_in_non_tip_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_stack_regions_intro _ _ = () let lemma_same_refs_in_non_tip_stack_regions_elim _ _ _ = () let lemma_equal_domains_trans _ _ _ = () let push_frame _ = let m0 = gst_get () in let m1 = HS.hs_push_frame m0 in gst_put m1
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.HyperStack.ST.Unsafe Prims.unit
FStar.HyperStack.ST.Unsafe
[]
[]
[ "Prims.unit", "FStar.HyperStack.ST.gst_put", "FStar.Monotonic.HyperStack.mem", "FStar.Monotonic.HyperStack.pop", "FStar.Monotonic.HyperStack.poppable", "FStar.HyperStack.ST.gst_get" ]
[]
false
true
false
false
false
let pop_frame _ =
let m1 = pop (gst_get ()) in gst_put m1
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.push_frame
val push_frame (_:unit) :Unsafe unit (requires (fun m -> True)) (ensures (fun (m0:mem) _ (m1:mem) -> fresh_frame m0 m1))
val push_frame (_:unit) :Unsafe unit (requires (fun m -> True)) (ensures (fun (m0:mem) _ (m1:mem) -> fresh_frame m0 m1))
let push_frame _ = let m0 = gst_get () in let m1 = HS.hs_push_frame m0 in gst_put m1
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 12, "end_line": 135, "start_col": 0, "start_line": 132 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2 let witnessed p = W.witnessed mem_rel p (* TODO: we should derive these using DM4F *) let gst_get _ = admit () let gst_put _ = admit () let gst_witness _ = admit () let gst_recall _ = admit () let lemma_functoriality p q = W.lemma_witnessed_weakening mem_rel p q let same_refs_in_all_regions m0 m1 = same_refs_common contained_region m0 m1 let same_refs_in_stack_regions m0 m1 = same_refs_common contained_stack_region m0 m1 let same_refs_in_non_tip_regions m0 m1 = same_refs_common contained_non_tip_region m0 m1 let same_refs_in_non_tip_stack_regions m0 m1 = same_refs_common contained_non_tip_stack_region m0 m1 let lemma_same_refs_in_all_regions_intro _ _ = () let lemma_same_refs_in_all_regions_elim _ _ _ = () let lemma_same_refs_in_stack_regions_intro _ _ = () let lemma_same_refs_in_stack_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_regions_intro _ _ = () let lemma_same_refs_in_non_tip_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_stack_regions_intro _ _ = () let lemma_same_refs_in_non_tip_stack_regions_elim _ _ _ = () let lemma_equal_domains_trans _ _ _ = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.HyperStack.ST.Unsafe Prims.unit
FStar.HyperStack.ST.Unsafe
[]
[]
[ "Prims.unit", "FStar.HyperStack.ST.gst_put", "FStar.Monotonic.HyperStack.mem", "FStar.Monotonic.HyperStack.fresh_frame", "FStar.Monotonic.HyperStack.hs_push_frame", "FStar.HyperStack.ST.gst_get" ]
[]
false
true
false
false
false
let push_frame _ =
let m0 = gst_get () in let m1 = HS.hs_push_frame m0 in gst_put m1
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.sfree
val sfree (#a:Type) (#rel:preorder a) (r:mmmstackref a rel) :StackInline unit (requires (fun m0 -> frameOf r = get_tip m0 /\ m0 `contains` r)) (ensures (fun m0 _ m1 -> m0 `contains` r /\ m1 == HS.free r m0))
val sfree (#a:Type) (#rel:preorder a) (r:mmmstackref a rel) :StackInline unit (requires (fun m0 -> frameOf r = get_tip m0 /\ m0 `contains` r)) (ensures (fun m0 _ m1 -> m0 `contains` r /\ m1 == HS.free r m0))
let sfree #_ #_ r = let m0 = gst_get () in let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.get_tip m0)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 12, "end_line": 165, "start_col": 0, "start_line": 158 }
(* 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.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2 let witnessed p = W.witnessed mem_rel p (* TODO: we should derive these using DM4F *) let gst_get _ = admit () let gst_put _ = admit () let gst_witness _ = admit () let gst_recall _ = admit () let lemma_functoriality p q = W.lemma_witnessed_weakening mem_rel p q let same_refs_in_all_regions m0 m1 = same_refs_common contained_region m0 m1 let same_refs_in_stack_regions m0 m1 = same_refs_common contained_stack_region m0 m1 let same_refs_in_non_tip_regions m0 m1 = same_refs_common contained_non_tip_region m0 m1 let same_refs_in_non_tip_stack_regions m0 m1 = same_refs_common contained_non_tip_stack_region m0 m1 let lemma_same_refs_in_all_regions_intro _ _ = () let lemma_same_refs_in_all_regions_elim _ _ _ = () let lemma_same_refs_in_stack_regions_intro _ _ = () let lemma_same_refs_in_stack_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_regions_intro _ _ = () let lemma_same_refs_in_non_tip_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_stack_regions_intro _ _ = () let lemma_same_refs_in_non_tip_stack_regions_elim _ _ _ = () let lemma_equal_domains_trans _ _ _ = () let push_frame _ = let m0 = gst_get () in let m1 = HS.hs_push_frame m0 in gst_put m1 let pop_frame _ = let m1 = pop (gst_get ()) in gst_put m1 private let salloc_common (#a:Type) (#rel:preorder a) (init:a) (mm:bool) :StackInline (mreference a rel) (requires (fun m -> is_stack_region (get_tip m))) (ensures (fun m0 s m1 -> is_stack_region (HS.frameOf s) /\ salloc_post init m0 s m1 /\ is_mm s == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel (get_tip m0) init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (get_hmap m0) (get_tip m0)) init mm; //AR: to prove that next_addr in tip's heap increases (it is part of mem_rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); //AR: to prove that rid_last_component of r.id is < rid_ctr gst_witness (ref_contains_pred r); gst_witness (region_contains_pred (HS.frameOf r)); r let salloc #_ #_ init = salloc_common init false let salloc_mm #_ #_ init = salloc_common init true
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.HyperStack.ST.mmmstackref a rel -> FStar.HyperStack.ST.StackInline Prims.unit
FStar.HyperStack.ST.StackInline
[]
[]
[ "FStar.Preorder.preorder", "FStar.HyperStack.ST.mmmstackref", "FStar.HyperStack.ST.gst_put", "Prims.unit", "FStar.Monotonic.Heap.lemma_next_addr_free_mm", "FStar.Map.sel", "FStar.Monotonic.HyperHeap.rid", "FStar.Monotonic.Heap.heap", "FStar.Monotonic.HyperStack.get_hmap", "FStar.Monotonic.HyperStack.get_tip", "FStar.Monotonic.HyperStack.as_ref", "FStar.Monotonic.Heap.lemma_distinct_addrs_distinct_mm", "FStar.Monotonic.Heap.lemma_distinct_addrs_distinct_preorders", "Prims._assert", "FStar.Set.equal", "FStar.Map.domain", "FStar.Monotonic.HyperStack.mem", "FStar.Monotonic.HyperStack.free", "FStar.HyperStack.ST.gst_get" ]
[]
false
true
false
false
false
let sfree #_ #_ r =
let m0 = gst_get () in let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.get_tip m0)) (HS.as_ref r); gst_put m1
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.salloc_common
val salloc_common (#a: Type) (#rel: preorder a) (init: a) (mm: bool) : StackInline (mreference a rel) (requires (fun m -> is_stack_region (get_tip m))) (ensures (fun m0 s m1 -> is_stack_region (HS.frameOf s) /\ salloc_post init m0 s m1 /\ is_mm s == mm) )
val salloc_common (#a: Type) (#rel: preorder a) (init: a) (mm: bool) : StackInline (mreference a rel) (requires (fun m -> is_stack_region (get_tip m))) (ensures (fun m0 s m1 -> is_stack_region (HS.frameOf s) /\ salloc_post init m0 s m1 /\ is_mm s == mm) )
let salloc_common (#a:Type) (#rel:preorder a) (init:a) (mm:bool) :StackInline (mreference a rel) (requires (fun m -> is_stack_region (get_tip m))) (ensures (fun m0 s m1 -> is_stack_region (HS.frameOf s) /\ salloc_post init m0 s m1 /\ is_mm s == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel (get_tip m0) init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (get_hmap m0) (get_tip m0)) init mm; //AR: to prove that next_addr in tip's heap increases (it is part of mem_rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); //AR: to prove that rid_last_component of r.id is < rid_ctr gst_witness (ref_contains_pred r); gst_witness (region_contains_pred (HS.frameOf r)); r
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 5, "end_line": 153, "start_col": 8, "start_line": 141 }
(* 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.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2 let witnessed p = W.witnessed mem_rel p (* TODO: we should derive these using DM4F *) let gst_get _ = admit () let gst_put _ = admit () let gst_witness _ = admit () let gst_recall _ = admit () let lemma_functoriality p q = W.lemma_witnessed_weakening mem_rel p q let same_refs_in_all_regions m0 m1 = same_refs_common contained_region m0 m1 let same_refs_in_stack_regions m0 m1 = same_refs_common contained_stack_region m0 m1 let same_refs_in_non_tip_regions m0 m1 = same_refs_common contained_non_tip_region m0 m1 let same_refs_in_non_tip_stack_regions m0 m1 = same_refs_common contained_non_tip_stack_region m0 m1 let lemma_same_refs_in_all_regions_intro _ _ = () let lemma_same_refs_in_all_regions_elim _ _ _ = () let lemma_same_refs_in_stack_regions_intro _ _ = () let lemma_same_refs_in_stack_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_regions_intro _ _ = () let lemma_same_refs_in_non_tip_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_stack_regions_intro _ _ = () let lemma_same_refs_in_non_tip_stack_regions_elim _ _ _ = () let lemma_equal_domains_trans _ _ _ = () let push_frame _ = let m0 = gst_get () in let m1 = HS.hs_push_frame m0 in gst_put m1 let pop_frame _ = let m1 = pop (gst_get ()) in gst_put m1
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
init: a -> mm: Prims.bool -> FStar.HyperStack.ST.StackInline (FStar.HyperStack.ST.mreference a rel)
FStar.HyperStack.ST.StackInline
[]
[]
[ "FStar.Preorder.preorder", "Prims.bool", "FStar.Monotonic.HyperStack.mreference", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.mreference", "Prims.unit", "FStar.HyperStack.ST.gst_witness", "FStar.HyperStack.ST.region_contains_pred", "FStar.Monotonic.HyperStack.frameOf", "FStar.HyperStack.ST.ref_contains_pred", "FStar.Monotonic.HyperStack.lemma_rid_ctr_pred", "Prims._assert", "FStar.Set.equal", "FStar.Monotonic.HyperHeap.rid", "FStar.Map.domain", "FStar.Monotonic.Heap.heap", "FStar.Monotonic.HyperStack.get_hmap", "FStar.HyperStack.ST.gst_put", "FStar.Monotonic.Heap.lemma_next_addr_alloc", "FStar.Map.sel", "FStar.Monotonic.HyperStack.get_tip", "FStar.Pervasives.Native.tuple2", "FStar.Monotonic.Heap.alloc", "FStar.Monotonic.Heap.mref", "Prims.l_and", "Prims.eq2", "FStar.Monotonic.HyperStack.as_ref", "FStar.Pervasives.Native.fst", "FStar.Map.t", "FStar.Pervasives.Native.snd", "FStar.Map.upd", "FStar.Monotonic.HyperStack.alloc", "FStar.HyperStack.ST.gst_get", "Prims.b2t", "FStar.Monotonic.HyperStack.is_stack_region", "FStar.HyperStack.ST.salloc_post", "FStar.Monotonic.HyperStack.is_mm" ]
[]
false
true
false
false
false
let salloc_common (#a: Type) (#rel: preorder a) (init: a) (mm: bool) : StackInline (mreference a rel) (requires (fun m -> is_stack_region (get_tip m))) (ensures (fun m0 s m1 -> is_stack_region (HS.frameOf s) /\ salloc_post init m0 s m1 /\ is_mm s == mm) ) =
let m0 = gst_get () in let r, m1 = HS.alloc rel (get_tip m0) init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (get_hmap m0) (get_tip m0)) init mm; gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); gst_witness (ref_contains_pred r); gst_witness (region_contains_pred (HS.frameOf r)); r
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.salloc
val salloc (#a:Type) (#rel:preorder a) (init:a) :StackInline (mstackref a rel) (requires (fun m -> is_stack_region (get_tip m))) (ensures salloc_post init)
val salloc (#a:Type) (#rel:preorder a) (init:a) :StackInline (mstackref a rel) (requires (fun m -> is_stack_region (get_tip m))) (ensures salloc_post init)
let salloc #_ #_ init = salloc_common init false
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 48, "end_line": 155, "start_col": 0, "start_line": 155 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2 let witnessed p = W.witnessed mem_rel p (* TODO: we should derive these using DM4F *) let gst_get _ = admit () let gst_put _ = admit () let gst_witness _ = admit () let gst_recall _ = admit () let lemma_functoriality p q = W.lemma_witnessed_weakening mem_rel p q let same_refs_in_all_regions m0 m1 = same_refs_common contained_region m0 m1 let same_refs_in_stack_regions m0 m1 = same_refs_common contained_stack_region m0 m1 let same_refs_in_non_tip_regions m0 m1 = same_refs_common contained_non_tip_region m0 m1 let same_refs_in_non_tip_stack_regions m0 m1 = same_refs_common contained_non_tip_stack_region m0 m1 let lemma_same_refs_in_all_regions_intro _ _ = () let lemma_same_refs_in_all_regions_elim _ _ _ = () let lemma_same_refs_in_stack_regions_intro _ _ = () let lemma_same_refs_in_stack_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_regions_intro _ _ = () let lemma_same_refs_in_non_tip_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_stack_regions_intro _ _ = () let lemma_same_refs_in_non_tip_stack_regions_elim _ _ _ = () let lemma_equal_domains_trans _ _ _ = () let push_frame _ = let m0 = gst_get () in let m1 = HS.hs_push_frame m0 in gst_put m1 let pop_frame _ = let m1 = pop (gst_get ()) in gst_put m1 private let salloc_common (#a:Type) (#rel:preorder a) (init:a) (mm:bool) :StackInline (mreference a rel) (requires (fun m -> is_stack_region (get_tip m))) (ensures (fun m0 s m1 -> is_stack_region (HS.frameOf s) /\ salloc_post init m0 s m1 /\ is_mm s == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel (get_tip m0) init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (get_hmap m0) (get_tip m0)) init mm; //AR: to prove that next_addr in tip's heap increases (it is part of mem_rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); //AR: to prove that rid_last_component of r.id is < rid_ctr gst_witness (ref_contains_pred r); gst_witness (region_contains_pred (HS.frameOf r)); r
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
init: a -> FStar.HyperStack.ST.StackInline (FStar.HyperStack.ST.mstackref a rel)
FStar.HyperStack.ST.StackInline
[]
[]
[ "FStar.Preorder.preorder", "FStar.HyperStack.ST.salloc_common", "FStar.HyperStack.ST.mreference", "FStar.HyperStack.ST.mstackref" ]
[]
false
true
false
false
false
let salloc #_ #_ init =
salloc_common init false
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.salloc_mm
val salloc_mm (#a:Type) (#rel:preorder a) (init:a) :StackInline (mmmstackref a rel) (requires (fun m -> is_stack_region (get_tip m))) (ensures salloc_post init)
val salloc_mm (#a:Type) (#rel:preorder a) (init:a) :StackInline (mmmstackref a rel) (requires (fun m -> is_stack_region (get_tip m))) (ensures salloc_post init)
let salloc_mm #_ #_ init = salloc_common init true
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 50, "end_line": 156, "start_col": 0, "start_line": 156 }
(* 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.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2 let witnessed p = W.witnessed mem_rel p (* TODO: we should derive these using DM4F *) let gst_get _ = admit () let gst_put _ = admit () let gst_witness _ = admit () let gst_recall _ = admit () let lemma_functoriality p q = W.lemma_witnessed_weakening mem_rel p q let same_refs_in_all_regions m0 m1 = same_refs_common contained_region m0 m1 let same_refs_in_stack_regions m0 m1 = same_refs_common contained_stack_region m0 m1 let same_refs_in_non_tip_regions m0 m1 = same_refs_common contained_non_tip_region m0 m1 let same_refs_in_non_tip_stack_regions m0 m1 = same_refs_common contained_non_tip_stack_region m0 m1 let lemma_same_refs_in_all_regions_intro _ _ = () let lemma_same_refs_in_all_regions_elim _ _ _ = () let lemma_same_refs_in_stack_regions_intro _ _ = () let lemma_same_refs_in_stack_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_regions_intro _ _ = () let lemma_same_refs_in_non_tip_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_stack_regions_intro _ _ = () let lemma_same_refs_in_non_tip_stack_regions_elim _ _ _ = () let lemma_equal_domains_trans _ _ _ = () let push_frame _ = let m0 = gst_get () in let m1 = HS.hs_push_frame m0 in gst_put m1 let pop_frame _ = let m1 = pop (gst_get ()) in gst_put m1 private let salloc_common (#a:Type) (#rel:preorder a) (init:a) (mm:bool) :StackInline (mreference a rel) (requires (fun m -> is_stack_region (get_tip m))) (ensures (fun m0 s m1 -> is_stack_region (HS.frameOf s) /\ salloc_post init m0 s m1 /\ is_mm s == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel (get_tip m0) init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (get_hmap m0) (get_tip m0)) init mm; //AR: to prove that next_addr in tip's heap increases (it is part of mem_rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); //AR: to prove that rid_last_component of r.id is < rid_ctr gst_witness (ref_contains_pred r); gst_witness (region_contains_pred (HS.frameOf r)); r
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
init: a -> FStar.HyperStack.ST.StackInline (FStar.HyperStack.ST.mmmstackref a rel)
FStar.HyperStack.ST.StackInline
[]
[]
[ "FStar.Preorder.preorder", "FStar.HyperStack.ST.salloc_common", "FStar.HyperStack.ST.mreference", "FStar.HyperStack.ST.mmmstackref" ]
[]
false
true
false
false
false
let salloc_mm #_ #_ init =
salloc_common init true
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.mem_rel_predicate
val mem_rel_predicate (#a: Type0) (#rel: preorder a) (r: mreference a rel) (p: mem_predicate) : mem_predicate
val mem_rel_predicate (#a: Type0) (#rel: preorder a) (r: mreference a rel) (p: mem_predicate) : mem_predicate
let mem_rel_predicate (#a:Type0) (#rel:preorder a) (r:mreference a rel) (p:mem_predicate) :mem_predicate = let rid = HS.frameOf r in fun m -> (HS.rid_last_component rid < HS.get_rid_ctr m) /\ ( //will help us prove that a deallocated region remains deallocated (m `HS.contains` r /\ p m) \/ //the ref is contained and satisfies p (m `contains_region` rid /\ ~ (m `HS.contains_ref_in_its_region` r) /\ HS.as_addr r < Heap.next_addr (HS.get_hmap m `Map.sel` rid) /\ r `HS.unused_in` m) \/ //the ref is deallocated, but its region is contained and next_addr > addr_of ref (not (m `contains_region` rid)))
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 38, "end_line": 285, "start_col": 8, "start_line": 278 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2 let witnessed p = W.witnessed mem_rel p (* TODO: we should derive these using DM4F *) let gst_get _ = admit () let gst_put _ = admit () let gst_witness _ = admit () let gst_recall _ = admit () let lemma_functoriality p q = W.lemma_witnessed_weakening mem_rel p q let same_refs_in_all_regions m0 m1 = same_refs_common contained_region m0 m1 let same_refs_in_stack_regions m0 m1 = same_refs_common contained_stack_region m0 m1 let same_refs_in_non_tip_regions m0 m1 = same_refs_common contained_non_tip_region m0 m1 let same_refs_in_non_tip_stack_regions m0 m1 = same_refs_common contained_non_tip_stack_region m0 m1 let lemma_same_refs_in_all_regions_intro _ _ = () let lemma_same_refs_in_all_regions_elim _ _ _ = () let lemma_same_refs_in_stack_regions_intro _ _ = () let lemma_same_refs_in_stack_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_regions_intro _ _ = () let lemma_same_refs_in_non_tip_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_stack_regions_intro _ _ = () let lemma_same_refs_in_non_tip_stack_regions_elim _ _ _ = () let lemma_equal_domains_trans _ _ _ = () let push_frame _ = let m0 = gst_get () in let m1 = HS.hs_push_frame m0 in gst_put m1 let pop_frame _ = let m1 = pop (gst_get ()) in gst_put m1 private let salloc_common (#a:Type) (#rel:preorder a) (init:a) (mm:bool) :StackInline (mreference a rel) (requires (fun m -> is_stack_region (get_tip m))) (ensures (fun m0 s m1 -> is_stack_region (HS.frameOf s) /\ salloc_post init m0 s m1 /\ is_mm s == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel (get_tip m0) init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (get_hmap m0) (get_tip m0)) init mm; //AR: to prove that next_addr in tip's heap increases (it is part of mem_rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); //AR: to prove that rid_last_component of r.id is < rid_ctr gst_witness (ref_contains_pred r); gst_witness (region_contains_pred (HS.frameOf r)); r let salloc #_ #_ init = salloc_common init false let salloc_mm #_ #_ init = salloc_common init true let sfree #_ #_ r = let m0 = gst_get () in let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.get_tip m0)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1 let new_region r0 = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 None in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid let new_colored_region r0 c = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 (Some c) in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid private let ralloc_common (#a:Type) (#rel:preorder a) (i:rid) (init:a) (mm:bool) :ST (mreference a rel) (requires (fun m -> is_heap_color (color i) /\ m `contains_region` i)) (ensures (fun m0 r m1 -> ralloc_post i init m0 r m1 /\ is_mm r == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel i init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (HS.get_hmap m0) i) init mm; //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); gst_witness (ref_contains_pred r); gst_witness (region_contains_pred i); r let ralloc #_ #_ i init = if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init false let ralloc_mm #_ #_ i init = if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init true let rfree #_ #_ r = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); HS.lemma_rid_ctr_pred (); let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.frameOf r)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1 let op_Colon_Equals #_ #_ r v = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); let m1 = HS.upd_tot m0 r v in Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_upd_equals_upd_tot_for_contained_refs (get_hmap m0 `Map.sel` (HS.frameOf r)) (HS.as_ref r) v; Heap.lemma_next_addr_upd (Map.sel (HS.get_hmap m0) (HS.frameOf r)) (HS.as_ref r) v; //next_addr in ref's rid heap remains same gst_put m1 let op_Bang #_ #_ r = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); Heap.lemma_sel_equals_sel_tot_for_contained_refs (get_hmap m0 `Map.sel` (HS.frameOf r)) (HS.as_ref r); HS.sel_tot m0 r let get _ = gst_get () let recall #_ #_ r = gst_recall (ref_contains_pred r); gst_recall (region_contains_pred (HS.frameOf r)) let recall_region i = if i <> HS.root then gst_recall (region_contains_pred i) let witness_region i = gst_witness (region_contains_pred i) let witness_hsref #_ #_ r = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); gst_witness (ref_contains_pred r) let mr_witness #r #_ #_ m p = recall m; let p_pred (#i:erid) (#a:Type) (#b:preorder a) (r:m_rref i a b) (p:mem_predicate) :mem_predicate = fun m -> m `contains` r /\ p m in gst_witness (p_pred m p); lemma_functoriality (p_pred m p) p let weaken_witness p q = let aux () :Lemma (requires ((forall h. p h ==> q h) /\ witnessed p)) (ensures (witnessed q)) = lemma_functoriality p q in FStar.Classical.move_requires aux () let testify (p:mem_predicate) = gst_recall p let testify_forall #c #p $s = W.lemma_witnessed_forall mem_rel p; gst_recall (fun h -> forall (x:c). p x h) let testify_forall_region_contains_pred #c #p $s = let p' (x:c) :mem_predicate = region_contains_pred (p x) in let s:squash (forall (x:c). witnessed (p' x)) = () in testify_forall s
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.HyperStack.ST.mreference a rel -> p: FStar.HyperStack.ST.mem_predicate -> FStar.HyperStack.ST.mem_predicate
Prims.Tot
[ "total" ]
[]
[ "FStar.Preorder.preorder", "FStar.HyperStack.ST.mreference", "FStar.HyperStack.ST.mem_predicate", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.Monotonic.HyperHeap.rid_last_component", "FStar.Monotonic.HyperStack.get_rid_ctr", "Prims.l_or", "FStar.Monotonic.HyperStack.contains", "FStar.HyperStack.ST.contains_region", "Prims.l_not", "FStar.Monotonic.HyperStack.contains_ref_in_its_region", "FStar.Monotonic.HyperStack.as_addr", "FStar.Monotonic.Heap.next_addr", "FStar.Map.sel", "FStar.Monotonic.HyperHeap.rid", "FStar.Monotonic.Heap.heap", "FStar.Monotonic.HyperStack.get_hmap", "FStar.Monotonic.HyperStack.unused_in", "Prims.op_Negation", "FStar.Monotonic.HyperStack.frameOf" ]
[]
false
false
false
false
false
let mem_rel_predicate (#a: Type0) (#rel: preorder a) (r: mreference a rel) (p: mem_predicate) : mem_predicate =
let rid = HS.frameOf r in fun m -> (HS.rid_last_component rid < HS.get_rid_ctr m) /\ ((m `HS.contains` r /\ p m) \/ (m `contains_region` rid /\ ~(m `HS.contains_ref_in_its_region` r) /\ HS.as_addr r < Heap.next_addr ((HS.get_hmap m) `Map.sel` rid) /\ r `HS.unused_in` m) \/ (not (m `contains_region` rid)))
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.token_p
val token_p (#a:Type0) (#rel:preorder a) (r:mreference a rel) (p:mem_predicate) :Type0
val token_p (#a:Type0) (#rel:preorder a) (r:mreference a rel) (p:mem_predicate) :Type0
let token_p #_ #_ r p = witnessed (mem_rel_predicate r p)
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 57, "end_line": 287, "start_col": 0, "start_line": 287 }
(* 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.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2 let witnessed p = W.witnessed mem_rel p (* TODO: we should derive these using DM4F *) let gst_get _ = admit () let gst_put _ = admit () let gst_witness _ = admit () let gst_recall _ = admit () let lemma_functoriality p q = W.lemma_witnessed_weakening mem_rel p q let same_refs_in_all_regions m0 m1 = same_refs_common contained_region m0 m1 let same_refs_in_stack_regions m0 m1 = same_refs_common contained_stack_region m0 m1 let same_refs_in_non_tip_regions m0 m1 = same_refs_common contained_non_tip_region m0 m1 let same_refs_in_non_tip_stack_regions m0 m1 = same_refs_common contained_non_tip_stack_region m0 m1 let lemma_same_refs_in_all_regions_intro _ _ = () let lemma_same_refs_in_all_regions_elim _ _ _ = () let lemma_same_refs_in_stack_regions_intro _ _ = () let lemma_same_refs_in_stack_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_regions_intro _ _ = () let lemma_same_refs_in_non_tip_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_stack_regions_intro _ _ = () let lemma_same_refs_in_non_tip_stack_regions_elim _ _ _ = () let lemma_equal_domains_trans _ _ _ = () let push_frame _ = let m0 = gst_get () in let m1 = HS.hs_push_frame m0 in gst_put m1 let pop_frame _ = let m1 = pop (gst_get ()) in gst_put m1 private let salloc_common (#a:Type) (#rel:preorder a) (init:a) (mm:bool) :StackInline (mreference a rel) (requires (fun m -> is_stack_region (get_tip m))) (ensures (fun m0 s m1 -> is_stack_region (HS.frameOf s) /\ salloc_post init m0 s m1 /\ is_mm s == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel (get_tip m0) init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (get_hmap m0) (get_tip m0)) init mm; //AR: to prove that next_addr in tip's heap increases (it is part of mem_rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); //AR: to prove that rid_last_component of r.id is < rid_ctr gst_witness (ref_contains_pred r); gst_witness (region_contains_pred (HS.frameOf r)); r let salloc #_ #_ init = salloc_common init false let salloc_mm #_ #_ init = salloc_common init true let sfree #_ #_ r = let m0 = gst_get () in let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.get_tip m0)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1 let new_region r0 = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 None in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid let new_colored_region r0 c = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 (Some c) in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid private let ralloc_common (#a:Type) (#rel:preorder a) (i:rid) (init:a) (mm:bool) :ST (mreference a rel) (requires (fun m -> is_heap_color (color i) /\ m `contains_region` i)) (ensures (fun m0 r m1 -> ralloc_post i init m0 r m1 /\ is_mm r == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel i init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (HS.get_hmap m0) i) init mm; //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); gst_witness (ref_contains_pred r); gst_witness (region_contains_pred i); r let ralloc #_ #_ i init = if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init false let ralloc_mm #_ #_ i init = if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init true let rfree #_ #_ r = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); HS.lemma_rid_ctr_pred (); let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.frameOf r)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1 let op_Colon_Equals #_ #_ r v = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); let m1 = HS.upd_tot m0 r v in Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_upd_equals_upd_tot_for_contained_refs (get_hmap m0 `Map.sel` (HS.frameOf r)) (HS.as_ref r) v; Heap.lemma_next_addr_upd (Map.sel (HS.get_hmap m0) (HS.frameOf r)) (HS.as_ref r) v; //next_addr in ref's rid heap remains same gst_put m1 let op_Bang #_ #_ r = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); Heap.lemma_sel_equals_sel_tot_for_contained_refs (get_hmap m0 `Map.sel` (HS.frameOf r)) (HS.as_ref r); HS.sel_tot m0 r let get _ = gst_get () let recall #_ #_ r = gst_recall (ref_contains_pred r); gst_recall (region_contains_pred (HS.frameOf r)) let recall_region i = if i <> HS.root then gst_recall (region_contains_pred i) let witness_region i = gst_witness (region_contains_pred i) let witness_hsref #_ #_ r = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); gst_witness (ref_contains_pred r) let mr_witness #r #_ #_ m p = recall m; let p_pred (#i:erid) (#a:Type) (#b:preorder a) (r:m_rref i a b) (p:mem_predicate) :mem_predicate = fun m -> m `contains` r /\ p m in gst_witness (p_pred m p); lemma_functoriality (p_pred m p) p let weaken_witness p q = let aux () :Lemma (requires ((forall h. p h ==> q h) /\ witnessed p)) (ensures (witnessed q)) = lemma_functoriality p q in FStar.Classical.move_requires aux () let testify (p:mem_predicate) = gst_recall p let testify_forall #c #p $s = W.lemma_witnessed_forall mem_rel p; gst_recall (fun h -> forall (x:c). p x h) let testify_forall_region_contains_pred #c #p $s = let p' (x:c) :mem_predicate = region_contains_pred (p x) in let s:squash (forall (x:c). witnessed (p' x)) = () in testify_forall s private let mem_rel_predicate (#a:Type0) (#rel:preorder a) (r:mreference a rel) (p:mem_predicate) :mem_predicate = let rid = HS.frameOf r in fun m -> (HS.rid_last_component rid < HS.get_rid_ctr m) /\ ( //will help us prove that a deallocated region remains deallocated (m `HS.contains` r /\ p m) \/ //the ref is contained and satisfies p (m `contains_region` rid /\ ~ (m `HS.contains_ref_in_its_region` r) /\ HS.as_addr r < Heap.next_addr (HS.get_hmap m `Map.sel` rid) /\ r `HS.unused_in` m) \/ //the ref is deallocated, but its region is contained and next_addr > addr_of ref (not (m `contains_region` rid))) //the region itself is not there
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.HyperStack.ST.mreference a rel -> p: FStar.HyperStack.ST.mem_predicate -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Preorder.preorder", "FStar.HyperStack.ST.mreference", "FStar.HyperStack.ST.mem_predicate", "FStar.HyperStack.ST.witnessed", "FStar.HyperStack.ST.mem_rel_predicate" ]
[]
false
false
false
false
true
let token_p #_ #_ r p =
witnessed (mem_rel_predicate r p)
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.ralloc_common
val ralloc_common (#a: Type) (#rel: preorder a) (i: rid) (init: a) (mm: bool) : ST (mreference a rel) (requires (fun m -> is_heap_color (color i) /\ m `contains_region` i)) (ensures (fun m0 r m1 -> ralloc_post i init m0 r m1 /\ is_mm r == mm))
val ralloc_common (#a: Type) (#rel: preorder a) (i: rid) (init: a) (mm: bool) : ST (mreference a rel) (requires (fun m -> is_heap_color (color i) /\ m `contains_region` i)) (ensures (fun m0 r m1 -> ralloc_post i init m0 r m1 /\ is_mm r == mm))
let ralloc_common (#a:Type) (#rel:preorder a) (i:rid) (init:a) (mm:bool) :ST (mreference a rel) (requires (fun m -> is_heap_color (color i) /\ m `contains_region` i)) (ensures (fun m0 r m1 -> ralloc_post i init m0 r m1 /\ is_mm r == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel i init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (HS.get_hmap m0) i) init mm; //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); gst_witness (ref_contains_pred r); gst_witness (region_contains_pred i); r
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 5, "end_line": 197, "start_col": 8, "start_line": 185 }
(* 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.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2 let witnessed p = W.witnessed mem_rel p (* TODO: we should derive these using DM4F *) let gst_get _ = admit () let gst_put _ = admit () let gst_witness _ = admit () let gst_recall _ = admit () let lemma_functoriality p q = W.lemma_witnessed_weakening mem_rel p q let same_refs_in_all_regions m0 m1 = same_refs_common contained_region m0 m1 let same_refs_in_stack_regions m0 m1 = same_refs_common contained_stack_region m0 m1 let same_refs_in_non_tip_regions m0 m1 = same_refs_common contained_non_tip_region m0 m1 let same_refs_in_non_tip_stack_regions m0 m1 = same_refs_common contained_non_tip_stack_region m0 m1 let lemma_same_refs_in_all_regions_intro _ _ = () let lemma_same_refs_in_all_regions_elim _ _ _ = () let lemma_same_refs_in_stack_regions_intro _ _ = () let lemma_same_refs_in_stack_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_regions_intro _ _ = () let lemma_same_refs_in_non_tip_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_stack_regions_intro _ _ = () let lemma_same_refs_in_non_tip_stack_regions_elim _ _ _ = () let lemma_equal_domains_trans _ _ _ = () let push_frame _ = let m0 = gst_get () in let m1 = HS.hs_push_frame m0 in gst_put m1 let pop_frame _ = let m1 = pop (gst_get ()) in gst_put m1 private let salloc_common (#a:Type) (#rel:preorder a) (init:a) (mm:bool) :StackInline (mreference a rel) (requires (fun m -> is_stack_region (get_tip m))) (ensures (fun m0 s m1 -> is_stack_region (HS.frameOf s) /\ salloc_post init m0 s m1 /\ is_mm s == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel (get_tip m0) init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (get_hmap m0) (get_tip m0)) init mm; //AR: to prove that next_addr in tip's heap increases (it is part of mem_rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); //AR: to prove that rid_last_component of r.id is < rid_ctr gst_witness (ref_contains_pred r); gst_witness (region_contains_pred (HS.frameOf r)); r let salloc #_ #_ init = salloc_common init false let salloc_mm #_ #_ init = salloc_common init true let sfree #_ #_ r = let m0 = gst_get () in let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.get_tip m0)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1 let new_region r0 = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 None in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid let new_colored_region r0 c = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 (Some c) in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i: FStar.Monotonic.HyperHeap.rid -> init: a -> mm: Prims.bool -> FStar.HyperStack.ST.ST (FStar.HyperStack.ST.mreference a rel)
FStar.HyperStack.ST.ST
[]
[]
[ "FStar.Preorder.preorder", "FStar.Monotonic.HyperHeap.rid", "Prims.bool", "FStar.Monotonic.HyperStack.mreference", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.mreference", "Prims.unit", "FStar.HyperStack.ST.gst_witness", "FStar.HyperStack.ST.region_contains_pred", "FStar.HyperStack.ST.ref_contains_pred", "FStar.Monotonic.HyperStack.lemma_rid_ctr_pred", "Prims._assert", "FStar.Set.equal", "FStar.Map.domain", "FStar.Monotonic.Heap.heap", "FStar.Monotonic.HyperStack.get_hmap", "FStar.HyperStack.ST.gst_put", "FStar.Monotonic.Heap.lemma_next_addr_alloc", "FStar.Map.sel", "FStar.Pervasives.Native.tuple2", "FStar.Monotonic.Heap.alloc", "FStar.Monotonic.Heap.mref", "Prims.l_and", "Prims.eq2", "FStar.Monotonic.HyperStack.as_ref", "FStar.Pervasives.Native.fst", "FStar.Map.t", "FStar.Pervasives.Native.snd", "FStar.Map.upd", "FStar.Monotonic.HyperStack.alloc", "FStar.HyperStack.ST.gst_get", "Prims.b2t", "FStar.Monotonic.HyperStack.is_heap_color", "FStar.Monotonic.HyperHeap.color", "FStar.HyperStack.ST.contains_region", "FStar.HyperStack.ST.ralloc_post", "FStar.Monotonic.HyperStack.is_mm" ]
[]
false
true
false
false
false
let ralloc_common (#a: Type) (#rel: preorder a) (i: rid) (init: a) (mm: bool) : ST (mreference a rel) (requires (fun m -> is_heap_color (color i) /\ m `contains_region` i)) (ensures (fun m0 r m1 -> ralloc_post i init m0 r m1 /\ is_mm r == mm)) =
let m0 = gst_get () in let r, m1 = HS.alloc rel i init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (HS.get_hmap m0) i) init mm; gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); gst_witness (ref_contains_pred r); gst_witness (region_contains_pred i); r
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.ralloc
val ralloc (#a:Type) (#rel:preorder a) (i:rid) (init:a) :ST (mref a rel) (requires (fun m -> is_eternal_region i)) (ensures (ralloc_post i init))
val ralloc (#a:Type) (#rel:preorder a) (i:rid) (init:a) :ST (mref a rel) (requires (fun m -> is_eternal_region i)) (ensures (ralloc_post i init))
let ralloc #_ #_ i init = if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init false
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 28, "end_line": 201, "start_col": 0, "start_line": 199 }
(* 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.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2 let witnessed p = W.witnessed mem_rel p (* TODO: we should derive these using DM4F *) let gst_get _ = admit () let gst_put _ = admit () let gst_witness _ = admit () let gst_recall _ = admit () let lemma_functoriality p q = W.lemma_witnessed_weakening mem_rel p q let same_refs_in_all_regions m0 m1 = same_refs_common contained_region m0 m1 let same_refs_in_stack_regions m0 m1 = same_refs_common contained_stack_region m0 m1 let same_refs_in_non_tip_regions m0 m1 = same_refs_common contained_non_tip_region m0 m1 let same_refs_in_non_tip_stack_regions m0 m1 = same_refs_common contained_non_tip_stack_region m0 m1 let lemma_same_refs_in_all_regions_intro _ _ = () let lemma_same_refs_in_all_regions_elim _ _ _ = () let lemma_same_refs_in_stack_regions_intro _ _ = () let lemma_same_refs_in_stack_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_regions_intro _ _ = () let lemma_same_refs_in_non_tip_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_stack_regions_intro _ _ = () let lemma_same_refs_in_non_tip_stack_regions_elim _ _ _ = () let lemma_equal_domains_trans _ _ _ = () let push_frame _ = let m0 = gst_get () in let m1 = HS.hs_push_frame m0 in gst_put m1 let pop_frame _ = let m1 = pop (gst_get ()) in gst_put m1 private let salloc_common (#a:Type) (#rel:preorder a) (init:a) (mm:bool) :StackInline (mreference a rel) (requires (fun m -> is_stack_region (get_tip m))) (ensures (fun m0 s m1 -> is_stack_region (HS.frameOf s) /\ salloc_post init m0 s m1 /\ is_mm s == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel (get_tip m0) init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (get_hmap m0) (get_tip m0)) init mm; //AR: to prove that next_addr in tip's heap increases (it is part of mem_rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); //AR: to prove that rid_last_component of r.id is < rid_ctr gst_witness (ref_contains_pred r); gst_witness (region_contains_pred (HS.frameOf r)); r let salloc #_ #_ init = salloc_common init false let salloc_mm #_ #_ init = salloc_common init true let sfree #_ #_ r = let m0 = gst_get () in let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.get_tip m0)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1 let new_region r0 = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 None in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid let new_colored_region r0 c = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 (Some c) in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid private let ralloc_common (#a:Type) (#rel:preorder a) (i:rid) (init:a) (mm:bool) :ST (mreference a rel) (requires (fun m -> is_heap_color (color i) /\ m `contains_region` i)) (ensures (fun m0 r m1 -> ralloc_post i init m0 r m1 /\ is_mm r == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel i init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (HS.get_hmap m0) i) init mm; //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); gst_witness (ref_contains_pred r); gst_witness (region_contains_pred i); r
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i: FStar.Monotonic.HyperHeap.rid -> init: a -> FStar.HyperStack.ST.ST (FStar.HyperStack.ST.mref a rel)
FStar.HyperStack.ST.ST
[]
[]
[ "FStar.Preorder.preorder", "FStar.Monotonic.HyperHeap.rid", "FStar.HyperStack.ST.ralloc_common", "FStar.HyperStack.ST.mreference", "Prims.unit", "Prims.op_disEquality", "FStar.Monotonic.HyperHeap.root", "FStar.HyperStack.ST.gst_recall", "FStar.HyperStack.ST.region_contains_pred", "Prims.bool", "FStar.HyperStack.ST.mref" ]
[]
false
true
false
false
false
let ralloc #_ #_ i init =
if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init false
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.recall_region
val recall_region (i:rid{is_eternal_region i}) :Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ i `is_in` get_hmap m1))
val recall_region (i:rid{is_eternal_region i}) :Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ i `is_in` get_hmap m1))
let recall_region i = if i <> HS.root then gst_recall (region_contains_pred i)
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 78, "end_line": 243, "start_col": 0, "start_line": 243 }
(* 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.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2 let witnessed p = W.witnessed mem_rel p (* TODO: we should derive these using DM4F *) let gst_get _ = admit () let gst_put _ = admit () let gst_witness _ = admit () let gst_recall _ = admit () let lemma_functoriality p q = W.lemma_witnessed_weakening mem_rel p q let same_refs_in_all_regions m0 m1 = same_refs_common contained_region m0 m1 let same_refs_in_stack_regions m0 m1 = same_refs_common contained_stack_region m0 m1 let same_refs_in_non_tip_regions m0 m1 = same_refs_common contained_non_tip_region m0 m1 let same_refs_in_non_tip_stack_regions m0 m1 = same_refs_common contained_non_tip_stack_region m0 m1 let lemma_same_refs_in_all_regions_intro _ _ = () let lemma_same_refs_in_all_regions_elim _ _ _ = () let lemma_same_refs_in_stack_regions_intro _ _ = () let lemma_same_refs_in_stack_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_regions_intro _ _ = () let lemma_same_refs_in_non_tip_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_stack_regions_intro _ _ = () let lemma_same_refs_in_non_tip_stack_regions_elim _ _ _ = () let lemma_equal_domains_trans _ _ _ = () let push_frame _ = let m0 = gst_get () in let m1 = HS.hs_push_frame m0 in gst_put m1 let pop_frame _ = let m1 = pop (gst_get ()) in gst_put m1 private let salloc_common (#a:Type) (#rel:preorder a) (init:a) (mm:bool) :StackInline (mreference a rel) (requires (fun m -> is_stack_region (get_tip m))) (ensures (fun m0 s m1 -> is_stack_region (HS.frameOf s) /\ salloc_post init m0 s m1 /\ is_mm s == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel (get_tip m0) init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (get_hmap m0) (get_tip m0)) init mm; //AR: to prove that next_addr in tip's heap increases (it is part of mem_rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); //AR: to prove that rid_last_component of r.id is < rid_ctr gst_witness (ref_contains_pred r); gst_witness (region_contains_pred (HS.frameOf r)); r let salloc #_ #_ init = salloc_common init false let salloc_mm #_ #_ init = salloc_common init true let sfree #_ #_ r = let m0 = gst_get () in let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.get_tip m0)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1 let new_region r0 = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 None in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid let new_colored_region r0 c = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 (Some c) in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid private let ralloc_common (#a:Type) (#rel:preorder a) (i:rid) (init:a) (mm:bool) :ST (mreference a rel) (requires (fun m -> is_heap_color (color i) /\ m `contains_region` i)) (ensures (fun m0 r m1 -> ralloc_post i init m0 r m1 /\ is_mm r == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel i init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (HS.get_hmap m0) i) init mm; //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); gst_witness (ref_contains_pred r); gst_witness (region_contains_pred i); r let ralloc #_ #_ i init = if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init false let ralloc_mm #_ #_ i init = if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init true let rfree #_ #_ r = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); HS.lemma_rid_ctr_pred (); let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.frameOf r)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1 let op_Colon_Equals #_ #_ r v = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); let m1 = HS.upd_tot m0 r v in Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_upd_equals_upd_tot_for_contained_refs (get_hmap m0 `Map.sel` (HS.frameOf r)) (HS.as_ref r) v; Heap.lemma_next_addr_upd (Map.sel (HS.get_hmap m0) (HS.frameOf r)) (HS.as_ref r) v; //next_addr in ref's rid heap remains same gst_put m1 let op_Bang #_ #_ r = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); Heap.lemma_sel_equals_sel_tot_for_contained_refs (get_hmap m0 `Map.sel` (HS.frameOf r)) (HS.as_ref r); HS.sel_tot m0 r let get _ = gst_get () let recall #_ #_ r = gst_recall (ref_contains_pred r); gst_recall (region_contains_pred (HS.frameOf r))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i: FStar.Monotonic.HyperHeap.rid{FStar.HyperStack.ST.is_eternal_region i} -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "FStar.Monotonic.HyperHeap.rid", "FStar.HyperStack.ST.is_eternal_region", "Prims.op_disEquality", "Prims.l_or", "Prims.l_and", "Prims.eq2", "Prims.int", "FStar.Monotonic.HyperHeap.color", "Prims.b2t", "Prims.op_Negation", "FStar.Monotonic.HyperHeap.rid_freeable", "FStar.Monotonic.HyperHeap.root", "FStar.HyperStack.ST.gst_recall", "FStar.HyperStack.ST.region_contains_pred", "Prims.unit", "Prims.bool" ]
[]
false
true
false
false
false
let recall_region i =
if i <> HS.root then gst_recall (region_contains_pred i)
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.op_Bang
val op_Bang (#a:Type) (#rel:preorder a) (r:mreference a rel) :Stack a (requires (fun m -> r `is_live_for_rw_in` m)) (ensures (deref_post r))
val op_Bang (#a:Type) (#rel:preorder a) (r:mreference a rel) :Stack a (requires (fun m -> r `is_live_for_rw_in` m)) (ensures (deref_post r))
let op_Bang #_ #_ r = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); Heap.lemma_sel_equals_sel_tot_for_contained_refs (get_hmap m0 `Map.sel` (HS.frameOf r)) (HS.as_ref r); HS.sel_tot m0 r
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 17, "end_line": 235, "start_col": 0, "start_line": 230 }
(* 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.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2 let witnessed p = W.witnessed mem_rel p (* TODO: we should derive these using DM4F *) let gst_get _ = admit () let gst_put _ = admit () let gst_witness _ = admit () let gst_recall _ = admit () let lemma_functoriality p q = W.lemma_witnessed_weakening mem_rel p q let same_refs_in_all_regions m0 m1 = same_refs_common contained_region m0 m1 let same_refs_in_stack_regions m0 m1 = same_refs_common contained_stack_region m0 m1 let same_refs_in_non_tip_regions m0 m1 = same_refs_common contained_non_tip_region m0 m1 let same_refs_in_non_tip_stack_regions m0 m1 = same_refs_common contained_non_tip_stack_region m0 m1 let lemma_same_refs_in_all_regions_intro _ _ = () let lemma_same_refs_in_all_regions_elim _ _ _ = () let lemma_same_refs_in_stack_regions_intro _ _ = () let lemma_same_refs_in_stack_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_regions_intro _ _ = () let lemma_same_refs_in_non_tip_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_stack_regions_intro _ _ = () let lemma_same_refs_in_non_tip_stack_regions_elim _ _ _ = () let lemma_equal_domains_trans _ _ _ = () let push_frame _ = let m0 = gst_get () in let m1 = HS.hs_push_frame m0 in gst_put m1 let pop_frame _ = let m1 = pop (gst_get ()) in gst_put m1 private let salloc_common (#a:Type) (#rel:preorder a) (init:a) (mm:bool) :StackInline (mreference a rel) (requires (fun m -> is_stack_region (get_tip m))) (ensures (fun m0 s m1 -> is_stack_region (HS.frameOf s) /\ salloc_post init m0 s m1 /\ is_mm s == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel (get_tip m0) init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (get_hmap m0) (get_tip m0)) init mm; //AR: to prove that next_addr in tip's heap increases (it is part of mem_rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); //AR: to prove that rid_last_component of r.id is < rid_ctr gst_witness (ref_contains_pred r); gst_witness (region_contains_pred (HS.frameOf r)); r let salloc #_ #_ init = salloc_common init false let salloc_mm #_ #_ init = salloc_common init true let sfree #_ #_ r = let m0 = gst_get () in let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.get_tip m0)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1 let new_region r0 = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 None in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid let new_colored_region r0 c = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 (Some c) in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid private let ralloc_common (#a:Type) (#rel:preorder a) (i:rid) (init:a) (mm:bool) :ST (mreference a rel) (requires (fun m -> is_heap_color (color i) /\ m `contains_region` i)) (ensures (fun m0 r m1 -> ralloc_post i init m0 r m1 /\ is_mm r == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel i init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (HS.get_hmap m0) i) init mm; //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); gst_witness (ref_contains_pred r); gst_witness (region_contains_pred i); r let ralloc #_ #_ i init = if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init false let ralloc_mm #_ #_ i init = if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init true let rfree #_ #_ r = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); HS.lemma_rid_ctr_pred (); let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.frameOf r)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1 let op_Colon_Equals #_ #_ r v = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); let m1 = HS.upd_tot m0 r v in Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_upd_equals_upd_tot_for_contained_refs (get_hmap m0 `Map.sel` (HS.frameOf r)) (HS.as_ref r) v; Heap.lemma_next_addr_upd (Map.sel (HS.get_hmap m0) (HS.frameOf r)) (HS.as_ref r) v; //next_addr in ref's rid heap remains same gst_put m1
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.HyperStack.ST.mreference a rel -> FStar.HyperStack.ST.Stack a
FStar.HyperStack.ST.Stack
[]
[]
[ "FStar.Preorder.preorder", "FStar.HyperStack.ST.mreference", "FStar.Monotonic.HyperStack.sel_tot", "Prims.unit", "FStar.Monotonic.Heap.lemma_sel_equals_sel_tot_for_contained_refs", "FStar.Map.sel", "FStar.Monotonic.HyperHeap.rid", "FStar.Monotonic.Heap.heap", "FStar.Monotonic.HyperStack.get_hmap", "FStar.Monotonic.HyperStack.frameOf", "FStar.Monotonic.HyperStack.as_ref", "FStar.HyperStack.ST.gst_recall", "FStar.HyperStack.ST.ref_contains_pred", "FStar.HyperStack.ST.region_contains_pred", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.gst_get" ]
[]
false
true
false
false
false
let ( ! ) #_ #_ r =
let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); Heap.lemma_sel_equals_sel_tot_for_contained_refs ((get_hmap m0) `Map.sel` (HS.frameOf r)) (HS.as_ref r); HS.sel_tot m0 r
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.mr_witness
val mr_witness (#r:erid) (#a:Type) (#b:preorder a) (m:m_rref r a b) (p:mem_predicate) :ST unit (requires (fun h0 -> p h0 /\ stable_on_t m p)) (ensures (fun h0 _ h1 -> h0==h1 /\ witnessed p))
val mr_witness (#r:erid) (#a:Type) (#b:preorder a) (m:m_rref r a b) (p:mem_predicate) :ST unit (requires (fun h0 -> p h0 /\ stable_on_t m p)) (ensures (fun h0 _ h1 -> h0==h1 /\ witnessed p))
let mr_witness #r #_ #_ m p = recall m; let p_pred (#i:erid) (#a:Type) (#b:preorder a) (r:m_rref i a b) (p:mem_predicate) :mem_predicate = fun m -> m `contains` r /\ p m in gst_witness (p_pred m p); lemma_functoriality (p_pred m p) p
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 36, "end_line": 259, "start_col": 0, "start_line": 251 }
(* 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.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2 let witnessed p = W.witnessed mem_rel p (* TODO: we should derive these using DM4F *) let gst_get _ = admit () let gst_put _ = admit () let gst_witness _ = admit () let gst_recall _ = admit () let lemma_functoriality p q = W.lemma_witnessed_weakening mem_rel p q let same_refs_in_all_regions m0 m1 = same_refs_common contained_region m0 m1 let same_refs_in_stack_regions m0 m1 = same_refs_common contained_stack_region m0 m1 let same_refs_in_non_tip_regions m0 m1 = same_refs_common contained_non_tip_region m0 m1 let same_refs_in_non_tip_stack_regions m0 m1 = same_refs_common contained_non_tip_stack_region m0 m1 let lemma_same_refs_in_all_regions_intro _ _ = () let lemma_same_refs_in_all_regions_elim _ _ _ = () let lemma_same_refs_in_stack_regions_intro _ _ = () let lemma_same_refs_in_stack_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_regions_intro _ _ = () let lemma_same_refs_in_non_tip_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_stack_regions_intro _ _ = () let lemma_same_refs_in_non_tip_stack_regions_elim _ _ _ = () let lemma_equal_domains_trans _ _ _ = () let push_frame _ = let m0 = gst_get () in let m1 = HS.hs_push_frame m0 in gst_put m1 let pop_frame _ = let m1 = pop (gst_get ()) in gst_put m1 private let salloc_common (#a:Type) (#rel:preorder a) (init:a) (mm:bool) :StackInline (mreference a rel) (requires (fun m -> is_stack_region (get_tip m))) (ensures (fun m0 s m1 -> is_stack_region (HS.frameOf s) /\ salloc_post init m0 s m1 /\ is_mm s == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel (get_tip m0) init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (get_hmap m0) (get_tip m0)) init mm; //AR: to prove that next_addr in tip's heap increases (it is part of mem_rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); //AR: to prove that rid_last_component of r.id is < rid_ctr gst_witness (ref_contains_pred r); gst_witness (region_contains_pred (HS.frameOf r)); r let salloc #_ #_ init = salloc_common init false let salloc_mm #_ #_ init = salloc_common init true let sfree #_ #_ r = let m0 = gst_get () in let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.get_tip m0)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1 let new_region r0 = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 None in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid let new_colored_region r0 c = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 (Some c) in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid private let ralloc_common (#a:Type) (#rel:preorder a) (i:rid) (init:a) (mm:bool) :ST (mreference a rel) (requires (fun m -> is_heap_color (color i) /\ m `contains_region` i)) (ensures (fun m0 r m1 -> ralloc_post i init m0 r m1 /\ is_mm r == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel i init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (HS.get_hmap m0) i) init mm; //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); gst_witness (ref_contains_pred r); gst_witness (region_contains_pred i); r let ralloc #_ #_ i init = if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init false let ralloc_mm #_ #_ i init = if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init true let rfree #_ #_ r = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); HS.lemma_rid_ctr_pred (); let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.frameOf r)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1 let op_Colon_Equals #_ #_ r v = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); let m1 = HS.upd_tot m0 r v in Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_upd_equals_upd_tot_for_contained_refs (get_hmap m0 `Map.sel` (HS.frameOf r)) (HS.as_ref r) v; Heap.lemma_next_addr_upd (Map.sel (HS.get_hmap m0) (HS.frameOf r)) (HS.as_ref r) v; //next_addr in ref's rid heap remains same gst_put m1 let op_Bang #_ #_ r = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); Heap.lemma_sel_equals_sel_tot_for_contained_refs (get_hmap m0 `Map.sel` (HS.frameOf r)) (HS.as_ref r); HS.sel_tot m0 r let get _ = gst_get () let recall #_ #_ r = gst_recall (ref_contains_pred r); gst_recall (region_contains_pred (HS.frameOf r)) let recall_region i = if i <> HS.root then gst_recall (region_contains_pred i) let witness_region i = gst_witness (region_contains_pred i) let witness_hsref #_ #_ r = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); gst_witness (ref_contains_pred r)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
m: FStar.HyperStack.ST.m_rref r a b -> p: FStar.HyperStack.ST.mem_predicate -> FStar.HyperStack.ST.ST Prims.unit
FStar.HyperStack.ST.ST
[]
[]
[ "FStar.HyperStack.ST.erid", "FStar.Preorder.preorder", "FStar.HyperStack.ST.m_rref", "FStar.HyperStack.ST.mem_predicate", "FStar.HyperStack.ST.lemma_functoriality", "Prims.unit", "FStar.HyperStack.ST.gst_witness", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "FStar.Monotonic.HyperStack.contains", "FStar.HyperStack.ST.recall" ]
[]
false
true
false
false
false
let mr_witness #r #_ #_ m p =
recall m; let p_pred (#i: erid) (#a: Type) (#b: preorder a) (r: m_rref i a b) (p: mem_predicate) : mem_predicate = fun m -> m `contains` r /\ p m in gst_witness (p_pred m p); lemma_functoriality (p_pred m p) p
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.ralloc_mm
val ralloc_mm (#a:Type) (#rel:preorder a) (i:rid) (init:a) :ST (mmmref a rel) (requires (fun m -> is_eternal_region i)) (ensures (ralloc_post i init))
val ralloc_mm (#a:Type) (#rel:preorder a) (i:rid) (init:a) :ST (mmmref a rel) (requires (fun m -> is_eternal_region i)) (ensures (ralloc_post i init))
let ralloc_mm #_ #_ i init = if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init true
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 27, "end_line": 205, "start_col": 0, "start_line": 203 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2 let witnessed p = W.witnessed mem_rel p (* TODO: we should derive these using DM4F *) let gst_get _ = admit () let gst_put _ = admit () let gst_witness _ = admit () let gst_recall _ = admit () let lemma_functoriality p q = W.lemma_witnessed_weakening mem_rel p q let same_refs_in_all_regions m0 m1 = same_refs_common contained_region m0 m1 let same_refs_in_stack_regions m0 m1 = same_refs_common contained_stack_region m0 m1 let same_refs_in_non_tip_regions m0 m1 = same_refs_common contained_non_tip_region m0 m1 let same_refs_in_non_tip_stack_regions m0 m1 = same_refs_common contained_non_tip_stack_region m0 m1 let lemma_same_refs_in_all_regions_intro _ _ = () let lemma_same_refs_in_all_regions_elim _ _ _ = () let lemma_same_refs_in_stack_regions_intro _ _ = () let lemma_same_refs_in_stack_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_regions_intro _ _ = () let lemma_same_refs_in_non_tip_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_stack_regions_intro _ _ = () let lemma_same_refs_in_non_tip_stack_regions_elim _ _ _ = () let lemma_equal_domains_trans _ _ _ = () let push_frame _ = let m0 = gst_get () in let m1 = HS.hs_push_frame m0 in gst_put m1 let pop_frame _ = let m1 = pop (gst_get ()) in gst_put m1 private let salloc_common (#a:Type) (#rel:preorder a) (init:a) (mm:bool) :StackInline (mreference a rel) (requires (fun m -> is_stack_region (get_tip m))) (ensures (fun m0 s m1 -> is_stack_region (HS.frameOf s) /\ salloc_post init m0 s m1 /\ is_mm s == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel (get_tip m0) init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (get_hmap m0) (get_tip m0)) init mm; //AR: to prove that next_addr in tip's heap increases (it is part of mem_rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); //AR: to prove that rid_last_component of r.id is < rid_ctr gst_witness (ref_contains_pred r); gst_witness (region_contains_pred (HS.frameOf r)); r let salloc #_ #_ init = salloc_common init false let salloc_mm #_ #_ init = salloc_common init true let sfree #_ #_ r = let m0 = gst_get () in let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.get_tip m0)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1 let new_region r0 = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 None in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid let new_colored_region r0 c = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 (Some c) in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid private let ralloc_common (#a:Type) (#rel:preorder a) (i:rid) (init:a) (mm:bool) :ST (mreference a rel) (requires (fun m -> is_heap_color (color i) /\ m `contains_region` i)) (ensures (fun m0 r m1 -> ralloc_post i init m0 r m1 /\ is_mm r == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel i init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (HS.get_hmap m0) i) init mm; //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); gst_witness (ref_contains_pred r); gst_witness (region_contains_pred i); r let ralloc #_ #_ i init = if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init false
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i: FStar.Monotonic.HyperHeap.rid -> init: a -> FStar.HyperStack.ST.ST (FStar.HyperStack.ST.mmmref a rel)
FStar.HyperStack.ST.ST
[]
[]
[ "FStar.Preorder.preorder", "FStar.Monotonic.HyperHeap.rid", "FStar.HyperStack.ST.ralloc_common", "FStar.HyperStack.ST.mreference", "Prims.unit", "Prims.op_disEquality", "FStar.Monotonic.HyperHeap.root", "FStar.HyperStack.ST.gst_recall", "FStar.HyperStack.ST.region_contains_pred", "Prims.bool", "FStar.HyperStack.ST.mmmref" ]
[]
false
true
false
false
false
let ralloc_mm #_ #_ i init =
if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init true
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.rfree
val rfree (#a:Type) (#rel:preorder a) (r:mreference a rel{HS.is_mm r /\ HS.is_heap_color (HS.color (HS.frameOf r))}) :ST unit (requires (fun m0 -> r `is_live_for_rw_in` m0)) (ensures (fun m0 _ m1 -> m0 `contains` r /\ m1 == HS.free r m0))
val rfree (#a:Type) (#rel:preorder a) (r:mreference a rel{HS.is_mm r /\ HS.is_heap_color (HS.color (HS.frameOf r))}) :ST unit (requires (fun m0 -> r `is_live_for_rw_in` m0)) (ensures (fun m0 _ m1 -> m0 `contains` r /\ m1 == HS.free r m0))
let rfree #_ #_ r = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); HS.lemma_rid_ctr_pred (); let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.frameOf r)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 12, "end_line": 217, "start_col": 0, "start_line": 207 }
(* 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.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2 let witnessed p = W.witnessed mem_rel p (* TODO: we should derive these using DM4F *) let gst_get _ = admit () let gst_put _ = admit () let gst_witness _ = admit () let gst_recall _ = admit () let lemma_functoriality p q = W.lemma_witnessed_weakening mem_rel p q let same_refs_in_all_regions m0 m1 = same_refs_common contained_region m0 m1 let same_refs_in_stack_regions m0 m1 = same_refs_common contained_stack_region m0 m1 let same_refs_in_non_tip_regions m0 m1 = same_refs_common contained_non_tip_region m0 m1 let same_refs_in_non_tip_stack_regions m0 m1 = same_refs_common contained_non_tip_stack_region m0 m1 let lemma_same_refs_in_all_regions_intro _ _ = () let lemma_same_refs_in_all_regions_elim _ _ _ = () let lemma_same_refs_in_stack_regions_intro _ _ = () let lemma_same_refs_in_stack_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_regions_intro _ _ = () let lemma_same_refs_in_non_tip_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_stack_regions_intro _ _ = () let lemma_same_refs_in_non_tip_stack_regions_elim _ _ _ = () let lemma_equal_domains_trans _ _ _ = () let push_frame _ = let m0 = gst_get () in let m1 = HS.hs_push_frame m0 in gst_put m1 let pop_frame _ = let m1 = pop (gst_get ()) in gst_put m1 private let salloc_common (#a:Type) (#rel:preorder a) (init:a) (mm:bool) :StackInline (mreference a rel) (requires (fun m -> is_stack_region (get_tip m))) (ensures (fun m0 s m1 -> is_stack_region (HS.frameOf s) /\ salloc_post init m0 s m1 /\ is_mm s == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel (get_tip m0) init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (get_hmap m0) (get_tip m0)) init mm; //AR: to prove that next_addr in tip's heap increases (it is part of mem_rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); //AR: to prove that rid_last_component of r.id is < rid_ctr gst_witness (ref_contains_pred r); gst_witness (region_contains_pred (HS.frameOf r)); r let salloc #_ #_ init = salloc_common init false let salloc_mm #_ #_ init = salloc_common init true let sfree #_ #_ r = let m0 = gst_get () in let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.get_tip m0)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1 let new_region r0 = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 None in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid let new_colored_region r0 c = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 (Some c) in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid private let ralloc_common (#a:Type) (#rel:preorder a) (i:rid) (init:a) (mm:bool) :ST (mreference a rel) (requires (fun m -> is_heap_color (color i) /\ m `contains_region` i)) (ensures (fun m0 r m1 -> ralloc_post i init m0 r m1 /\ is_mm r == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel i init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (HS.get_hmap m0) i) init mm; //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); gst_witness (ref_contains_pred r); gst_witness (region_contains_pred i); r let ralloc #_ #_ i init = if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init false let ralloc_mm #_ #_ i init = if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init true
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.HyperStack.ST.mreference a rel { FStar.Monotonic.HyperStack.is_mm r /\ FStar.Monotonic.HyperStack.is_heap_color (FStar.Monotonic.HyperHeap.color (FStar.Monotonic.HyperStack.frameOf r)) } -> FStar.HyperStack.ST.ST Prims.unit
FStar.HyperStack.ST.ST
[]
[]
[ "FStar.Preorder.preorder", "FStar.HyperStack.ST.mreference", "Prims.l_and", "Prims.b2t", "FStar.Monotonic.HyperStack.is_mm", "FStar.Monotonic.HyperStack.is_heap_color", "FStar.Monotonic.HyperHeap.color", "FStar.Monotonic.HyperStack.frameOf", "FStar.HyperStack.ST.gst_put", "Prims.unit", "FStar.Monotonic.Heap.lemma_next_addr_free_mm", "FStar.Map.sel", "FStar.Monotonic.HyperHeap.rid", "FStar.Monotonic.Heap.heap", "FStar.Monotonic.HyperStack.get_hmap", "FStar.Monotonic.HyperStack.as_ref", "FStar.Monotonic.Heap.lemma_distinct_addrs_distinct_mm", "FStar.Monotonic.Heap.lemma_distinct_addrs_distinct_preorders", "Prims._assert", "FStar.Set.equal", "FStar.Map.domain", "FStar.Monotonic.HyperStack.mem", "FStar.Monotonic.HyperStack.free", "FStar.Monotonic.HyperStack.lemma_rid_ctr_pred", "FStar.HyperStack.ST.gst_recall", "FStar.HyperStack.ST.ref_contains_pred", "FStar.HyperStack.ST.region_contains_pred", "FStar.HyperStack.ST.gst_get" ]
[]
false
true
false
false
false
let rfree #_ #_ r =
let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); HS.lemma_rid_ctr_pred (); let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.frameOf r)) (HS.as_ref r); gst_put m1
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.testify
val testify (p:mem_predicate) :ST unit (requires (fun _ -> witnessed p)) (ensures (fun h0 _ h1 -> h0==h1 /\ p h1))
val testify (p:mem_predicate) :ST unit (requires (fun _ -> witnessed p)) (ensures (fun h0 _ h1 -> h0==h1 /\ p h1))
let testify (p:mem_predicate) = gst_recall p
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 44, "end_line": 267, "start_col": 0, "start_line": 267 }
(* 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.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2 let witnessed p = W.witnessed mem_rel p (* TODO: we should derive these using DM4F *) let gst_get _ = admit () let gst_put _ = admit () let gst_witness _ = admit () let gst_recall _ = admit () let lemma_functoriality p q = W.lemma_witnessed_weakening mem_rel p q let same_refs_in_all_regions m0 m1 = same_refs_common contained_region m0 m1 let same_refs_in_stack_regions m0 m1 = same_refs_common contained_stack_region m0 m1 let same_refs_in_non_tip_regions m0 m1 = same_refs_common contained_non_tip_region m0 m1 let same_refs_in_non_tip_stack_regions m0 m1 = same_refs_common contained_non_tip_stack_region m0 m1 let lemma_same_refs_in_all_regions_intro _ _ = () let lemma_same_refs_in_all_regions_elim _ _ _ = () let lemma_same_refs_in_stack_regions_intro _ _ = () let lemma_same_refs_in_stack_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_regions_intro _ _ = () let lemma_same_refs_in_non_tip_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_stack_regions_intro _ _ = () let lemma_same_refs_in_non_tip_stack_regions_elim _ _ _ = () let lemma_equal_domains_trans _ _ _ = () let push_frame _ = let m0 = gst_get () in let m1 = HS.hs_push_frame m0 in gst_put m1 let pop_frame _ = let m1 = pop (gst_get ()) in gst_put m1 private let salloc_common (#a:Type) (#rel:preorder a) (init:a) (mm:bool) :StackInline (mreference a rel) (requires (fun m -> is_stack_region (get_tip m))) (ensures (fun m0 s m1 -> is_stack_region (HS.frameOf s) /\ salloc_post init m0 s m1 /\ is_mm s == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel (get_tip m0) init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (get_hmap m0) (get_tip m0)) init mm; //AR: to prove that next_addr in tip's heap increases (it is part of mem_rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); //AR: to prove that rid_last_component of r.id is < rid_ctr gst_witness (ref_contains_pred r); gst_witness (region_contains_pred (HS.frameOf r)); r let salloc #_ #_ init = salloc_common init false let salloc_mm #_ #_ init = salloc_common init true let sfree #_ #_ r = let m0 = gst_get () in let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.get_tip m0)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1 let new_region r0 = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 None in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid let new_colored_region r0 c = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 (Some c) in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid private let ralloc_common (#a:Type) (#rel:preorder a) (i:rid) (init:a) (mm:bool) :ST (mreference a rel) (requires (fun m -> is_heap_color (color i) /\ m `contains_region` i)) (ensures (fun m0 r m1 -> ralloc_post i init m0 r m1 /\ is_mm r == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel i init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (HS.get_hmap m0) i) init mm; //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); gst_witness (ref_contains_pred r); gst_witness (region_contains_pred i); r let ralloc #_ #_ i init = if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init false let ralloc_mm #_ #_ i init = if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init true let rfree #_ #_ r = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); HS.lemma_rid_ctr_pred (); let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.frameOf r)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1 let op_Colon_Equals #_ #_ r v = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); let m1 = HS.upd_tot m0 r v in Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_upd_equals_upd_tot_for_contained_refs (get_hmap m0 `Map.sel` (HS.frameOf r)) (HS.as_ref r) v; Heap.lemma_next_addr_upd (Map.sel (HS.get_hmap m0) (HS.frameOf r)) (HS.as_ref r) v; //next_addr in ref's rid heap remains same gst_put m1 let op_Bang #_ #_ r = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); Heap.lemma_sel_equals_sel_tot_for_contained_refs (get_hmap m0 `Map.sel` (HS.frameOf r)) (HS.as_ref r); HS.sel_tot m0 r let get _ = gst_get () let recall #_ #_ r = gst_recall (ref_contains_pred r); gst_recall (region_contains_pred (HS.frameOf r)) let recall_region i = if i <> HS.root then gst_recall (region_contains_pred i) let witness_region i = gst_witness (region_contains_pred i) let witness_hsref #_ #_ r = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); gst_witness (ref_contains_pred r) let mr_witness #r #_ #_ m p = recall m; let p_pred (#i:erid) (#a:Type) (#b:preorder a) (r:m_rref i a b) (p:mem_predicate) :mem_predicate = fun m -> m `contains` r /\ p m in gst_witness (p_pred m p); lemma_functoriality (p_pred m p) p let weaken_witness p q = let aux () :Lemma (requires ((forall h. p h ==> q h) /\ witnessed p)) (ensures (witnessed q)) = lemma_functoriality p q in FStar.Classical.move_requires aux ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: FStar.HyperStack.ST.mem_predicate -> FStar.HyperStack.ST.ST Prims.unit
FStar.HyperStack.ST.ST
[]
[]
[ "FStar.HyperStack.ST.mem_predicate", "FStar.HyperStack.ST.gst_recall", "Prims.unit" ]
[]
false
true
false
false
false
let testify (p: mem_predicate) =
gst_recall p
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.new_region
val new_region (r0:rid) :ST rid (requires (fun m -> is_eternal_region r0)) (ensures (fun m0 r1 m1 -> new_region_post_common r0 r1 m0 m1 /\ HS.color r1 = HS.color r0 /\ is_eternal_region r1 /\ (r1, m1) == HS.new_eternal_region m0 r0 None))
val new_region (r0:rid) :ST rid (requires (fun m -> is_eternal_region r0)) (ensures (fun m0 r1 m1 -> new_region_post_common r0 r1 m0 m1 /\ HS.color r1 = HS.color r0 /\ is_eternal_region r1 /\ (r1, m1) == HS.new_eternal_region m0 r0 None))
let new_region r0 = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 None in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 9, "end_line": 174, "start_col": 0, "start_line": 167 }
(* 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.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2 let witnessed p = W.witnessed mem_rel p (* TODO: we should derive these using DM4F *) let gst_get _ = admit () let gst_put _ = admit () let gst_witness _ = admit () let gst_recall _ = admit () let lemma_functoriality p q = W.lemma_witnessed_weakening mem_rel p q let same_refs_in_all_regions m0 m1 = same_refs_common contained_region m0 m1 let same_refs_in_stack_regions m0 m1 = same_refs_common contained_stack_region m0 m1 let same_refs_in_non_tip_regions m0 m1 = same_refs_common contained_non_tip_region m0 m1 let same_refs_in_non_tip_stack_regions m0 m1 = same_refs_common contained_non_tip_stack_region m0 m1 let lemma_same_refs_in_all_regions_intro _ _ = () let lemma_same_refs_in_all_regions_elim _ _ _ = () let lemma_same_refs_in_stack_regions_intro _ _ = () let lemma_same_refs_in_stack_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_regions_intro _ _ = () let lemma_same_refs_in_non_tip_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_stack_regions_intro _ _ = () let lemma_same_refs_in_non_tip_stack_regions_elim _ _ _ = () let lemma_equal_domains_trans _ _ _ = () let push_frame _ = let m0 = gst_get () in let m1 = HS.hs_push_frame m0 in gst_put m1 let pop_frame _ = let m1 = pop (gst_get ()) in gst_put m1 private let salloc_common (#a:Type) (#rel:preorder a) (init:a) (mm:bool) :StackInline (mreference a rel) (requires (fun m -> is_stack_region (get_tip m))) (ensures (fun m0 s m1 -> is_stack_region (HS.frameOf s) /\ salloc_post init m0 s m1 /\ is_mm s == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel (get_tip m0) init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (get_hmap m0) (get_tip m0)) init mm; //AR: to prove that next_addr in tip's heap increases (it is part of mem_rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); //AR: to prove that rid_last_component of r.id is < rid_ctr gst_witness (ref_contains_pred r); gst_witness (region_contains_pred (HS.frameOf r)); r let salloc #_ #_ init = salloc_common init false let salloc_mm #_ #_ init = salloc_common init true let sfree #_ #_ r = let m0 = gst_get () in let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.get_tip m0)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r0: FStar.Monotonic.HyperHeap.rid -> FStar.HyperStack.ST.ST FStar.Monotonic.HyperHeap.rid
FStar.HyperStack.ST.ST
[]
[]
[ "FStar.Monotonic.HyperHeap.rid", "FStar.Monotonic.HyperStack.mem", "Prims.unit", "FStar.HyperStack.ST.gst_witness", "FStar.HyperStack.ST.region_contains_pred", "FStar.HyperStack.ST.gst_put", "FStar.Pervasives.Native.tuple2", "FStar.Monotonic.HyperStack.fresh_region", "FStar.Pervasives.Native.fst", "FStar.Pervasives.Native.snd", "FStar.Monotonic.HyperStack.new_eternal_region", "FStar.Pervasives.Native.None", "Prims.int", "FStar.HyperStack.ST.gst_get", "FStar.Monotonic.HyperStack.lemma_rid_ctr_pred", "Prims.op_disEquality", "FStar.Monotonic.HyperHeap.root", "FStar.HyperStack.ST.gst_recall", "Prims.bool" ]
[]
false
true
false
false
false
let new_region r0 =
if r0 <> HS.root then gst_recall (region_contains_pred r0); HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 None in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.witness_region
val witness_region (i:rid) :Stack unit (requires (fun m0 -> HS.is_eternal_region_hs i ==> i `is_in` get_hmap m0)) (ensures (fun m0 _ m1 -> m0 == m1 /\ witnessed (region_contains_pred i)))
val witness_region (i:rid) :Stack unit (requires (fun m0 -> HS.is_eternal_region_hs i ==> i `is_in` get_hmap m0)) (ensures (fun m0 _ m1 -> m0 == m1 /\ witnessed (region_contains_pred i)))
let witness_region i = gst_witness (region_contains_pred i)
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 59, "end_line": 244, "start_col": 0, "start_line": 244 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2 let witnessed p = W.witnessed mem_rel p (* TODO: we should derive these using DM4F *) let gst_get _ = admit () let gst_put _ = admit () let gst_witness _ = admit () let gst_recall _ = admit () let lemma_functoriality p q = W.lemma_witnessed_weakening mem_rel p q let same_refs_in_all_regions m0 m1 = same_refs_common contained_region m0 m1 let same_refs_in_stack_regions m0 m1 = same_refs_common contained_stack_region m0 m1 let same_refs_in_non_tip_regions m0 m1 = same_refs_common contained_non_tip_region m0 m1 let same_refs_in_non_tip_stack_regions m0 m1 = same_refs_common contained_non_tip_stack_region m0 m1 let lemma_same_refs_in_all_regions_intro _ _ = () let lemma_same_refs_in_all_regions_elim _ _ _ = () let lemma_same_refs_in_stack_regions_intro _ _ = () let lemma_same_refs_in_stack_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_regions_intro _ _ = () let lemma_same_refs_in_non_tip_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_stack_regions_intro _ _ = () let lemma_same_refs_in_non_tip_stack_regions_elim _ _ _ = () let lemma_equal_domains_trans _ _ _ = () let push_frame _ = let m0 = gst_get () in let m1 = HS.hs_push_frame m0 in gst_put m1 let pop_frame _ = let m1 = pop (gst_get ()) in gst_put m1 private let salloc_common (#a:Type) (#rel:preorder a) (init:a) (mm:bool) :StackInline (mreference a rel) (requires (fun m -> is_stack_region (get_tip m))) (ensures (fun m0 s m1 -> is_stack_region (HS.frameOf s) /\ salloc_post init m0 s m1 /\ is_mm s == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel (get_tip m0) init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (get_hmap m0) (get_tip m0)) init mm; //AR: to prove that next_addr in tip's heap increases (it is part of mem_rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); //AR: to prove that rid_last_component of r.id is < rid_ctr gst_witness (ref_contains_pred r); gst_witness (region_contains_pred (HS.frameOf r)); r let salloc #_ #_ init = salloc_common init false let salloc_mm #_ #_ init = salloc_common init true let sfree #_ #_ r = let m0 = gst_get () in let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.get_tip m0)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1 let new_region r0 = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 None in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid let new_colored_region r0 c = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 (Some c) in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid private let ralloc_common (#a:Type) (#rel:preorder a) (i:rid) (init:a) (mm:bool) :ST (mreference a rel) (requires (fun m -> is_heap_color (color i) /\ m `contains_region` i)) (ensures (fun m0 r m1 -> ralloc_post i init m0 r m1 /\ is_mm r == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel i init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (HS.get_hmap m0) i) init mm; //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); gst_witness (ref_contains_pred r); gst_witness (region_contains_pred i); r let ralloc #_ #_ i init = if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init false let ralloc_mm #_ #_ i init = if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init true let rfree #_ #_ r = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); HS.lemma_rid_ctr_pred (); let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.frameOf r)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1 let op_Colon_Equals #_ #_ r v = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); let m1 = HS.upd_tot m0 r v in Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_upd_equals_upd_tot_for_contained_refs (get_hmap m0 `Map.sel` (HS.frameOf r)) (HS.as_ref r) v; Heap.lemma_next_addr_upd (Map.sel (HS.get_hmap m0) (HS.frameOf r)) (HS.as_ref r) v; //next_addr in ref's rid heap remains same gst_put m1 let op_Bang #_ #_ r = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); Heap.lemma_sel_equals_sel_tot_for_contained_refs (get_hmap m0 `Map.sel` (HS.frameOf r)) (HS.as_ref r); HS.sel_tot m0 r let get _ = gst_get () let recall #_ #_ r = gst_recall (ref_contains_pred r); gst_recall (region_contains_pred (HS.frameOf r))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i: FStar.Monotonic.HyperHeap.rid -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "FStar.Monotonic.HyperHeap.rid", "FStar.HyperStack.ST.gst_witness", "FStar.HyperStack.ST.region_contains_pred", "Prims.unit" ]
[]
false
true
false
false
false
let witness_region i =
gst_witness (region_contains_pred i)
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.rid_of_drgn
val rid_of_drgn (d:drgn) : d_hrid
val rid_of_drgn (d:drgn) : d_hrid
let rid_of_drgn d = d
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 21, "end_line": 318, "start_col": 0, "start_line": 318 }
(* 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.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2 let witnessed p = W.witnessed mem_rel p (* TODO: we should derive these using DM4F *) let gst_get _ = admit () let gst_put _ = admit () let gst_witness _ = admit () let gst_recall _ = admit () let lemma_functoriality p q = W.lemma_witnessed_weakening mem_rel p q let same_refs_in_all_regions m0 m1 = same_refs_common contained_region m0 m1 let same_refs_in_stack_regions m0 m1 = same_refs_common contained_stack_region m0 m1 let same_refs_in_non_tip_regions m0 m1 = same_refs_common contained_non_tip_region m0 m1 let same_refs_in_non_tip_stack_regions m0 m1 = same_refs_common contained_non_tip_stack_region m0 m1 let lemma_same_refs_in_all_regions_intro _ _ = () let lemma_same_refs_in_all_regions_elim _ _ _ = () let lemma_same_refs_in_stack_regions_intro _ _ = () let lemma_same_refs_in_stack_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_regions_intro _ _ = () let lemma_same_refs_in_non_tip_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_stack_regions_intro _ _ = () let lemma_same_refs_in_non_tip_stack_regions_elim _ _ _ = () let lemma_equal_domains_trans _ _ _ = () let push_frame _ = let m0 = gst_get () in let m1 = HS.hs_push_frame m0 in gst_put m1 let pop_frame _ = let m1 = pop (gst_get ()) in gst_put m1 private let salloc_common (#a:Type) (#rel:preorder a) (init:a) (mm:bool) :StackInline (mreference a rel) (requires (fun m -> is_stack_region (get_tip m))) (ensures (fun m0 s m1 -> is_stack_region (HS.frameOf s) /\ salloc_post init m0 s m1 /\ is_mm s == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel (get_tip m0) init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (get_hmap m0) (get_tip m0)) init mm; //AR: to prove that next_addr in tip's heap increases (it is part of mem_rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); //AR: to prove that rid_last_component of r.id is < rid_ctr gst_witness (ref_contains_pred r); gst_witness (region_contains_pred (HS.frameOf r)); r let salloc #_ #_ init = salloc_common init false let salloc_mm #_ #_ init = salloc_common init true let sfree #_ #_ r = let m0 = gst_get () in let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.get_tip m0)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1 let new_region r0 = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 None in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid let new_colored_region r0 c = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 (Some c) in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid private let ralloc_common (#a:Type) (#rel:preorder a) (i:rid) (init:a) (mm:bool) :ST (mreference a rel) (requires (fun m -> is_heap_color (color i) /\ m `contains_region` i)) (ensures (fun m0 r m1 -> ralloc_post i init m0 r m1 /\ is_mm r == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel i init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (HS.get_hmap m0) i) init mm; //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); gst_witness (ref_contains_pred r); gst_witness (region_contains_pred i); r let ralloc #_ #_ i init = if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init false let ralloc_mm #_ #_ i init = if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init true let rfree #_ #_ r = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); HS.lemma_rid_ctr_pred (); let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.frameOf r)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1 let op_Colon_Equals #_ #_ r v = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); let m1 = HS.upd_tot m0 r v in Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_upd_equals_upd_tot_for_contained_refs (get_hmap m0 `Map.sel` (HS.frameOf r)) (HS.as_ref r) v; Heap.lemma_next_addr_upd (Map.sel (HS.get_hmap m0) (HS.frameOf r)) (HS.as_ref r) v; //next_addr in ref's rid heap remains same gst_put m1 let op_Bang #_ #_ r = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); Heap.lemma_sel_equals_sel_tot_for_contained_refs (get_hmap m0 `Map.sel` (HS.frameOf r)) (HS.as_ref r); HS.sel_tot m0 r let get _ = gst_get () let recall #_ #_ r = gst_recall (ref_contains_pred r); gst_recall (region_contains_pred (HS.frameOf r)) let recall_region i = if i <> HS.root then gst_recall (region_contains_pred i) let witness_region i = gst_witness (region_contains_pred i) let witness_hsref #_ #_ r = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); gst_witness (ref_contains_pred r) let mr_witness #r #_ #_ m p = recall m; let p_pred (#i:erid) (#a:Type) (#b:preorder a) (r:m_rref i a b) (p:mem_predicate) :mem_predicate = fun m -> m `contains` r /\ p m in gst_witness (p_pred m p); lemma_functoriality (p_pred m p) p let weaken_witness p q = let aux () :Lemma (requires ((forall h. p h ==> q h) /\ witnessed p)) (ensures (witnessed q)) = lemma_functoriality p q in FStar.Classical.move_requires aux () let testify (p:mem_predicate) = gst_recall p let testify_forall #c #p $s = W.lemma_witnessed_forall mem_rel p; gst_recall (fun h -> forall (x:c). p x h) let testify_forall_region_contains_pred #c #p $s = let p' (x:c) :mem_predicate = region_contains_pred (p x) in let s:squash (forall (x:c). witnessed (p' x)) = () in testify_forall s private let mem_rel_predicate (#a:Type0) (#rel:preorder a) (r:mreference a rel) (p:mem_predicate) :mem_predicate = let rid = HS.frameOf r in fun m -> (HS.rid_last_component rid < HS.get_rid_ctr m) /\ ( //will help us prove that a deallocated region remains deallocated (m `HS.contains` r /\ p m) \/ //the ref is contained and satisfies p (m `contains_region` rid /\ ~ (m `HS.contains_ref_in_its_region` r) /\ HS.as_addr r < Heap.next_addr (HS.get_hmap m `Map.sel` rid) /\ r `HS.unused_in` m) \/ //the ref is deallocated, but its region is contained and next_addr > addr_of ref (not (m `contains_region` rid))) //the region itself is not there let token_p #_ #_ r p = witnessed (mem_rel_predicate r p) let witness_p #_ #_ r p = gst_recall (ref_contains_pred r); gst_recall (region_contains_pred (HS.frameOf r)); HS.lemma_next_addr_contained_refs_addr (); gst_witness (mem_rel_predicate r p) let recall_p #_ #_ r p = gst_recall (ref_contains_pred r); gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (mem_rel_predicate r p) let token_functoriality #_ #_ r p q = lemma_functoriality (mem_rel_predicate r p) (mem_rel_predicate r q) let lemma_witnessed_constant p = W.lemma_witnessed_constant mem_rel p let lemma_witnessed_nested p = assert_norm (witnessed (fun (m:mem) -> witnessed p) == W.witnessed mem_rel (fun (m:mem) -> W.witnessed mem_rel p)); assert_norm (witnessed p == W.witnessed mem_rel p); W.lemma_witnessed_nested mem_rel p let lemma_witnessed_and p q = W.lemma_witnessed_and mem_rel p q let lemma_witnessed_or p q = W.lemma_witnessed_or mem_rel p q let lemma_witnessed_impl p q = W.lemma_witnessed_impl mem_rel p q let lemma_witnessed_forall #_ p = W.lemma_witnessed_forall mem_rel p let lemma_witnessed_exists #_ p = W.lemma_witnessed_exists mem_rel p
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
d: FStar.HyperStack.ST.drgn -> FStar.HyperStack.ST.d_hrid
Prims.Tot
[ "total" ]
[]
[ "FStar.HyperStack.ST.drgn", "FStar.HyperStack.ST.d_hrid" ]
[]
false
false
false
true
false
let rid_of_drgn d =
d
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.new_colored_region
val new_colored_region (r0:rid) (c:int) :ST rid (requires (fun m -> HS.is_heap_color c /\ is_eternal_region r0)) (ensures (fun m0 r1 m1 -> new_region_post_common r0 r1 m0 m1 /\ HS.color r1 = c /\ is_eternal_region r1 /\ (r1, m1) == HS.new_eternal_region m0 r0 (Some c)))
val new_colored_region (r0:rid) (c:int) :ST rid (requires (fun m -> HS.is_heap_color c /\ is_eternal_region r0)) (ensures (fun m0 r1 m1 -> new_region_post_common r0 r1 m0 m1 /\ HS.color r1 = c /\ is_eternal_region r1 /\ (r1, m1) == HS.new_eternal_region m0 r0 (Some c)))
let new_colored_region r0 c = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 (Some c) in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 9, "end_line": 183, "start_col": 0, "start_line": 176 }
(* 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.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2 let witnessed p = W.witnessed mem_rel p (* TODO: we should derive these using DM4F *) let gst_get _ = admit () let gst_put _ = admit () let gst_witness _ = admit () let gst_recall _ = admit () let lemma_functoriality p q = W.lemma_witnessed_weakening mem_rel p q let same_refs_in_all_regions m0 m1 = same_refs_common contained_region m0 m1 let same_refs_in_stack_regions m0 m1 = same_refs_common contained_stack_region m0 m1 let same_refs_in_non_tip_regions m0 m1 = same_refs_common contained_non_tip_region m0 m1 let same_refs_in_non_tip_stack_regions m0 m1 = same_refs_common contained_non_tip_stack_region m0 m1 let lemma_same_refs_in_all_regions_intro _ _ = () let lemma_same_refs_in_all_regions_elim _ _ _ = () let lemma_same_refs_in_stack_regions_intro _ _ = () let lemma_same_refs_in_stack_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_regions_intro _ _ = () let lemma_same_refs_in_non_tip_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_stack_regions_intro _ _ = () let lemma_same_refs_in_non_tip_stack_regions_elim _ _ _ = () let lemma_equal_domains_trans _ _ _ = () let push_frame _ = let m0 = gst_get () in let m1 = HS.hs_push_frame m0 in gst_put m1 let pop_frame _ = let m1 = pop (gst_get ()) in gst_put m1 private let salloc_common (#a:Type) (#rel:preorder a) (init:a) (mm:bool) :StackInline (mreference a rel) (requires (fun m -> is_stack_region (get_tip m))) (ensures (fun m0 s m1 -> is_stack_region (HS.frameOf s) /\ salloc_post init m0 s m1 /\ is_mm s == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel (get_tip m0) init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (get_hmap m0) (get_tip m0)) init mm; //AR: to prove that next_addr in tip's heap increases (it is part of mem_rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); //AR: to prove that rid_last_component of r.id is < rid_ctr gst_witness (ref_contains_pred r); gst_witness (region_contains_pred (HS.frameOf r)); r let salloc #_ #_ init = salloc_common init false let salloc_mm #_ #_ init = salloc_common init true let sfree #_ #_ r = let m0 = gst_get () in let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.get_tip m0)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1 let new_region r0 = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 None in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r0: FStar.Monotonic.HyperHeap.rid -> c: Prims.int -> FStar.HyperStack.ST.ST FStar.Monotonic.HyperHeap.rid
FStar.HyperStack.ST.ST
[]
[]
[ "FStar.Monotonic.HyperHeap.rid", "Prims.int", "FStar.Monotonic.HyperStack.mem", "Prims.unit", "FStar.HyperStack.ST.gst_witness", "FStar.HyperStack.ST.region_contains_pred", "FStar.HyperStack.ST.gst_put", "FStar.Pervasives.Native.tuple2", "FStar.Monotonic.HyperStack.fresh_region", "FStar.Pervasives.Native.fst", "FStar.Pervasives.Native.snd", "FStar.Monotonic.HyperStack.new_eternal_region", "FStar.Pervasives.Native.Some", "FStar.HyperStack.ST.gst_get", "FStar.Monotonic.HyperStack.lemma_rid_ctr_pred", "Prims.op_disEquality", "FStar.Monotonic.HyperHeap.root", "FStar.HyperStack.ST.gst_recall", "Prims.bool" ]
[]
false
true
false
false
false
let new_colored_region r0 c =
if r0 <> HS.root then gst_recall (region_contains_pred r0); HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 (Some c) in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.op_Colon_Equals
val op_Colon_Equals (#a:Type) (#rel:preorder a) (r:mreference a rel) (v:a) :STL unit (requires (fun m -> r `is_live_for_rw_in` m /\ rel (HS.sel m r) v)) (ensures (assign_post r v))
val op_Colon_Equals (#a:Type) (#rel:preorder a) (r:mreference a rel) (v:a) :STL unit (requires (fun m -> r `is_live_for_rw_in` m /\ rel (HS.sel m r) v)) (ensures (assign_post r v))
let op_Colon_Equals #_ #_ r v = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); let m1 = HS.upd_tot m0 r v in Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_upd_equals_upd_tot_for_contained_refs (get_hmap m0 `Map.sel` (HS.frameOf r)) (HS.as_ref r) v; Heap.lemma_next_addr_upd (Map.sel (HS.get_hmap m0) (HS.frameOf r)) (HS.as_ref r) v; //next_addr in ref's rid heap remains same gst_put m1
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 12, "end_line": 228, "start_col": 0, "start_line": 219 }
(* 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.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2 let witnessed p = W.witnessed mem_rel p (* TODO: we should derive these using DM4F *) let gst_get _ = admit () let gst_put _ = admit () let gst_witness _ = admit () let gst_recall _ = admit () let lemma_functoriality p q = W.lemma_witnessed_weakening mem_rel p q let same_refs_in_all_regions m0 m1 = same_refs_common contained_region m0 m1 let same_refs_in_stack_regions m0 m1 = same_refs_common contained_stack_region m0 m1 let same_refs_in_non_tip_regions m0 m1 = same_refs_common contained_non_tip_region m0 m1 let same_refs_in_non_tip_stack_regions m0 m1 = same_refs_common contained_non_tip_stack_region m0 m1 let lemma_same_refs_in_all_regions_intro _ _ = () let lemma_same_refs_in_all_regions_elim _ _ _ = () let lemma_same_refs_in_stack_regions_intro _ _ = () let lemma_same_refs_in_stack_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_regions_intro _ _ = () let lemma_same_refs_in_non_tip_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_stack_regions_intro _ _ = () let lemma_same_refs_in_non_tip_stack_regions_elim _ _ _ = () let lemma_equal_domains_trans _ _ _ = () let push_frame _ = let m0 = gst_get () in let m1 = HS.hs_push_frame m0 in gst_put m1 let pop_frame _ = let m1 = pop (gst_get ()) in gst_put m1 private let salloc_common (#a:Type) (#rel:preorder a) (init:a) (mm:bool) :StackInline (mreference a rel) (requires (fun m -> is_stack_region (get_tip m))) (ensures (fun m0 s m1 -> is_stack_region (HS.frameOf s) /\ salloc_post init m0 s m1 /\ is_mm s == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel (get_tip m0) init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (get_hmap m0) (get_tip m0)) init mm; //AR: to prove that next_addr in tip's heap increases (it is part of mem_rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); //AR: to prove that rid_last_component of r.id is < rid_ctr gst_witness (ref_contains_pred r); gst_witness (region_contains_pred (HS.frameOf r)); r let salloc #_ #_ init = salloc_common init false let salloc_mm #_ #_ init = salloc_common init true let sfree #_ #_ r = let m0 = gst_get () in let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.get_tip m0)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1 let new_region r0 = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 None in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid let new_colored_region r0 c = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 (Some c) in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid private let ralloc_common (#a:Type) (#rel:preorder a) (i:rid) (init:a) (mm:bool) :ST (mreference a rel) (requires (fun m -> is_heap_color (color i) /\ m `contains_region` i)) (ensures (fun m0 r m1 -> ralloc_post i init m0 r m1 /\ is_mm r == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel i init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (HS.get_hmap m0) i) init mm; //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); gst_witness (ref_contains_pred r); gst_witness (region_contains_pred i); r let ralloc #_ #_ i init = if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init false let ralloc_mm #_ #_ i init = if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init true let rfree #_ #_ r = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); HS.lemma_rid_ctr_pred (); let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.frameOf r)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.HyperStack.ST.mreference a rel -> v: a -> FStar.HyperStack.ST.STL Prims.unit
FStar.HyperStack.ST.STL
[]
[]
[ "FStar.Preorder.preorder", "FStar.HyperStack.ST.mreference", "FStar.HyperStack.ST.gst_put", "Prims.unit", "FStar.Monotonic.Heap.lemma_next_addr_upd", "FStar.Map.sel", "FStar.Monotonic.HyperHeap.rid", "FStar.Monotonic.Heap.heap", "FStar.Monotonic.HyperStack.get_hmap", "FStar.Monotonic.HyperStack.frameOf", "FStar.Monotonic.HyperStack.as_ref", "FStar.Monotonic.Heap.lemma_upd_equals_upd_tot_for_contained_refs", "FStar.Monotonic.Heap.lemma_distinct_addrs_distinct_mm", "FStar.Monotonic.Heap.lemma_distinct_addrs_distinct_preorders", "FStar.Monotonic.HyperStack.mem", "FStar.Monotonic.HyperStack.upd_tot", "FStar.HyperStack.ST.gst_recall", "FStar.HyperStack.ST.ref_contains_pred", "FStar.HyperStack.ST.region_contains_pred", "FStar.HyperStack.ST.gst_get" ]
[]
false
true
false
false
false
let ( := ) #_ #_ r v =
let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); let m1 = HS.upd_tot m0 r v in Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_upd_equals_upd_tot_for_contained_refs ((get_hmap m0) `Map.sel` (HS.frameOf r)) (HS.as_ref r) v; Heap.lemma_next_addr_upd (Map.sel (HS.get_hmap m0) (HS.frameOf r)) (HS.as_ref r) v; gst_put m1
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.drgn
val drgn : Type0
val drgn : Type0
let drgn = d_hrid
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 17, "end_line": 317, "start_col": 0, "start_line": 317 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2 let witnessed p = W.witnessed mem_rel p (* TODO: we should derive these using DM4F *) let gst_get _ = admit () let gst_put _ = admit () let gst_witness _ = admit () let gst_recall _ = admit () let lemma_functoriality p q = W.lemma_witnessed_weakening mem_rel p q let same_refs_in_all_regions m0 m1 = same_refs_common contained_region m0 m1 let same_refs_in_stack_regions m0 m1 = same_refs_common contained_stack_region m0 m1 let same_refs_in_non_tip_regions m0 m1 = same_refs_common contained_non_tip_region m0 m1 let same_refs_in_non_tip_stack_regions m0 m1 = same_refs_common contained_non_tip_stack_region m0 m1 let lemma_same_refs_in_all_regions_intro _ _ = () let lemma_same_refs_in_all_regions_elim _ _ _ = () let lemma_same_refs_in_stack_regions_intro _ _ = () let lemma_same_refs_in_stack_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_regions_intro _ _ = () let lemma_same_refs_in_non_tip_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_stack_regions_intro _ _ = () let lemma_same_refs_in_non_tip_stack_regions_elim _ _ _ = () let lemma_equal_domains_trans _ _ _ = () let push_frame _ = let m0 = gst_get () in let m1 = HS.hs_push_frame m0 in gst_put m1 let pop_frame _ = let m1 = pop (gst_get ()) in gst_put m1 private let salloc_common (#a:Type) (#rel:preorder a) (init:a) (mm:bool) :StackInline (mreference a rel) (requires (fun m -> is_stack_region (get_tip m))) (ensures (fun m0 s m1 -> is_stack_region (HS.frameOf s) /\ salloc_post init m0 s m1 /\ is_mm s == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel (get_tip m0) init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (get_hmap m0) (get_tip m0)) init mm; //AR: to prove that next_addr in tip's heap increases (it is part of mem_rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); //AR: to prove that rid_last_component of r.id is < rid_ctr gst_witness (ref_contains_pred r); gst_witness (region_contains_pred (HS.frameOf r)); r let salloc #_ #_ init = salloc_common init false let salloc_mm #_ #_ init = salloc_common init true let sfree #_ #_ r = let m0 = gst_get () in let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.get_tip m0)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1 let new_region r0 = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 None in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid let new_colored_region r0 c = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 (Some c) in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid private let ralloc_common (#a:Type) (#rel:preorder a) (i:rid) (init:a) (mm:bool) :ST (mreference a rel) (requires (fun m -> is_heap_color (color i) /\ m `contains_region` i)) (ensures (fun m0 r m1 -> ralloc_post i init m0 r m1 /\ is_mm r == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel i init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (HS.get_hmap m0) i) init mm; //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); gst_witness (ref_contains_pred r); gst_witness (region_contains_pred i); r let ralloc #_ #_ i init = if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init false let ralloc_mm #_ #_ i init = if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init true let rfree #_ #_ r = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); HS.lemma_rid_ctr_pred (); let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.frameOf r)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1 let op_Colon_Equals #_ #_ r v = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); let m1 = HS.upd_tot m0 r v in Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_upd_equals_upd_tot_for_contained_refs (get_hmap m0 `Map.sel` (HS.frameOf r)) (HS.as_ref r) v; Heap.lemma_next_addr_upd (Map.sel (HS.get_hmap m0) (HS.frameOf r)) (HS.as_ref r) v; //next_addr in ref's rid heap remains same gst_put m1 let op_Bang #_ #_ r = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); Heap.lemma_sel_equals_sel_tot_for_contained_refs (get_hmap m0 `Map.sel` (HS.frameOf r)) (HS.as_ref r); HS.sel_tot m0 r let get _ = gst_get () let recall #_ #_ r = gst_recall (ref_contains_pred r); gst_recall (region_contains_pred (HS.frameOf r)) let recall_region i = if i <> HS.root then gst_recall (region_contains_pred i) let witness_region i = gst_witness (region_contains_pred i) let witness_hsref #_ #_ r = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); gst_witness (ref_contains_pred r) let mr_witness #r #_ #_ m p = recall m; let p_pred (#i:erid) (#a:Type) (#b:preorder a) (r:m_rref i a b) (p:mem_predicate) :mem_predicate = fun m -> m `contains` r /\ p m in gst_witness (p_pred m p); lemma_functoriality (p_pred m p) p let weaken_witness p q = let aux () :Lemma (requires ((forall h. p h ==> q h) /\ witnessed p)) (ensures (witnessed q)) = lemma_functoriality p q in FStar.Classical.move_requires aux () let testify (p:mem_predicate) = gst_recall p let testify_forall #c #p $s = W.lemma_witnessed_forall mem_rel p; gst_recall (fun h -> forall (x:c). p x h) let testify_forall_region_contains_pred #c #p $s = let p' (x:c) :mem_predicate = region_contains_pred (p x) in let s:squash (forall (x:c). witnessed (p' x)) = () in testify_forall s private let mem_rel_predicate (#a:Type0) (#rel:preorder a) (r:mreference a rel) (p:mem_predicate) :mem_predicate = let rid = HS.frameOf r in fun m -> (HS.rid_last_component rid < HS.get_rid_ctr m) /\ ( //will help us prove that a deallocated region remains deallocated (m `HS.contains` r /\ p m) \/ //the ref is contained and satisfies p (m `contains_region` rid /\ ~ (m `HS.contains_ref_in_its_region` r) /\ HS.as_addr r < Heap.next_addr (HS.get_hmap m `Map.sel` rid) /\ r `HS.unused_in` m) \/ //the ref is deallocated, but its region is contained and next_addr > addr_of ref (not (m `contains_region` rid))) //the region itself is not there let token_p #_ #_ r p = witnessed (mem_rel_predicate r p) let witness_p #_ #_ r p = gst_recall (ref_contains_pred r); gst_recall (region_contains_pred (HS.frameOf r)); HS.lemma_next_addr_contained_refs_addr (); gst_witness (mem_rel_predicate r p) let recall_p #_ #_ r p = gst_recall (ref_contains_pred r); gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (mem_rel_predicate r p) let token_functoriality #_ #_ r p q = lemma_functoriality (mem_rel_predicate r p) (mem_rel_predicate r q) let lemma_witnessed_constant p = W.lemma_witnessed_constant mem_rel p let lemma_witnessed_nested p = assert_norm (witnessed (fun (m:mem) -> witnessed p) == W.witnessed mem_rel (fun (m:mem) -> W.witnessed mem_rel p)); assert_norm (witnessed p == W.witnessed mem_rel p); W.lemma_witnessed_nested mem_rel p let lemma_witnessed_and p q = W.lemma_witnessed_and mem_rel p q let lemma_witnessed_or p q = W.lemma_witnessed_or mem_rel p q let lemma_witnessed_impl p q = W.lemma_witnessed_impl mem_rel p q let lemma_witnessed_forall #_ p = W.lemma_witnessed_forall mem_rel p let lemma_witnessed_exists #_ p = W.lemma_witnessed_exists mem_rel p
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.HyperStack.ST.d_hrid" ]
[]
false
false
false
true
true
let drgn =
d_hrid
false
FStar.HyperStack.ST.fst
FStar.HyperStack.ST.witness_hsref
val witness_hsref (#a:Type) (#rel:preorder a) (r:HS.mreference a rel) :ST unit (fun h0 -> h0 `HS.contains` r) (fun h0 _ h1 -> h0 == h1 /\ witnessed (ref_contains_pred r))
val witness_hsref (#a:Type) (#rel:preorder a) (r:HS.mreference a rel) :ST unit (fun h0 -> h0 `HS.contains` r) (fun h0 _ h1 -> h0 == h1 /\ witnessed (ref_contains_pred r))
let witness_hsref #_ #_ r = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); gst_witness (ref_contains_pred r)
{ "file_name": "ulib/FStar.HyperStack.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 35, "end_line": 249, "start_col": 0, "start_line": 246 }
(* 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.HyperStack.ST open FStar.HyperStack module W = FStar.Monotonic.Witnessed module HS = FStar.HyperStack open FStar.Preorder (* Eternal regions remain contained *) private let eternal_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (HS.is_heap_color (color r)); (m1 `contains_region` r)} (HS.is_eternal_region_hs r /\ m1 `contains_region` r) ==> m2 `contains_region` r (* rid counter increases monotonically *) private let rid_ctr_pred (m1 m2:mem) :Type0 = get_rid_ctr m1 <= get_rid_ctr m2 (* * A region r, that is: * (a) not contained in m1, and * (b) has rid last component less than m1.rid_ctr * * remains not contained in m2 *) private let rid_last_component_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} ((~ (m1 `contains_region` r)) /\ rid_last_component r < get_rid_ctr m1) ==> (~ (m2 `contains_region` r)) (* Predicate for eternal refs *) private let eternal_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel). {:pattern (m1 `HS.contains` r)} (is_mm r) \/ (((m1 `HS.contains` r) /\ (HS.is_eternal_region_hs (frameOf r) \/ m2 `contains_region` (HS.frameOf r))) ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r))) (* * Predicate for next ref address in a region's heap * For all regions, their next_addr increases monotonically (or the region ceases to exist) *) private let next_ref_addr_in_a_region_pred (m1 m2:mem) :Type0 = forall (r:HS.rid).{:pattern (m1 `contains_region` r)} (m1 `contains_region` r) ==> (if m2 `contains_region` r then let h1 = Map.sel (HS.get_hmap m1) r in let h2 = Map.sel (HS.get_hmap m2) r in Heap.next_addr h1 <= Heap.next_addr h2 else True) (* Predicate that an unused ref whose addr is less than the next addr remains unused *) private let unused_ref_next_addr_pred (m1 m2:mem) :Type0 = forall (rid:HS.rid).{:pattern (m1 `contains_region` rid)} (m1 `contains_region` rid) ==> (let h1 = Map.sel (HS.get_hmap m1) rid in (forall (a:Type0) (rel:preorder a) (r:HS.mreference a rel).{:pattern (r `HS.unused_in` m1)} (HS.frameOf r == rid /\ r `HS.unused_in` m1 /\ HS.as_addr r < Heap.next_addr h1) ==> (r `HS.unused_in` m2))) (* Predicate for mm refs *) private let mm_refs_pred (m1 m2:mem) :Type0 = forall (a:Type) (rel:preorder a) (r:HS.mreference a rel).{:pattern (m1 `HS.contains` r)} (not (is_mm r)) \/ (m1 `HS.contains` r ==> (m2 `HS.contains` r /\ rel (HS.sel m1 r) (HS.sel m2 r) \/ r `HS.unused_in` m2)) (* The preorder is the conjunction of above predicates *) let mem_rel :preorder mem = HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); fun (m1 m2:mem) -> eternal_region_pred m1 m2 /\ rid_ctr_pred m1 m2 /\ rid_last_component_pred m1 m2 /\ eternal_refs_pred m1 m2 /\ next_ref_addr_in_a_region_pred m1 m2 /\ unused_ref_next_addr_pred m1 m2 /\ mm_refs_pred m1 m2 (* Predicates that we will witness with regions and refs *) let region_contains_pred r = fun m -> (not (HS.is_eternal_region_hs r)) \/ m `contains_region` r let ref_contains_pred #_ #_ r = fun m -> let rid = HS.frameOf r in rid_last_component rid < get_rid_ctr m /\ (m `contains_region` rid ==> ( (HS.as_addr r < Heap.next_addr (Map.sel (HS.get_hmap m) rid)) /\ (HS.is_mm r ==> (m `HS.contains` r \/ r `HS.unused_in` m)) /\ ((not (HS.is_mm r)) ==> m `HS.contains` r))) let stable p = forall (h1:mem) (h2:mem).{:pattern (mem_rel h1 h2)} (p h1 /\ mem_rel h1 h2) ==> p h2 let witnessed p = W.witnessed mem_rel p (* TODO: we should derive these using DM4F *) let gst_get _ = admit () let gst_put _ = admit () let gst_witness _ = admit () let gst_recall _ = admit () let lemma_functoriality p q = W.lemma_witnessed_weakening mem_rel p q let same_refs_in_all_regions m0 m1 = same_refs_common contained_region m0 m1 let same_refs_in_stack_regions m0 m1 = same_refs_common contained_stack_region m0 m1 let same_refs_in_non_tip_regions m0 m1 = same_refs_common contained_non_tip_region m0 m1 let same_refs_in_non_tip_stack_regions m0 m1 = same_refs_common contained_non_tip_stack_region m0 m1 let lemma_same_refs_in_all_regions_intro _ _ = () let lemma_same_refs_in_all_regions_elim _ _ _ = () let lemma_same_refs_in_stack_regions_intro _ _ = () let lemma_same_refs_in_stack_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_regions_intro _ _ = () let lemma_same_refs_in_non_tip_regions_elim _ _ _ = () let lemma_same_refs_in_non_tip_stack_regions_intro _ _ = () let lemma_same_refs_in_non_tip_stack_regions_elim _ _ _ = () let lemma_equal_domains_trans _ _ _ = () let push_frame _ = let m0 = gst_get () in let m1 = HS.hs_push_frame m0 in gst_put m1 let pop_frame _ = let m1 = pop (gst_get ()) in gst_put m1 private let salloc_common (#a:Type) (#rel:preorder a) (init:a) (mm:bool) :StackInline (mreference a rel) (requires (fun m -> is_stack_region (get_tip m))) (ensures (fun m0 s m1 -> is_stack_region (HS.frameOf s) /\ salloc_post init m0 s m1 /\ is_mm s == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel (get_tip m0) init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (get_hmap m0) (get_tip m0)) init mm; //AR: to prove that next_addr in tip's heap increases (it is part of mem_rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); //AR: to prove that rid_last_component of r.id is < rid_ctr gst_witness (ref_contains_pred r); gst_witness (region_contains_pred (HS.frameOf r)); r let salloc #_ #_ init = salloc_common init false let salloc_mm #_ #_ init = salloc_common init true let sfree #_ #_ r = let m0 = gst_get () in let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.get_tip m0)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1 let new_region r0 = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 None in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid let new_colored_region r0 c = if r0 <> HS.root then gst_recall (region_contains_pred r0); //recall containment of r0 HS.lemma_rid_ctr_pred (); let m0 = gst_get () in let new_rid, m1 = HS.new_eternal_region m0 r0 (Some c) in gst_put m1; gst_witness (region_contains_pred new_rid); new_rid private let ralloc_common (#a:Type) (#rel:preorder a) (i:rid) (init:a) (mm:bool) :ST (mreference a rel) (requires (fun m -> is_heap_color (color i) /\ m `contains_region` i)) (ensures (fun m0 r m1 -> ralloc_post i init m0 r m1 /\ is_mm r == mm)) = let m0 = gst_get () in let r, m1 = HS.alloc rel i init mm m0 in Heap.lemma_next_addr_alloc rel (Map.sel (HS.get_hmap m0) i) init mm; //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1; assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); HS.lemma_rid_ctr_pred (); gst_witness (ref_contains_pred r); gst_witness (region_contains_pred i); r let ralloc #_ #_ i init = if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init false let ralloc_mm #_ #_ i init = if i <> HS.root then gst_recall (region_contains_pred i); ralloc_common i init true let rfree #_ #_ r = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); HS.lemma_rid_ctr_pred (); let m1 = HS.free r m0 in assert (Set.equal (Map.domain (get_hmap m0)) (Map.domain (get_hmap m1))); Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_next_addr_free_mm (Map.sel (HS.get_hmap m0) (HS.frameOf r)) (HS.as_ref r); //AR: to prove that next_addr in tip's heap remains same (to satisfy the predicate in mm rel) gst_put m1 let op_Colon_Equals #_ #_ r v = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); let m1 = HS.upd_tot m0 r v in Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_upd_equals_upd_tot_for_contained_refs (get_hmap m0 `Map.sel` (HS.frameOf r)) (HS.as_ref r) v; Heap.lemma_next_addr_upd (Map.sel (HS.get_hmap m0) (HS.frameOf r)) (HS.as_ref r) v; //next_addr in ref's rid heap remains same gst_put m1 let op_Bang #_ #_ r = let m0 = gst_get () in gst_recall (region_contains_pred (HS.frameOf r)); gst_recall (ref_contains_pred r); Heap.lemma_sel_equals_sel_tot_for_contained_refs (get_hmap m0 `Map.sel` (HS.frameOf r)) (HS.as_ref r); HS.sel_tot m0 r let get _ = gst_get () let recall #_ #_ r = gst_recall (ref_contains_pred r); gst_recall (region_contains_pred (HS.frameOf r)) let recall_region i = if i <> HS.root then gst_recall (region_contains_pred i) let witness_region i = gst_witness (region_contains_pred i)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Map.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "FStar.HyperStack.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Monotonic.HyperStack.mreference a rel -> FStar.HyperStack.ST.ST Prims.unit
FStar.HyperStack.ST.ST
[]
[]
[ "FStar.Preorder.preorder", "FStar.Monotonic.HyperStack.mreference", "FStar.HyperStack.ST.gst_witness", "FStar.HyperStack.ST.ref_contains_pred", "Prims.unit", "FStar.Monotonic.HyperStack.lemma_next_addr_contained_refs_addr", "FStar.Monotonic.HyperStack.lemma_rid_ctr_pred" ]
[]
false
true
false
false
false
let witness_hsref #_ #_ r =
HS.lemma_rid_ctr_pred (); HS.lemma_next_addr_contained_refs_addr (); gst_witness (ref_contains_pred r)
false