file_name
stringlengths
5
52
name
stringlengths
4
95
original_source_type
stringlengths
0
23k
source_type
stringlengths
9
23k
source_definition
stringlengths
9
57.9k
source
dict
source_range
dict
file_context
stringlengths
0
721k
dependencies
dict
opens_and_abbrevs
listlengths
2
94
vconfig
dict
interleaved
bool
1 class
verbose_type
stringlengths
1
7.42k
effect
stringclasses
118 values
effect_flags
sequencelengths
0
2
mutual_with
sequencelengths
0
11
ideal_premises
sequencelengths
0
236
proof_features
sequencelengths
0
1
is_simple_lemma
bool
2 classes
is_div
bool
2 classes
is_proof
bool
2 classes
is_simply_typed
bool
2 classes
is_type
bool
2 classes
partial_definition
stringlengths
5
3.99k
completed_definiton
stringlengths
1
1.63M
isa_cross_project_example
bool
1 class
FStar.UInt32.fsti
FStar.UInt32.op_Less_Less_Hat
val op_Less_Less_Hat : a: FStar.UInt32.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t
let op_Less_Less_Hat = shift_left
{ "file_name": "ulib/FStar.UInt32.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 40, "end_line": 330, "start_col": 7, "start_line": 330 }
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt32 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) unfold let n = 32 /// For FStar.UIntN.fstp: anything that you fix/update here should be /// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of /// this module. /// /// Except, as compared to [FStar.IntN.fstp], here: /// - every occurrence of [int_t] has been replaced with [uint_t] /// - every occurrence of [@%] has been replaced with [%]. /// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers /// This module provides an abstract type for machine integers of a /// given signedness and width. The interface is designed to be safe /// with respect to arithmetic underflow and overflow. /// Note, we have attempted several times to re-design this module to /// make it more amenable to normalization and to impose less overhead /// on the SMT solver when reasoning about machine integer /// arithmetic. The following github issue reports on the current /// status of that work. /// /// https://github.com/FStarLang/FStar/issues/1757 open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (** Abstract type of machine integers, with an underlying representation using a bounded mathematical integer *) new val t : eqtype (** A coercion that projects a bounded mathematical integer from a machine integer *) val v (x:t) : Tot (uint_t n) (** A coercion that injects a bounded mathematical integers into a machine integer *) val uint_to_t (x:uint_t n) : Pure t (requires True) (ensures (fun y -> v y = x)) (** Injection/projection inverse *) val uv_inv (x : t) : Lemma (ensures (uint_to_t (v x) == x)) [SMTPat (v x)] (** Projection/injection inverse *) val vu_inv (x : uint_t n) : Lemma (ensures (v (uint_to_t x) == x)) [SMTPat (uint_to_t x)] (** An alternate form of the injectivity of the [v] projection *) val v_inj (x1 x2: t): Lemma (requires (v x1 == v x2)) (ensures (x1 == x2)) (** Constants 0 and 1 *) val zero : x:t{v x = 0} val one : x:t{v x = 1} (**** Addition primitives *) (** Bounds-respecting addition The precondition enforces that the sum does not overflow, expressing the bound as an addition on mathematical integers *) val add (a:t) (b:t) : Pure t (requires (size (v a + v b) n)) (ensures (fun c -> v a + v b = v c)) (** Underspecified, possibly overflowing addition: The postcondition only enures that the result is the sum of the arguments in case there is no overflow *) val add_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a + v b) n ==> v a + v b = v c)) (** Addition modulo [2^n] Machine integers can always be added, but the postcondition is now in terms of addition modulo [2^n] on mathematical integers *) val add_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c)) (**** Subtraction primitives *) (** Bounds-respecting subtraction The precondition enforces that the difference does not underflow, expressing the bound as a difference on mathematical integers *) val sub (a:t) (b:t) : Pure t (requires (size (v a - v b) n)) (ensures (fun c -> v a - v b = v c)) (** Underspecified, possibly overflowing subtraction: The postcondition only enures that the result is the difference of the arguments in case there is no underflow *) val sub_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a - v b) n ==> v a - v b = v c)) (** Subtraction modulo [2^n] Machine integers can always be subtractd, but the postcondition is now in terms of subtraction modulo [2^n] on mathematical integers *) val sub_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c)) (**** Multiplication primitives *) (** Bounds-respecting multiplication The precondition enforces that the product does not overflow, expressing the bound as a product on mathematical integers *) val mul (a:t) (b:t) : Pure t (requires (size (v a * v b) n)) (ensures (fun c -> v a * v b = v c)) (** Underspecified, possibly overflowing product The postcondition only enures that the result is the product of the arguments in case there is no overflow *) val mul_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a * v b) n ==> v a * v b = v c)) (** Multiplication modulo [2^n] Machine integers can always be multiplied, but the postcondition is now in terms of product modulo [2^n] on mathematical integers *) val mul_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c)) (**** Division primitives *) (** Euclidean division of [a] and [b], with [b] non-zero *) val div (a:t) (b:t{v b <> 0}) : Pure t (requires (True)) (ensures (fun c -> v a / v b = v c)) (**** Modulo primitives *) (** Euclidean remainder The result is the modulus of [a] with respect to a non-zero [b] *) val rem (a:t) (b:t{v b <> 0}) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c)) (**** Bitwise operators *) /// Also see FStar.BV (** Bitwise logical conjunction *) val logand (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logand` v y = v z)) (** Bitwise logical exclusive-or *) val logxor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logxor` v y == v z)) (** Bitwise logical disjunction *) val logor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logor` v y == v z)) (** Bitwise logical negation *) val lognot (x:t) : Pure t (requires True) (ensures (fun z -> lognot (v x) == v z)) (**** Shift operators *) (** Shift right with zero fill, shifting at most the integer width *) val shift_right (a:t) (s:t) : Pure t (requires (v s < n)) (ensures (fun c -> FStar.UInt.shift_right (v a) (v s) = v c)) (** Shift left with zero fill, shifting at most the integer width *) val shift_left (a:t) (s:t) : Pure t (requires (v s < n)) (ensures (fun c -> FStar.UInt.shift_left (v a) (v s) = v c)) (**** Comparison operators *) (** Equality Note, it is safe to also use the polymorphic decidable equality operator [=] *) let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b) (** Greater than *) let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b) (** Greater than or equal *) let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b) (** Less than *) let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b) (** Less than or equal *) let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b) (** Unary negation *) inline_for_extraction let minus (a:t) = add_mod (lognot a) (uint_to_t 1) (** The maximum shift value for this type, i.e. its width minus one, as an *) inline_for_extraction let n_minus_one = uint_to_t (n - 1) #set-options "--z3rlimit 80 --initial_fuel 1 --max_fuel 1" (** A constant-time way to compute the equality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=2e60bb395c1f589a398ec606d611132ef9ef764b Note, the branching on [a=b] is just for proof-purposes. *) [@ CNoInline ] let eq_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\ (v a <> v b ==> v c = 0))) = let x = logxor a b in let minus_x = minus x in let x_or_minus_x = logor x minus_x in let xnx = shift_right x_or_minus_x n_minus_one in let c = sub_mod xnx (uint_to_t 1) in if a = b then begin logxor_self (v a); lognot_lemma_1 #n; logor_lemma_1 (v x); assert (v x = 0 /\ v minus_x = 0 /\ v x_or_minus_x = 0 /\ v xnx = 0); assert (v c = ones n) end else begin logxor_neq_nonzero (v a) (v b); lemma_msb_pow2 #n (v (lognot x)); lemma_msb_pow2 #n (v minus_x); lemma_minus_zero #n (v x); assert (v c = FStar.UInt.zero n) end; c private val lemma_sub_msbs (a:t) (b:t) : Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b)))) (** A constant-time way to compute the [>=] inequality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=0a483a9b431d87eca1b275463c632f8d5551978a *) [@ CNoInline ] let gte_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\ (v a < v b ==> v c = 0))) = let x = a in let y = b in let x_xor_y = logxor x y in let x_sub_y = sub_mod x y in let x_sub_y_xor_y = logxor x_sub_y y in let q = logor x_xor_y x_sub_y_xor_y in let x_xor_q = logxor x q in let x_xor_q_ = shift_right x_xor_q n_minus_one in let c = sub_mod x_xor_q_ (uint_to_t 1) in lemma_sub_msbs x y; lemma_msb_gte (v x) (v y); lemma_msb_gte (v y) (v x); c #reset-options (*** Infix notations *) unfold let op_Plus_Hat = add unfold let op_Plus_Question_Hat = add_underspec unfold let op_Plus_Percent_Hat = add_mod unfold let op_Subtraction_Hat = sub unfold let op_Subtraction_Question_Hat = sub_underspec unfold let op_Subtraction_Percent_Hat = sub_mod unfold let op_Star_Hat = mul unfold let op_Star_Question_Hat = mul_underspec unfold let op_Star_Percent_Hat = mul_mod unfold let op_Slash_Hat = div unfold let op_Percent_Hat = rem unfold let op_Hat_Hat = logxor unfold let op_Amp_Hat = logand
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt32.fsti" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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
a: FStar.UInt32.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t
Prims.Pure
[]
[]
[ "FStar.UInt32.shift_left" ]
[]
false
false
false
false
false
let op_Less_Less_Hat =
shift_left
false
FStar.UInt32.fsti
FStar.UInt32.op_Hat_Hat
val op_Hat_Hat : x: FStar.UInt32.t -> y: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t
let op_Hat_Hat = logxor
{ "file_name": "ulib/FStar.UInt32.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 30, "end_line": 327, "start_col": 7, "start_line": 327 }
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt32 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) unfold let n = 32 /// For FStar.UIntN.fstp: anything that you fix/update here should be /// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of /// this module. /// /// Except, as compared to [FStar.IntN.fstp], here: /// - every occurrence of [int_t] has been replaced with [uint_t] /// - every occurrence of [@%] has been replaced with [%]. /// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers /// This module provides an abstract type for machine integers of a /// given signedness and width. The interface is designed to be safe /// with respect to arithmetic underflow and overflow. /// Note, we have attempted several times to re-design this module to /// make it more amenable to normalization and to impose less overhead /// on the SMT solver when reasoning about machine integer /// arithmetic. The following github issue reports on the current /// status of that work. /// /// https://github.com/FStarLang/FStar/issues/1757 open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (** Abstract type of machine integers, with an underlying representation using a bounded mathematical integer *) new val t : eqtype (** A coercion that projects a bounded mathematical integer from a machine integer *) val v (x:t) : Tot (uint_t n) (** A coercion that injects a bounded mathematical integers into a machine integer *) val uint_to_t (x:uint_t n) : Pure t (requires True) (ensures (fun y -> v y = x)) (** Injection/projection inverse *) val uv_inv (x : t) : Lemma (ensures (uint_to_t (v x) == x)) [SMTPat (v x)] (** Projection/injection inverse *) val vu_inv (x : uint_t n) : Lemma (ensures (v (uint_to_t x) == x)) [SMTPat (uint_to_t x)] (** An alternate form of the injectivity of the [v] projection *) val v_inj (x1 x2: t): Lemma (requires (v x1 == v x2)) (ensures (x1 == x2)) (** Constants 0 and 1 *) val zero : x:t{v x = 0} val one : x:t{v x = 1} (**** Addition primitives *) (** Bounds-respecting addition The precondition enforces that the sum does not overflow, expressing the bound as an addition on mathematical integers *) val add (a:t) (b:t) : Pure t (requires (size (v a + v b) n)) (ensures (fun c -> v a + v b = v c)) (** Underspecified, possibly overflowing addition: The postcondition only enures that the result is the sum of the arguments in case there is no overflow *) val add_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a + v b) n ==> v a + v b = v c)) (** Addition modulo [2^n] Machine integers can always be added, but the postcondition is now in terms of addition modulo [2^n] on mathematical integers *) val add_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c)) (**** Subtraction primitives *) (** Bounds-respecting subtraction The precondition enforces that the difference does not underflow, expressing the bound as a difference on mathematical integers *) val sub (a:t) (b:t) : Pure t (requires (size (v a - v b) n)) (ensures (fun c -> v a - v b = v c)) (** Underspecified, possibly overflowing subtraction: The postcondition only enures that the result is the difference of the arguments in case there is no underflow *) val sub_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a - v b) n ==> v a - v b = v c)) (** Subtraction modulo [2^n] Machine integers can always be subtractd, but the postcondition is now in terms of subtraction modulo [2^n] on mathematical integers *) val sub_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c)) (**** Multiplication primitives *) (** Bounds-respecting multiplication The precondition enforces that the product does not overflow, expressing the bound as a product on mathematical integers *) val mul (a:t) (b:t) : Pure t (requires (size (v a * v b) n)) (ensures (fun c -> v a * v b = v c)) (** Underspecified, possibly overflowing product The postcondition only enures that the result is the product of the arguments in case there is no overflow *) val mul_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a * v b) n ==> v a * v b = v c)) (** Multiplication modulo [2^n] Machine integers can always be multiplied, but the postcondition is now in terms of product modulo [2^n] on mathematical integers *) val mul_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c)) (**** Division primitives *) (** Euclidean division of [a] and [b], with [b] non-zero *) val div (a:t) (b:t{v b <> 0}) : Pure t (requires (True)) (ensures (fun c -> v a / v b = v c)) (**** Modulo primitives *) (** Euclidean remainder The result is the modulus of [a] with respect to a non-zero [b] *) val rem (a:t) (b:t{v b <> 0}) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c)) (**** Bitwise operators *) /// Also see FStar.BV (** Bitwise logical conjunction *) val logand (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logand` v y = v z)) (** Bitwise logical exclusive-or *) val logxor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logxor` v y == v z)) (** Bitwise logical disjunction *) val logor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logor` v y == v z)) (** Bitwise logical negation *) val lognot (x:t) : Pure t (requires True) (ensures (fun z -> lognot (v x) == v z)) (**** Shift operators *) (** Shift right with zero fill, shifting at most the integer width *) val shift_right (a:t) (s:t) : Pure t (requires (v s < n)) (ensures (fun c -> FStar.UInt.shift_right (v a) (v s) = v c)) (** Shift left with zero fill, shifting at most the integer width *) val shift_left (a:t) (s:t) : Pure t (requires (v s < n)) (ensures (fun c -> FStar.UInt.shift_left (v a) (v s) = v c)) (**** Comparison operators *) (** Equality Note, it is safe to also use the polymorphic decidable equality operator [=] *) let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b) (** Greater than *) let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b) (** Greater than or equal *) let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b) (** Less than *) let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b) (** Less than or equal *) let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b) (** Unary negation *) inline_for_extraction let minus (a:t) = add_mod (lognot a) (uint_to_t 1) (** The maximum shift value for this type, i.e. its width minus one, as an *) inline_for_extraction let n_minus_one = uint_to_t (n - 1) #set-options "--z3rlimit 80 --initial_fuel 1 --max_fuel 1" (** A constant-time way to compute the equality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=2e60bb395c1f589a398ec606d611132ef9ef764b Note, the branching on [a=b] is just for proof-purposes. *) [@ CNoInline ] let eq_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\ (v a <> v b ==> v c = 0))) = let x = logxor a b in let minus_x = minus x in let x_or_minus_x = logor x minus_x in let xnx = shift_right x_or_minus_x n_minus_one in let c = sub_mod xnx (uint_to_t 1) in if a = b then begin logxor_self (v a); lognot_lemma_1 #n; logor_lemma_1 (v x); assert (v x = 0 /\ v minus_x = 0 /\ v x_or_minus_x = 0 /\ v xnx = 0); assert (v c = ones n) end else begin logxor_neq_nonzero (v a) (v b); lemma_msb_pow2 #n (v (lognot x)); lemma_msb_pow2 #n (v minus_x); lemma_minus_zero #n (v x); assert (v c = FStar.UInt.zero n) end; c private val lemma_sub_msbs (a:t) (b:t) : Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b)))) (** A constant-time way to compute the [>=] inequality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=0a483a9b431d87eca1b275463c632f8d5551978a *) [@ CNoInline ] let gte_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\ (v a < v b ==> v c = 0))) = let x = a in let y = b in let x_xor_y = logxor x y in let x_sub_y = sub_mod x y in let x_sub_y_xor_y = logxor x_sub_y y in let q = logor x_xor_y x_sub_y_xor_y in let x_xor_q = logxor x q in let x_xor_q_ = shift_right x_xor_q n_minus_one in let c = sub_mod x_xor_q_ (uint_to_t 1) in lemma_sub_msbs x y; lemma_msb_gte (v x) (v y); lemma_msb_gte (v y) (v x); c #reset-options (*** Infix notations *) unfold let op_Plus_Hat = add unfold let op_Plus_Question_Hat = add_underspec unfold let op_Plus_Percent_Hat = add_mod unfold let op_Subtraction_Hat = sub unfold let op_Subtraction_Question_Hat = sub_underspec unfold let op_Subtraction_Percent_Hat = sub_mod unfold let op_Star_Hat = mul unfold let op_Star_Question_Hat = mul_underspec unfold let op_Star_Percent_Hat = mul_mod unfold let op_Slash_Hat = div
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt32.fsti" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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
x: FStar.UInt32.t -> y: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t
Prims.Pure
[]
[]
[ "FStar.UInt32.logxor" ]
[]
false
false
false
false
false
let op_Hat_Hat =
logxor
false
FStar.UInt32.fsti
FStar.UInt32.op_Equals_Hat
val op_Equals_Hat : a: FStar.UInt32.t -> b: FStar.UInt32.t -> Prims.bool
let op_Equals_Hat = eq
{ "file_name": "ulib/FStar.UInt32.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 29, "end_line": 332, "start_col": 7, "start_line": 332 }
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt32 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) unfold let n = 32 /// For FStar.UIntN.fstp: anything that you fix/update here should be /// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of /// this module. /// /// Except, as compared to [FStar.IntN.fstp], here: /// - every occurrence of [int_t] has been replaced with [uint_t] /// - every occurrence of [@%] has been replaced with [%]. /// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers /// This module provides an abstract type for machine integers of a /// given signedness and width. The interface is designed to be safe /// with respect to arithmetic underflow and overflow. /// Note, we have attempted several times to re-design this module to /// make it more amenable to normalization and to impose less overhead /// on the SMT solver when reasoning about machine integer /// arithmetic. The following github issue reports on the current /// status of that work. /// /// https://github.com/FStarLang/FStar/issues/1757 open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (** Abstract type of machine integers, with an underlying representation using a bounded mathematical integer *) new val t : eqtype (** A coercion that projects a bounded mathematical integer from a machine integer *) val v (x:t) : Tot (uint_t n) (** A coercion that injects a bounded mathematical integers into a machine integer *) val uint_to_t (x:uint_t n) : Pure t (requires True) (ensures (fun y -> v y = x)) (** Injection/projection inverse *) val uv_inv (x : t) : Lemma (ensures (uint_to_t (v x) == x)) [SMTPat (v x)] (** Projection/injection inverse *) val vu_inv (x : uint_t n) : Lemma (ensures (v (uint_to_t x) == x)) [SMTPat (uint_to_t x)] (** An alternate form of the injectivity of the [v] projection *) val v_inj (x1 x2: t): Lemma (requires (v x1 == v x2)) (ensures (x1 == x2)) (** Constants 0 and 1 *) val zero : x:t{v x = 0} val one : x:t{v x = 1} (**** Addition primitives *) (** Bounds-respecting addition The precondition enforces that the sum does not overflow, expressing the bound as an addition on mathematical integers *) val add (a:t) (b:t) : Pure t (requires (size (v a + v b) n)) (ensures (fun c -> v a + v b = v c)) (** Underspecified, possibly overflowing addition: The postcondition only enures that the result is the sum of the arguments in case there is no overflow *) val add_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a + v b) n ==> v a + v b = v c)) (** Addition modulo [2^n] Machine integers can always be added, but the postcondition is now in terms of addition modulo [2^n] on mathematical integers *) val add_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c)) (**** Subtraction primitives *) (** Bounds-respecting subtraction The precondition enforces that the difference does not underflow, expressing the bound as a difference on mathematical integers *) val sub (a:t) (b:t) : Pure t (requires (size (v a - v b) n)) (ensures (fun c -> v a - v b = v c)) (** Underspecified, possibly overflowing subtraction: The postcondition only enures that the result is the difference of the arguments in case there is no underflow *) val sub_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a - v b) n ==> v a - v b = v c)) (** Subtraction modulo [2^n] Machine integers can always be subtractd, but the postcondition is now in terms of subtraction modulo [2^n] on mathematical integers *) val sub_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c)) (**** Multiplication primitives *) (** Bounds-respecting multiplication The precondition enforces that the product does not overflow, expressing the bound as a product on mathematical integers *) val mul (a:t) (b:t) : Pure t (requires (size (v a * v b) n)) (ensures (fun c -> v a * v b = v c)) (** Underspecified, possibly overflowing product The postcondition only enures that the result is the product of the arguments in case there is no overflow *) val mul_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a * v b) n ==> v a * v b = v c)) (** Multiplication modulo [2^n] Machine integers can always be multiplied, but the postcondition is now in terms of product modulo [2^n] on mathematical integers *) val mul_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c)) (**** Division primitives *) (** Euclidean division of [a] and [b], with [b] non-zero *) val div (a:t) (b:t{v b <> 0}) : Pure t (requires (True)) (ensures (fun c -> v a / v b = v c)) (**** Modulo primitives *) (** Euclidean remainder The result is the modulus of [a] with respect to a non-zero [b] *) val rem (a:t) (b:t{v b <> 0}) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c)) (**** Bitwise operators *) /// Also see FStar.BV (** Bitwise logical conjunction *) val logand (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logand` v y = v z)) (** Bitwise logical exclusive-or *) val logxor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logxor` v y == v z)) (** Bitwise logical disjunction *) val logor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logor` v y == v z)) (** Bitwise logical negation *) val lognot (x:t) : Pure t (requires True) (ensures (fun z -> lognot (v x) == v z)) (**** Shift operators *) (** Shift right with zero fill, shifting at most the integer width *) val shift_right (a:t) (s:t) : Pure t (requires (v s < n)) (ensures (fun c -> FStar.UInt.shift_right (v a) (v s) = v c)) (** Shift left with zero fill, shifting at most the integer width *) val shift_left (a:t) (s:t) : Pure t (requires (v s < n)) (ensures (fun c -> FStar.UInt.shift_left (v a) (v s) = v c)) (**** Comparison operators *) (** Equality Note, it is safe to also use the polymorphic decidable equality operator [=] *) let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b) (** Greater than *) let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b) (** Greater than or equal *) let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b) (** Less than *) let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b) (** Less than or equal *) let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b) (** Unary negation *) inline_for_extraction let minus (a:t) = add_mod (lognot a) (uint_to_t 1) (** The maximum shift value for this type, i.e. its width minus one, as an *) inline_for_extraction let n_minus_one = uint_to_t (n - 1) #set-options "--z3rlimit 80 --initial_fuel 1 --max_fuel 1" (** A constant-time way to compute the equality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=2e60bb395c1f589a398ec606d611132ef9ef764b Note, the branching on [a=b] is just for proof-purposes. *) [@ CNoInline ] let eq_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\ (v a <> v b ==> v c = 0))) = let x = logxor a b in let minus_x = minus x in let x_or_minus_x = logor x minus_x in let xnx = shift_right x_or_minus_x n_minus_one in let c = sub_mod xnx (uint_to_t 1) in if a = b then begin logxor_self (v a); lognot_lemma_1 #n; logor_lemma_1 (v x); assert (v x = 0 /\ v minus_x = 0 /\ v x_or_minus_x = 0 /\ v xnx = 0); assert (v c = ones n) end else begin logxor_neq_nonzero (v a) (v b); lemma_msb_pow2 #n (v (lognot x)); lemma_msb_pow2 #n (v minus_x); lemma_minus_zero #n (v x); assert (v c = FStar.UInt.zero n) end; c private val lemma_sub_msbs (a:t) (b:t) : Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b)))) (** A constant-time way to compute the [>=] inequality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=0a483a9b431d87eca1b275463c632f8d5551978a *) [@ CNoInline ] let gte_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\ (v a < v b ==> v c = 0))) = let x = a in let y = b in let x_xor_y = logxor x y in let x_sub_y = sub_mod x y in let x_sub_y_xor_y = logxor x_sub_y y in let q = logor x_xor_y x_sub_y_xor_y in let x_xor_q = logxor x q in let x_xor_q_ = shift_right x_xor_q n_minus_one in let c = sub_mod x_xor_q_ (uint_to_t 1) in lemma_sub_msbs x y; lemma_msb_gte (v x) (v y); lemma_msb_gte (v y) (v x); c #reset-options (*** Infix notations *) unfold let op_Plus_Hat = add unfold let op_Plus_Question_Hat = add_underspec unfold let op_Plus_Percent_Hat = add_mod unfold let op_Subtraction_Hat = sub unfold let op_Subtraction_Question_Hat = sub_underspec unfold let op_Subtraction_Percent_Hat = sub_mod unfold let op_Star_Hat = mul unfold let op_Star_Question_Hat = mul_underspec unfold let op_Star_Percent_Hat = mul_mod unfold let op_Slash_Hat = div unfold let op_Percent_Hat = rem unfold let op_Hat_Hat = logxor unfold let op_Amp_Hat = logand unfold let op_Bar_Hat = logor unfold let op_Less_Less_Hat = shift_left
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt32.fsti" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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
a: FStar.UInt32.t -> b: FStar.UInt32.t -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.eq" ]
[]
false
false
false
true
false
let op_Equals_Hat =
eq
false
FStar.UInt32.fsti
FStar.UInt32.op_Bar_Hat
val op_Bar_Hat : x: FStar.UInt32.t -> y: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t
let op_Bar_Hat = logor
{ "file_name": "ulib/FStar.UInt32.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 29, "end_line": 329, "start_col": 7, "start_line": 329 }
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt32 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) unfold let n = 32 /// For FStar.UIntN.fstp: anything that you fix/update here should be /// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of /// this module. /// /// Except, as compared to [FStar.IntN.fstp], here: /// - every occurrence of [int_t] has been replaced with [uint_t] /// - every occurrence of [@%] has been replaced with [%]. /// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers /// This module provides an abstract type for machine integers of a /// given signedness and width. The interface is designed to be safe /// with respect to arithmetic underflow and overflow. /// Note, we have attempted several times to re-design this module to /// make it more amenable to normalization and to impose less overhead /// on the SMT solver when reasoning about machine integer /// arithmetic. The following github issue reports on the current /// status of that work. /// /// https://github.com/FStarLang/FStar/issues/1757 open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (** Abstract type of machine integers, with an underlying representation using a bounded mathematical integer *) new val t : eqtype (** A coercion that projects a bounded mathematical integer from a machine integer *) val v (x:t) : Tot (uint_t n) (** A coercion that injects a bounded mathematical integers into a machine integer *) val uint_to_t (x:uint_t n) : Pure t (requires True) (ensures (fun y -> v y = x)) (** Injection/projection inverse *) val uv_inv (x : t) : Lemma (ensures (uint_to_t (v x) == x)) [SMTPat (v x)] (** Projection/injection inverse *) val vu_inv (x : uint_t n) : Lemma (ensures (v (uint_to_t x) == x)) [SMTPat (uint_to_t x)] (** An alternate form of the injectivity of the [v] projection *) val v_inj (x1 x2: t): Lemma (requires (v x1 == v x2)) (ensures (x1 == x2)) (** Constants 0 and 1 *) val zero : x:t{v x = 0} val one : x:t{v x = 1} (**** Addition primitives *) (** Bounds-respecting addition The precondition enforces that the sum does not overflow, expressing the bound as an addition on mathematical integers *) val add (a:t) (b:t) : Pure t (requires (size (v a + v b) n)) (ensures (fun c -> v a + v b = v c)) (** Underspecified, possibly overflowing addition: The postcondition only enures that the result is the sum of the arguments in case there is no overflow *) val add_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a + v b) n ==> v a + v b = v c)) (** Addition modulo [2^n] Machine integers can always be added, but the postcondition is now in terms of addition modulo [2^n] on mathematical integers *) val add_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c)) (**** Subtraction primitives *) (** Bounds-respecting subtraction The precondition enforces that the difference does not underflow, expressing the bound as a difference on mathematical integers *) val sub (a:t) (b:t) : Pure t (requires (size (v a - v b) n)) (ensures (fun c -> v a - v b = v c)) (** Underspecified, possibly overflowing subtraction: The postcondition only enures that the result is the difference of the arguments in case there is no underflow *) val sub_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a - v b) n ==> v a - v b = v c)) (** Subtraction modulo [2^n] Machine integers can always be subtractd, but the postcondition is now in terms of subtraction modulo [2^n] on mathematical integers *) val sub_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c)) (**** Multiplication primitives *) (** Bounds-respecting multiplication The precondition enforces that the product does not overflow, expressing the bound as a product on mathematical integers *) val mul (a:t) (b:t) : Pure t (requires (size (v a * v b) n)) (ensures (fun c -> v a * v b = v c)) (** Underspecified, possibly overflowing product The postcondition only enures that the result is the product of the arguments in case there is no overflow *) val mul_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a * v b) n ==> v a * v b = v c)) (** Multiplication modulo [2^n] Machine integers can always be multiplied, but the postcondition is now in terms of product modulo [2^n] on mathematical integers *) val mul_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c)) (**** Division primitives *) (** Euclidean division of [a] and [b], with [b] non-zero *) val div (a:t) (b:t{v b <> 0}) : Pure t (requires (True)) (ensures (fun c -> v a / v b = v c)) (**** Modulo primitives *) (** Euclidean remainder The result is the modulus of [a] with respect to a non-zero [b] *) val rem (a:t) (b:t{v b <> 0}) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c)) (**** Bitwise operators *) /// Also see FStar.BV (** Bitwise logical conjunction *) val logand (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logand` v y = v z)) (** Bitwise logical exclusive-or *) val logxor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logxor` v y == v z)) (** Bitwise logical disjunction *) val logor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logor` v y == v z)) (** Bitwise logical negation *) val lognot (x:t) : Pure t (requires True) (ensures (fun z -> lognot (v x) == v z)) (**** Shift operators *) (** Shift right with zero fill, shifting at most the integer width *) val shift_right (a:t) (s:t) : Pure t (requires (v s < n)) (ensures (fun c -> FStar.UInt.shift_right (v a) (v s) = v c)) (** Shift left with zero fill, shifting at most the integer width *) val shift_left (a:t) (s:t) : Pure t (requires (v s < n)) (ensures (fun c -> FStar.UInt.shift_left (v a) (v s) = v c)) (**** Comparison operators *) (** Equality Note, it is safe to also use the polymorphic decidable equality operator [=] *) let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b) (** Greater than *) let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b) (** Greater than or equal *) let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b) (** Less than *) let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b) (** Less than or equal *) let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b) (** Unary negation *) inline_for_extraction let minus (a:t) = add_mod (lognot a) (uint_to_t 1) (** The maximum shift value for this type, i.e. its width minus one, as an *) inline_for_extraction let n_minus_one = uint_to_t (n - 1) #set-options "--z3rlimit 80 --initial_fuel 1 --max_fuel 1" (** A constant-time way to compute the equality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=2e60bb395c1f589a398ec606d611132ef9ef764b Note, the branching on [a=b] is just for proof-purposes. *) [@ CNoInline ] let eq_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\ (v a <> v b ==> v c = 0))) = let x = logxor a b in let minus_x = minus x in let x_or_minus_x = logor x minus_x in let xnx = shift_right x_or_minus_x n_minus_one in let c = sub_mod xnx (uint_to_t 1) in if a = b then begin logxor_self (v a); lognot_lemma_1 #n; logor_lemma_1 (v x); assert (v x = 0 /\ v minus_x = 0 /\ v x_or_minus_x = 0 /\ v xnx = 0); assert (v c = ones n) end else begin logxor_neq_nonzero (v a) (v b); lemma_msb_pow2 #n (v (lognot x)); lemma_msb_pow2 #n (v minus_x); lemma_minus_zero #n (v x); assert (v c = FStar.UInt.zero n) end; c private val lemma_sub_msbs (a:t) (b:t) : Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b)))) (** A constant-time way to compute the [>=] inequality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=0a483a9b431d87eca1b275463c632f8d5551978a *) [@ CNoInline ] let gte_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\ (v a < v b ==> v c = 0))) = let x = a in let y = b in let x_xor_y = logxor x y in let x_sub_y = sub_mod x y in let x_sub_y_xor_y = logxor x_sub_y y in let q = logor x_xor_y x_sub_y_xor_y in let x_xor_q = logxor x q in let x_xor_q_ = shift_right x_xor_q n_minus_one in let c = sub_mod x_xor_q_ (uint_to_t 1) in lemma_sub_msbs x y; lemma_msb_gte (v x) (v y); lemma_msb_gte (v y) (v x); c #reset-options (*** Infix notations *) unfold let op_Plus_Hat = add unfold let op_Plus_Question_Hat = add_underspec unfold let op_Plus_Percent_Hat = add_mod unfold let op_Subtraction_Hat = sub unfold let op_Subtraction_Question_Hat = sub_underspec unfold let op_Subtraction_Percent_Hat = sub_mod unfold let op_Star_Hat = mul unfold let op_Star_Question_Hat = mul_underspec unfold let op_Star_Percent_Hat = mul_mod unfold let op_Slash_Hat = div unfold let op_Percent_Hat = rem unfold let op_Hat_Hat = logxor
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt32.fsti" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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
x: FStar.UInt32.t -> y: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t
Prims.Pure
[]
[]
[ "FStar.UInt32.logor" ]
[]
false
false
false
false
false
let op_Bar_Hat =
logor
false
Vale.X64.Decls.fst
Vale.X64.Decls.va_lemma_while_total
val va_lemma_while_total (b:ocmp) (c:va_code) (s0:va_state) : Ghost (va_state & va_fuel) (requires True) (ensures fun (s1, f1) -> s1 == s0 /\ eval_while_inv (While b c) s1 f1 s1 )
val va_lemma_while_total (b:ocmp) (c:va_code) (s0:va_state) : Ghost (va_state & va_fuel) (requires True) (ensures fun (s1, f1) -> s1 == s0 /\ eval_while_inv (While b c) s1 f1 s1 )
let va_lemma_while_total = Lemmas.lemma_while_total
{ "file_name": "vale/code/arch/x64/Vale.X64.Decls.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 51, "end_line": 139, "start_col": 0, "start_line": 139 }
module Vale.X64.Decls open FStar.Mul open Vale.X64.Machine_s open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open FStar.UInt module P = Vale.X64.Print_s module BC = Vale.X64.Bytes_Code_s module BS = Vale.X64.Machine_Semantics_s #reset-options "--max_fuel 0 --max_ifuel 0 --smtencoding.elim_box true --smtencoding.l_arith_repr boxwrap --smtencoding.nl_arith_repr boxwrap --z3cliopt smt.arith.nl=true --using_facts_from 'Prims FStar.UInt Vale.Def.Words_s FStar.UInt64'" let lemma_mul_in_bounds (x y:nat64) : Lemma (requires x * y < pow2_64) (ensures FStar.UInt.mul_mod #64 x y == x * y) = () #reset-options "--z3cliopt smt.arith.nl=true --using_facts_from Prims --using_facts_from FStar.Math" let lemma_mul_nat (x:nat) (y:nat) : Lemma (ensures 0 <= (x * y)) = () #reset-options "--initial_fuel 2 --max_fuel 2" let cf flags = match Lemmas.cf flags with | Some v -> v | None -> false let overflow flags = match Lemmas.overflow flags with | Some v -> v | None -> false let valid_cf flags = match Lemmas.cf flags with | Some v -> true | None -> false let valid_of flags = match Lemmas.overflow flags with | Some v -> true | None -> false let updated_cf new_flags new_cf = Lemmas.cf new_flags = Some new_cf let updated_of new_flags new_cf = Lemmas.overflow new_flags = Some new_cf let maintained_cf new_flags flags = Lemmas.cf new_flags = Lemmas.cf flags let maintained_of new_flags flags = Lemmas.overflow new_flags = Lemmas.overflow flags let ins = BS.ins type ocmp = BS.ocmp type va_fuel = nat type va_pbool = Vale.Def.PossiblyMonad.pbool let va_ttrue () = Vale.Def.PossiblyMonad.ttrue let va_ffalse = Vale.Def.PossiblyMonad.ffalse let va_pbool_and x y = Vale.Def.PossiblyMonad.((&&.)) x y let get_reason p = match p with | Vale.Def.PossiblyMonad.Ok () -> None | Vale.Def.PossiblyMonad.Err reason -> Some reason let mul_nat_helper x y = FStar.Math.Lemmas.nat_times_nat_is_nat x y let va_fuel_default () = 0 let lemma_opr_Mem64 (id:heaplet_id) (s:va_state) (base:operand64) (offset:int) (b:M.buffer64) (index:int) (t:taint) : Lemma (requires ( let h = Map16.sel s.vs_heap.vf_heaplets id in M.mem_inv s.vs_heap /\ OReg? base /\ valid_src_addr h b index /\ M.valid_layout_buffer b (s.vs_heap.vf_layout) h false /\ M.valid_taint_buf64 b h (full_heap_taint s.vs_heap) t /\ eval_operand base s + offset == M.buffer_addr b h + 8 * index )) (ensures ( let h = Map16.sel s.vs_heap.vf_heaplets id in valid_operand (va_opr_code_Mem64 id base offset t) s /\ M.load_mem64 (M.buffer_addr b h + 8 * index) (s.vs_heap.vf_heap) == M.buffer_read b index h )) = Vale.X64.Memory_Sems.low_lemma_load_mem64_full b index s.vs_heap t id; let h = M.get_vale_heap s.vs_heap in let t = va_opr_code_Mem64 id base offset t in M.lemma_valid_mem64 b index h; let OMem (m, t) = t in assert (valid_buf_maddr64 (eval_maddr m s) h s.vs_heap.vf_layout b index t); M.lemma_load_mem64 b index h let lemma_opr_Mem128 (id:heaplet_id) (s:va_state) (base:operand64) (offset:int) (t:taint) (b:M.buffer128) (index:int) : Lemma (requires ( let h = Map16.sel s.vs_heap.vf_heaplets id in M.mem_inv s.vs_heap /\ OReg? base /\ valid_src_addr h b index /\ M.valid_layout_buffer b (s.vs_heap.vf_layout) h false /\ M.valid_taint_buf128 b h (full_heap_taint s.vs_heap) t /\ eval_operand base s + offset == M.buffer_addr b h + 16 * index )) (ensures ( let h = Map16.sel s.vs_heap.vf_heaplets id in valid_operand128 (va_opr_code_Mem128 id base offset t) s /\ M.load_mem128 (M.buffer_addr b h + 16 * index) (M.get_vale_heap s.vs_heap) == M.buffer_read b index h )) = Vale.X64.Memory_Sems.low_lemma_load_mem128_full b index s.vs_heap t id; let h = M.get_vale_heap s.vs_heap in let t = va_opr_code_Mem128 id base offset t in M.lemma_valid_mem128 b index h; let OMem (m, t) = t in assert (valid_buf_maddr128 (eval_maddr m s) h s.vs_heap.vf_layout b index t); M.lemma_load_mem128 b index h let taint_at memTaint addr = Map.sel memTaint addr let va_cmp_eq o1 o2 = BC.OEq o1 o2 let va_cmp_ne o1 o2 = BC.ONe o1 o2 let va_cmp_le o1 o2 = BC.OLe o1 o2 let va_cmp_ge o1 o2 = BC.OGe o1 o2 let va_cmp_lt o1 o2 = BC.OLt o1 o2 let va_cmp_gt o1 o2 = BC.OGt o1 o2 let eval_code = Lemmas.eval_code let eval_while_inv = Lemmas.eval_while_inv let va_ins_lemma (c0:va_code) (s0:va_state) : Lemma (requires True) (ensures (forall (i:ins) (s:BS.machine_state).{:pattern (BS.machine_eval_code_ins i s)} BS.machine_eval_code_ins i s == BS.machine_eval_code_ins_def i s) ) = reveal_opaque (`%BS.machine_eval_code_ins) BS.machine_eval_code_ins let eval_ocmp = Lemmas.eval_ocmp let valid_ocmp = Lemmas.valid_ocmp let havoc_flags = Lemmas.havoc_flags unfold let va_eval_ins = Lemmas.eval_ins let lemma_cmp_eq s o1 o2 = () let lemma_cmp_ne s o1 o2 = () let lemma_cmp_le s o1 o2 = () let lemma_cmp_ge s o1 o2 = () let lemma_cmp_lt s o1 o2 = () let lemma_cmp_gt s o1 o2 = () let lemma_valid_cmp_eq s o1 o2 = () let lemma_valid_cmp_ne s o1 o2 = () let lemma_valid_cmp_le s o1 o2 = () let lemma_valid_cmp_ge s o1 o2 = () let lemma_valid_cmp_lt s o1 o2 = () let lemma_valid_cmp_gt s o1 o2 = () let va_compute_merge_total = Lemmas.compute_merge_total let va_lemma_merge_total b0 s0 f0 sM fM sN = Lemmas.lemma_merge_total b0 s0 f0 sM fM sN; Lemmas.compute_merge_total f0 fM let va_lemma_empty_total = Lemmas.lemma_empty_total let va_lemma_ifElse_total = Lemmas.lemma_ifElse_total let va_lemma_ifElseTrue_total = Lemmas.lemma_ifElseTrue_total
{ "checked_file": "/", "dependencies": [ "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory_Sems.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Lemmas.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Def.PossiblyMonad.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Map.fsti.checked", "FStar.IO.fst.checked" ], "interface_file": true, "source_file": "Vale.X64.Decls.fst" }
[ { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Stack_i", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 2, "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
b: Vale.X64.Decls.ocmp -> c: Vale.X64.Decls.va_code -> s0: Vale.X64.Decls.va_state -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
Prims.Ghost
[]
[]
[ "Vale.X64.Lemmas.lemma_while_total" ]
[]
false
false
false
false
false
let va_lemma_while_total =
Lemmas.lemma_while_total
false
FStar.UInt32.fsti
FStar.UInt32.op_Percent_Hat
val op_Percent_Hat : a: FStar.UInt32.t -> b: FStar.UInt32.t{FStar.UInt32.v b <> 0} -> Prims.Pure FStar.UInt32.t
let op_Percent_Hat = rem
{ "file_name": "ulib/FStar.UInt32.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 31, "end_line": 326, "start_col": 7, "start_line": 326 }
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt32 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) unfold let n = 32 /// For FStar.UIntN.fstp: anything that you fix/update here should be /// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of /// this module. /// /// Except, as compared to [FStar.IntN.fstp], here: /// - every occurrence of [int_t] has been replaced with [uint_t] /// - every occurrence of [@%] has been replaced with [%]. /// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers /// This module provides an abstract type for machine integers of a /// given signedness and width. The interface is designed to be safe /// with respect to arithmetic underflow and overflow. /// Note, we have attempted several times to re-design this module to /// make it more amenable to normalization and to impose less overhead /// on the SMT solver when reasoning about machine integer /// arithmetic. The following github issue reports on the current /// status of that work. /// /// https://github.com/FStarLang/FStar/issues/1757 open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (** Abstract type of machine integers, with an underlying representation using a bounded mathematical integer *) new val t : eqtype (** A coercion that projects a bounded mathematical integer from a machine integer *) val v (x:t) : Tot (uint_t n) (** A coercion that injects a bounded mathematical integers into a machine integer *) val uint_to_t (x:uint_t n) : Pure t (requires True) (ensures (fun y -> v y = x)) (** Injection/projection inverse *) val uv_inv (x : t) : Lemma (ensures (uint_to_t (v x) == x)) [SMTPat (v x)] (** Projection/injection inverse *) val vu_inv (x : uint_t n) : Lemma (ensures (v (uint_to_t x) == x)) [SMTPat (uint_to_t x)] (** An alternate form of the injectivity of the [v] projection *) val v_inj (x1 x2: t): Lemma (requires (v x1 == v x2)) (ensures (x1 == x2)) (** Constants 0 and 1 *) val zero : x:t{v x = 0} val one : x:t{v x = 1} (**** Addition primitives *) (** Bounds-respecting addition The precondition enforces that the sum does not overflow, expressing the bound as an addition on mathematical integers *) val add (a:t) (b:t) : Pure t (requires (size (v a + v b) n)) (ensures (fun c -> v a + v b = v c)) (** Underspecified, possibly overflowing addition: The postcondition only enures that the result is the sum of the arguments in case there is no overflow *) val add_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a + v b) n ==> v a + v b = v c)) (** Addition modulo [2^n] Machine integers can always be added, but the postcondition is now in terms of addition modulo [2^n] on mathematical integers *) val add_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c)) (**** Subtraction primitives *) (** Bounds-respecting subtraction The precondition enforces that the difference does not underflow, expressing the bound as a difference on mathematical integers *) val sub (a:t) (b:t) : Pure t (requires (size (v a - v b) n)) (ensures (fun c -> v a - v b = v c)) (** Underspecified, possibly overflowing subtraction: The postcondition only enures that the result is the difference of the arguments in case there is no underflow *) val sub_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a - v b) n ==> v a - v b = v c)) (** Subtraction modulo [2^n] Machine integers can always be subtractd, but the postcondition is now in terms of subtraction modulo [2^n] on mathematical integers *) val sub_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c)) (**** Multiplication primitives *) (** Bounds-respecting multiplication The precondition enforces that the product does not overflow, expressing the bound as a product on mathematical integers *) val mul (a:t) (b:t) : Pure t (requires (size (v a * v b) n)) (ensures (fun c -> v a * v b = v c)) (** Underspecified, possibly overflowing product The postcondition only enures that the result is the product of the arguments in case there is no overflow *) val mul_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a * v b) n ==> v a * v b = v c)) (** Multiplication modulo [2^n] Machine integers can always be multiplied, but the postcondition is now in terms of product modulo [2^n] on mathematical integers *) val mul_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c)) (**** Division primitives *) (** Euclidean division of [a] and [b], with [b] non-zero *) val div (a:t) (b:t{v b <> 0}) : Pure t (requires (True)) (ensures (fun c -> v a / v b = v c)) (**** Modulo primitives *) (** Euclidean remainder The result is the modulus of [a] with respect to a non-zero [b] *) val rem (a:t) (b:t{v b <> 0}) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c)) (**** Bitwise operators *) /// Also see FStar.BV (** Bitwise logical conjunction *) val logand (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logand` v y = v z)) (** Bitwise logical exclusive-or *) val logxor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logxor` v y == v z)) (** Bitwise logical disjunction *) val logor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logor` v y == v z)) (** Bitwise logical negation *) val lognot (x:t) : Pure t (requires True) (ensures (fun z -> lognot (v x) == v z)) (**** Shift operators *) (** Shift right with zero fill, shifting at most the integer width *) val shift_right (a:t) (s:t) : Pure t (requires (v s < n)) (ensures (fun c -> FStar.UInt.shift_right (v a) (v s) = v c)) (** Shift left with zero fill, shifting at most the integer width *) val shift_left (a:t) (s:t) : Pure t (requires (v s < n)) (ensures (fun c -> FStar.UInt.shift_left (v a) (v s) = v c)) (**** Comparison operators *) (** Equality Note, it is safe to also use the polymorphic decidable equality operator [=] *) let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b) (** Greater than *) let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b) (** Greater than or equal *) let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b) (** Less than *) let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b) (** Less than or equal *) let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b) (** Unary negation *) inline_for_extraction let minus (a:t) = add_mod (lognot a) (uint_to_t 1) (** The maximum shift value for this type, i.e. its width minus one, as an *) inline_for_extraction let n_minus_one = uint_to_t (n - 1) #set-options "--z3rlimit 80 --initial_fuel 1 --max_fuel 1" (** A constant-time way to compute the equality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=2e60bb395c1f589a398ec606d611132ef9ef764b Note, the branching on [a=b] is just for proof-purposes. *) [@ CNoInline ] let eq_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\ (v a <> v b ==> v c = 0))) = let x = logxor a b in let minus_x = minus x in let x_or_minus_x = logor x minus_x in let xnx = shift_right x_or_minus_x n_minus_one in let c = sub_mod xnx (uint_to_t 1) in if a = b then begin logxor_self (v a); lognot_lemma_1 #n; logor_lemma_1 (v x); assert (v x = 0 /\ v minus_x = 0 /\ v x_or_minus_x = 0 /\ v xnx = 0); assert (v c = ones n) end else begin logxor_neq_nonzero (v a) (v b); lemma_msb_pow2 #n (v (lognot x)); lemma_msb_pow2 #n (v minus_x); lemma_minus_zero #n (v x); assert (v c = FStar.UInt.zero n) end; c private val lemma_sub_msbs (a:t) (b:t) : Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b)))) (** A constant-time way to compute the [>=] inequality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=0a483a9b431d87eca1b275463c632f8d5551978a *) [@ CNoInline ] let gte_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\ (v a < v b ==> v c = 0))) = let x = a in let y = b in let x_xor_y = logxor x y in let x_sub_y = sub_mod x y in let x_sub_y_xor_y = logxor x_sub_y y in let q = logor x_xor_y x_sub_y_xor_y in let x_xor_q = logxor x q in let x_xor_q_ = shift_right x_xor_q n_minus_one in let c = sub_mod x_xor_q_ (uint_to_t 1) in lemma_sub_msbs x y; lemma_msb_gte (v x) (v y); lemma_msb_gte (v y) (v x); c #reset-options (*** Infix notations *) unfold let op_Plus_Hat = add unfold let op_Plus_Question_Hat = add_underspec unfold let op_Plus_Percent_Hat = add_mod unfold let op_Subtraction_Hat = sub unfold let op_Subtraction_Question_Hat = sub_underspec unfold let op_Subtraction_Percent_Hat = sub_mod unfold let op_Star_Hat = mul unfold let op_Star_Question_Hat = mul_underspec unfold let op_Star_Percent_Hat = mul_mod
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt32.fsti" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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
a: FStar.UInt32.t -> b: FStar.UInt32.t{FStar.UInt32.v b <> 0} -> Prims.Pure FStar.UInt32.t
Prims.Pure
[]
[]
[ "FStar.UInt32.rem" ]
[]
false
false
false
false
false
let op_Percent_Hat =
rem
false
FStar.UInt32.fsti
FStar.UInt32.op_Greater_Hat
val op_Greater_Hat : a: FStar.UInt32.t -> b: FStar.UInt32.t -> Prims.bool
let op_Greater_Hat = gt
{ "file_name": "ulib/FStar.UInt32.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 30, "end_line": 333, "start_col": 7, "start_line": 333 }
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt32 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) unfold let n = 32 /// For FStar.UIntN.fstp: anything that you fix/update here should be /// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of /// this module. /// /// Except, as compared to [FStar.IntN.fstp], here: /// - every occurrence of [int_t] has been replaced with [uint_t] /// - every occurrence of [@%] has been replaced with [%]. /// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers /// This module provides an abstract type for machine integers of a /// given signedness and width. The interface is designed to be safe /// with respect to arithmetic underflow and overflow. /// Note, we have attempted several times to re-design this module to /// make it more amenable to normalization and to impose less overhead /// on the SMT solver when reasoning about machine integer /// arithmetic. The following github issue reports on the current /// status of that work. /// /// https://github.com/FStarLang/FStar/issues/1757 open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (** Abstract type of machine integers, with an underlying representation using a bounded mathematical integer *) new val t : eqtype (** A coercion that projects a bounded mathematical integer from a machine integer *) val v (x:t) : Tot (uint_t n) (** A coercion that injects a bounded mathematical integers into a machine integer *) val uint_to_t (x:uint_t n) : Pure t (requires True) (ensures (fun y -> v y = x)) (** Injection/projection inverse *) val uv_inv (x : t) : Lemma (ensures (uint_to_t (v x) == x)) [SMTPat (v x)] (** Projection/injection inverse *) val vu_inv (x : uint_t n) : Lemma (ensures (v (uint_to_t x) == x)) [SMTPat (uint_to_t x)] (** An alternate form of the injectivity of the [v] projection *) val v_inj (x1 x2: t): Lemma (requires (v x1 == v x2)) (ensures (x1 == x2)) (** Constants 0 and 1 *) val zero : x:t{v x = 0} val one : x:t{v x = 1} (**** Addition primitives *) (** Bounds-respecting addition The precondition enforces that the sum does not overflow, expressing the bound as an addition on mathematical integers *) val add (a:t) (b:t) : Pure t (requires (size (v a + v b) n)) (ensures (fun c -> v a + v b = v c)) (** Underspecified, possibly overflowing addition: The postcondition only enures that the result is the sum of the arguments in case there is no overflow *) val add_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a + v b) n ==> v a + v b = v c)) (** Addition modulo [2^n] Machine integers can always be added, but the postcondition is now in terms of addition modulo [2^n] on mathematical integers *) val add_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c)) (**** Subtraction primitives *) (** Bounds-respecting subtraction The precondition enforces that the difference does not underflow, expressing the bound as a difference on mathematical integers *) val sub (a:t) (b:t) : Pure t (requires (size (v a - v b) n)) (ensures (fun c -> v a - v b = v c)) (** Underspecified, possibly overflowing subtraction: The postcondition only enures that the result is the difference of the arguments in case there is no underflow *) val sub_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a - v b) n ==> v a - v b = v c)) (** Subtraction modulo [2^n] Machine integers can always be subtractd, but the postcondition is now in terms of subtraction modulo [2^n] on mathematical integers *) val sub_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c)) (**** Multiplication primitives *) (** Bounds-respecting multiplication The precondition enforces that the product does not overflow, expressing the bound as a product on mathematical integers *) val mul (a:t) (b:t) : Pure t (requires (size (v a * v b) n)) (ensures (fun c -> v a * v b = v c)) (** Underspecified, possibly overflowing product The postcondition only enures that the result is the product of the arguments in case there is no overflow *) val mul_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a * v b) n ==> v a * v b = v c)) (** Multiplication modulo [2^n] Machine integers can always be multiplied, but the postcondition is now in terms of product modulo [2^n] on mathematical integers *) val mul_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c)) (**** Division primitives *) (** Euclidean division of [a] and [b], with [b] non-zero *) val div (a:t) (b:t{v b <> 0}) : Pure t (requires (True)) (ensures (fun c -> v a / v b = v c)) (**** Modulo primitives *) (** Euclidean remainder The result is the modulus of [a] with respect to a non-zero [b] *) val rem (a:t) (b:t{v b <> 0}) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c)) (**** Bitwise operators *) /// Also see FStar.BV (** Bitwise logical conjunction *) val logand (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logand` v y = v z)) (** Bitwise logical exclusive-or *) val logxor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logxor` v y == v z)) (** Bitwise logical disjunction *) val logor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logor` v y == v z)) (** Bitwise logical negation *) val lognot (x:t) : Pure t (requires True) (ensures (fun z -> lognot (v x) == v z)) (**** Shift operators *) (** Shift right with zero fill, shifting at most the integer width *) val shift_right (a:t) (s:t) : Pure t (requires (v s < n)) (ensures (fun c -> FStar.UInt.shift_right (v a) (v s) = v c)) (** Shift left with zero fill, shifting at most the integer width *) val shift_left (a:t) (s:t) : Pure t (requires (v s < n)) (ensures (fun c -> FStar.UInt.shift_left (v a) (v s) = v c)) (**** Comparison operators *) (** Equality Note, it is safe to also use the polymorphic decidable equality operator [=] *) let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b) (** Greater than *) let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b) (** Greater than or equal *) let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b) (** Less than *) let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b) (** Less than or equal *) let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b) (** Unary negation *) inline_for_extraction let minus (a:t) = add_mod (lognot a) (uint_to_t 1) (** The maximum shift value for this type, i.e. its width minus one, as an *) inline_for_extraction let n_minus_one = uint_to_t (n - 1) #set-options "--z3rlimit 80 --initial_fuel 1 --max_fuel 1" (** A constant-time way to compute the equality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=2e60bb395c1f589a398ec606d611132ef9ef764b Note, the branching on [a=b] is just for proof-purposes. *) [@ CNoInline ] let eq_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\ (v a <> v b ==> v c = 0))) = let x = logxor a b in let minus_x = minus x in let x_or_minus_x = logor x minus_x in let xnx = shift_right x_or_minus_x n_minus_one in let c = sub_mod xnx (uint_to_t 1) in if a = b then begin logxor_self (v a); lognot_lemma_1 #n; logor_lemma_1 (v x); assert (v x = 0 /\ v minus_x = 0 /\ v x_or_minus_x = 0 /\ v xnx = 0); assert (v c = ones n) end else begin logxor_neq_nonzero (v a) (v b); lemma_msb_pow2 #n (v (lognot x)); lemma_msb_pow2 #n (v minus_x); lemma_minus_zero #n (v x); assert (v c = FStar.UInt.zero n) end; c private val lemma_sub_msbs (a:t) (b:t) : Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b)))) (** A constant-time way to compute the [>=] inequality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=0a483a9b431d87eca1b275463c632f8d5551978a *) [@ CNoInline ] let gte_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\ (v a < v b ==> v c = 0))) = let x = a in let y = b in let x_xor_y = logxor x y in let x_sub_y = sub_mod x y in let x_sub_y_xor_y = logxor x_sub_y y in let q = logor x_xor_y x_sub_y_xor_y in let x_xor_q = logxor x q in let x_xor_q_ = shift_right x_xor_q n_minus_one in let c = sub_mod x_xor_q_ (uint_to_t 1) in lemma_sub_msbs x y; lemma_msb_gte (v x) (v y); lemma_msb_gte (v y) (v x); c #reset-options (*** Infix notations *) unfold let op_Plus_Hat = add unfold let op_Plus_Question_Hat = add_underspec unfold let op_Plus_Percent_Hat = add_mod unfold let op_Subtraction_Hat = sub unfold let op_Subtraction_Question_Hat = sub_underspec unfold let op_Subtraction_Percent_Hat = sub_mod unfold let op_Star_Hat = mul unfold let op_Star_Question_Hat = mul_underspec unfold let op_Star_Percent_Hat = mul_mod unfold let op_Slash_Hat = div unfold let op_Percent_Hat = rem unfold let op_Hat_Hat = logxor unfold let op_Amp_Hat = logand unfold let op_Bar_Hat = logor unfold let op_Less_Less_Hat = shift_left unfold let op_Greater_Greater_Hat = shift_right
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt32.fsti" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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
a: FStar.UInt32.t -> b: FStar.UInt32.t -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.gt" ]
[]
false
false
false
true
false
let op_Greater_Hat =
gt
false
FStar.UInt32.fsti
FStar.UInt32.op_Amp_Hat
val op_Amp_Hat : x: FStar.UInt32.t -> y: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t
let op_Amp_Hat = logand
{ "file_name": "ulib/FStar.UInt32.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 30, "end_line": 328, "start_col": 7, "start_line": 328 }
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt32 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) unfold let n = 32 /// For FStar.UIntN.fstp: anything that you fix/update here should be /// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of /// this module. /// /// Except, as compared to [FStar.IntN.fstp], here: /// - every occurrence of [int_t] has been replaced with [uint_t] /// - every occurrence of [@%] has been replaced with [%]. /// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers /// This module provides an abstract type for machine integers of a /// given signedness and width. The interface is designed to be safe /// with respect to arithmetic underflow and overflow. /// Note, we have attempted several times to re-design this module to /// make it more amenable to normalization and to impose less overhead /// on the SMT solver when reasoning about machine integer /// arithmetic. The following github issue reports on the current /// status of that work. /// /// https://github.com/FStarLang/FStar/issues/1757 open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (** Abstract type of machine integers, with an underlying representation using a bounded mathematical integer *) new val t : eqtype (** A coercion that projects a bounded mathematical integer from a machine integer *) val v (x:t) : Tot (uint_t n) (** A coercion that injects a bounded mathematical integers into a machine integer *) val uint_to_t (x:uint_t n) : Pure t (requires True) (ensures (fun y -> v y = x)) (** Injection/projection inverse *) val uv_inv (x : t) : Lemma (ensures (uint_to_t (v x) == x)) [SMTPat (v x)] (** Projection/injection inverse *) val vu_inv (x : uint_t n) : Lemma (ensures (v (uint_to_t x) == x)) [SMTPat (uint_to_t x)] (** An alternate form of the injectivity of the [v] projection *) val v_inj (x1 x2: t): Lemma (requires (v x1 == v x2)) (ensures (x1 == x2)) (** Constants 0 and 1 *) val zero : x:t{v x = 0} val one : x:t{v x = 1} (**** Addition primitives *) (** Bounds-respecting addition The precondition enforces that the sum does not overflow, expressing the bound as an addition on mathematical integers *) val add (a:t) (b:t) : Pure t (requires (size (v a + v b) n)) (ensures (fun c -> v a + v b = v c)) (** Underspecified, possibly overflowing addition: The postcondition only enures that the result is the sum of the arguments in case there is no overflow *) val add_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a + v b) n ==> v a + v b = v c)) (** Addition modulo [2^n] Machine integers can always be added, but the postcondition is now in terms of addition modulo [2^n] on mathematical integers *) val add_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c)) (**** Subtraction primitives *) (** Bounds-respecting subtraction The precondition enforces that the difference does not underflow, expressing the bound as a difference on mathematical integers *) val sub (a:t) (b:t) : Pure t (requires (size (v a - v b) n)) (ensures (fun c -> v a - v b = v c)) (** Underspecified, possibly overflowing subtraction: The postcondition only enures that the result is the difference of the arguments in case there is no underflow *) val sub_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a - v b) n ==> v a - v b = v c)) (** Subtraction modulo [2^n] Machine integers can always be subtractd, but the postcondition is now in terms of subtraction modulo [2^n] on mathematical integers *) val sub_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c)) (**** Multiplication primitives *) (** Bounds-respecting multiplication The precondition enforces that the product does not overflow, expressing the bound as a product on mathematical integers *) val mul (a:t) (b:t) : Pure t (requires (size (v a * v b) n)) (ensures (fun c -> v a * v b = v c)) (** Underspecified, possibly overflowing product The postcondition only enures that the result is the product of the arguments in case there is no overflow *) val mul_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a * v b) n ==> v a * v b = v c)) (** Multiplication modulo [2^n] Machine integers can always be multiplied, but the postcondition is now in terms of product modulo [2^n] on mathematical integers *) val mul_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c)) (**** Division primitives *) (** Euclidean division of [a] and [b], with [b] non-zero *) val div (a:t) (b:t{v b <> 0}) : Pure t (requires (True)) (ensures (fun c -> v a / v b = v c)) (**** Modulo primitives *) (** Euclidean remainder The result is the modulus of [a] with respect to a non-zero [b] *) val rem (a:t) (b:t{v b <> 0}) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c)) (**** Bitwise operators *) /// Also see FStar.BV (** Bitwise logical conjunction *) val logand (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logand` v y = v z)) (** Bitwise logical exclusive-or *) val logxor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logxor` v y == v z)) (** Bitwise logical disjunction *) val logor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logor` v y == v z)) (** Bitwise logical negation *) val lognot (x:t) : Pure t (requires True) (ensures (fun z -> lognot (v x) == v z)) (**** Shift operators *) (** Shift right with zero fill, shifting at most the integer width *) val shift_right (a:t) (s:t) : Pure t (requires (v s < n)) (ensures (fun c -> FStar.UInt.shift_right (v a) (v s) = v c)) (** Shift left with zero fill, shifting at most the integer width *) val shift_left (a:t) (s:t) : Pure t (requires (v s < n)) (ensures (fun c -> FStar.UInt.shift_left (v a) (v s) = v c)) (**** Comparison operators *) (** Equality Note, it is safe to also use the polymorphic decidable equality operator [=] *) let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b) (** Greater than *) let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b) (** Greater than or equal *) let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b) (** Less than *) let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b) (** Less than or equal *) let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b) (** Unary negation *) inline_for_extraction let minus (a:t) = add_mod (lognot a) (uint_to_t 1) (** The maximum shift value for this type, i.e. its width minus one, as an *) inline_for_extraction let n_minus_one = uint_to_t (n - 1) #set-options "--z3rlimit 80 --initial_fuel 1 --max_fuel 1" (** A constant-time way to compute the equality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=2e60bb395c1f589a398ec606d611132ef9ef764b Note, the branching on [a=b] is just for proof-purposes. *) [@ CNoInline ] let eq_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\ (v a <> v b ==> v c = 0))) = let x = logxor a b in let minus_x = minus x in let x_or_minus_x = logor x minus_x in let xnx = shift_right x_or_minus_x n_minus_one in let c = sub_mod xnx (uint_to_t 1) in if a = b then begin logxor_self (v a); lognot_lemma_1 #n; logor_lemma_1 (v x); assert (v x = 0 /\ v minus_x = 0 /\ v x_or_minus_x = 0 /\ v xnx = 0); assert (v c = ones n) end else begin logxor_neq_nonzero (v a) (v b); lemma_msb_pow2 #n (v (lognot x)); lemma_msb_pow2 #n (v minus_x); lemma_minus_zero #n (v x); assert (v c = FStar.UInt.zero n) end; c private val lemma_sub_msbs (a:t) (b:t) : Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b)))) (** A constant-time way to compute the [>=] inequality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=0a483a9b431d87eca1b275463c632f8d5551978a *) [@ CNoInline ] let gte_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\ (v a < v b ==> v c = 0))) = let x = a in let y = b in let x_xor_y = logxor x y in let x_sub_y = sub_mod x y in let x_sub_y_xor_y = logxor x_sub_y y in let q = logor x_xor_y x_sub_y_xor_y in let x_xor_q = logxor x q in let x_xor_q_ = shift_right x_xor_q n_minus_one in let c = sub_mod x_xor_q_ (uint_to_t 1) in lemma_sub_msbs x y; lemma_msb_gte (v x) (v y); lemma_msb_gte (v y) (v x); c #reset-options (*** Infix notations *) unfold let op_Plus_Hat = add unfold let op_Plus_Question_Hat = add_underspec unfold let op_Plus_Percent_Hat = add_mod unfold let op_Subtraction_Hat = sub unfold let op_Subtraction_Question_Hat = sub_underspec unfold let op_Subtraction_Percent_Hat = sub_mod unfold let op_Star_Hat = mul unfold let op_Star_Question_Hat = mul_underspec unfold let op_Star_Percent_Hat = mul_mod unfold let op_Slash_Hat = div unfold let op_Percent_Hat = rem
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt32.fsti" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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
x: FStar.UInt32.t -> y: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t
Prims.Pure
[]
[]
[ "FStar.UInt32.logand" ]
[]
false
false
false
false
false
let op_Amp_Hat =
logand
false
FStar.UInt32.fsti
FStar.UInt32.op_Less_Hat
val op_Less_Hat : a: FStar.UInt32.t -> b: FStar.UInt32.t -> Prims.bool
let op_Less_Hat = lt
{ "file_name": "ulib/FStar.UInt32.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 27, "end_line": 335, "start_col": 7, "start_line": 335 }
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt32 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) unfold let n = 32 /// For FStar.UIntN.fstp: anything that you fix/update here should be /// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of /// this module. /// /// Except, as compared to [FStar.IntN.fstp], here: /// - every occurrence of [int_t] has been replaced with [uint_t] /// - every occurrence of [@%] has been replaced with [%]. /// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers /// This module provides an abstract type for machine integers of a /// given signedness and width. The interface is designed to be safe /// with respect to arithmetic underflow and overflow. /// Note, we have attempted several times to re-design this module to /// make it more amenable to normalization and to impose less overhead /// on the SMT solver when reasoning about machine integer /// arithmetic. The following github issue reports on the current /// status of that work. /// /// https://github.com/FStarLang/FStar/issues/1757 open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (** Abstract type of machine integers, with an underlying representation using a bounded mathematical integer *) new val t : eqtype (** A coercion that projects a bounded mathematical integer from a machine integer *) val v (x:t) : Tot (uint_t n) (** A coercion that injects a bounded mathematical integers into a machine integer *) val uint_to_t (x:uint_t n) : Pure t (requires True) (ensures (fun y -> v y = x)) (** Injection/projection inverse *) val uv_inv (x : t) : Lemma (ensures (uint_to_t (v x) == x)) [SMTPat (v x)] (** Projection/injection inverse *) val vu_inv (x : uint_t n) : Lemma (ensures (v (uint_to_t x) == x)) [SMTPat (uint_to_t x)] (** An alternate form of the injectivity of the [v] projection *) val v_inj (x1 x2: t): Lemma (requires (v x1 == v x2)) (ensures (x1 == x2)) (** Constants 0 and 1 *) val zero : x:t{v x = 0} val one : x:t{v x = 1} (**** Addition primitives *) (** Bounds-respecting addition The precondition enforces that the sum does not overflow, expressing the bound as an addition on mathematical integers *) val add (a:t) (b:t) : Pure t (requires (size (v a + v b) n)) (ensures (fun c -> v a + v b = v c)) (** Underspecified, possibly overflowing addition: The postcondition only enures that the result is the sum of the arguments in case there is no overflow *) val add_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a + v b) n ==> v a + v b = v c)) (** Addition modulo [2^n] Machine integers can always be added, but the postcondition is now in terms of addition modulo [2^n] on mathematical integers *) val add_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c)) (**** Subtraction primitives *) (** Bounds-respecting subtraction The precondition enforces that the difference does not underflow, expressing the bound as a difference on mathematical integers *) val sub (a:t) (b:t) : Pure t (requires (size (v a - v b) n)) (ensures (fun c -> v a - v b = v c)) (** Underspecified, possibly overflowing subtraction: The postcondition only enures that the result is the difference of the arguments in case there is no underflow *) val sub_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a - v b) n ==> v a - v b = v c)) (** Subtraction modulo [2^n] Machine integers can always be subtractd, but the postcondition is now in terms of subtraction modulo [2^n] on mathematical integers *) val sub_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c)) (**** Multiplication primitives *) (** Bounds-respecting multiplication The precondition enforces that the product does not overflow, expressing the bound as a product on mathematical integers *) val mul (a:t) (b:t) : Pure t (requires (size (v a * v b) n)) (ensures (fun c -> v a * v b = v c)) (** Underspecified, possibly overflowing product The postcondition only enures that the result is the product of the arguments in case there is no overflow *) val mul_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a * v b) n ==> v a * v b = v c)) (** Multiplication modulo [2^n] Machine integers can always be multiplied, but the postcondition is now in terms of product modulo [2^n] on mathematical integers *) val mul_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c)) (**** Division primitives *) (** Euclidean division of [a] and [b], with [b] non-zero *) val div (a:t) (b:t{v b <> 0}) : Pure t (requires (True)) (ensures (fun c -> v a / v b = v c)) (**** Modulo primitives *) (** Euclidean remainder The result is the modulus of [a] with respect to a non-zero [b] *) val rem (a:t) (b:t{v b <> 0}) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c)) (**** Bitwise operators *) /// Also see FStar.BV (** Bitwise logical conjunction *) val logand (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logand` v y = v z)) (** Bitwise logical exclusive-or *) val logxor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logxor` v y == v z)) (** Bitwise logical disjunction *) val logor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logor` v y == v z)) (** Bitwise logical negation *) val lognot (x:t) : Pure t (requires True) (ensures (fun z -> lognot (v x) == v z)) (**** Shift operators *) (** Shift right with zero fill, shifting at most the integer width *) val shift_right (a:t) (s:t) : Pure t (requires (v s < n)) (ensures (fun c -> FStar.UInt.shift_right (v a) (v s) = v c)) (** Shift left with zero fill, shifting at most the integer width *) val shift_left (a:t) (s:t) : Pure t (requires (v s < n)) (ensures (fun c -> FStar.UInt.shift_left (v a) (v s) = v c)) (**** Comparison operators *) (** Equality Note, it is safe to also use the polymorphic decidable equality operator [=] *) let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b) (** Greater than *) let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b) (** Greater than or equal *) let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b) (** Less than *) let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b) (** Less than or equal *) let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b) (** Unary negation *) inline_for_extraction let minus (a:t) = add_mod (lognot a) (uint_to_t 1) (** The maximum shift value for this type, i.e. its width minus one, as an *) inline_for_extraction let n_minus_one = uint_to_t (n - 1) #set-options "--z3rlimit 80 --initial_fuel 1 --max_fuel 1" (** A constant-time way to compute the equality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=2e60bb395c1f589a398ec606d611132ef9ef764b Note, the branching on [a=b] is just for proof-purposes. *) [@ CNoInline ] let eq_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\ (v a <> v b ==> v c = 0))) = let x = logxor a b in let minus_x = minus x in let x_or_minus_x = logor x minus_x in let xnx = shift_right x_or_minus_x n_minus_one in let c = sub_mod xnx (uint_to_t 1) in if a = b then begin logxor_self (v a); lognot_lemma_1 #n; logor_lemma_1 (v x); assert (v x = 0 /\ v minus_x = 0 /\ v x_or_minus_x = 0 /\ v xnx = 0); assert (v c = ones n) end else begin logxor_neq_nonzero (v a) (v b); lemma_msb_pow2 #n (v (lognot x)); lemma_msb_pow2 #n (v minus_x); lemma_minus_zero #n (v x); assert (v c = FStar.UInt.zero n) end; c private val lemma_sub_msbs (a:t) (b:t) : Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b)))) (** A constant-time way to compute the [>=] inequality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=0a483a9b431d87eca1b275463c632f8d5551978a *) [@ CNoInline ] let gte_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\ (v a < v b ==> v c = 0))) = let x = a in let y = b in let x_xor_y = logxor x y in let x_sub_y = sub_mod x y in let x_sub_y_xor_y = logxor x_sub_y y in let q = logor x_xor_y x_sub_y_xor_y in let x_xor_q = logxor x q in let x_xor_q_ = shift_right x_xor_q n_minus_one in let c = sub_mod x_xor_q_ (uint_to_t 1) in lemma_sub_msbs x y; lemma_msb_gte (v x) (v y); lemma_msb_gte (v y) (v x); c #reset-options (*** Infix notations *) unfold let op_Plus_Hat = add unfold let op_Plus_Question_Hat = add_underspec unfold let op_Plus_Percent_Hat = add_mod unfold let op_Subtraction_Hat = sub unfold let op_Subtraction_Question_Hat = sub_underspec unfold let op_Subtraction_Percent_Hat = sub_mod unfold let op_Star_Hat = mul unfold let op_Star_Question_Hat = mul_underspec unfold let op_Star_Percent_Hat = mul_mod unfold let op_Slash_Hat = div unfold let op_Percent_Hat = rem unfold let op_Hat_Hat = logxor unfold let op_Amp_Hat = logand unfold let op_Bar_Hat = logor unfold let op_Less_Less_Hat = shift_left unfold let op_Greater_Greater_Hat = shift_right unfold let op_Equals_Hat = eq unfold let op_Greater_Hat = gt
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt32.fsti" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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
a: FStar.UInt32.t -> b: FStar.UInt32.t -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.lt" ]
[]
false
false
false
true
false
let op_Less_Hat =
lt
false
Vale.X64.Decls.fst
Vale.X64.Decls.va_lemma_ifElseTrue_total
val va_lemma_ifElseTrue_total (ifb:ocmp) (ct:va_code) (cf:va_code) (s0:va_state) (f0:va_fuel) (sM:va_state) : Lemma (requires valid_ocmp ifb s0 /\ eval_ocmp s0 ifb /\ eval_code ct ({s0 with vs_flags = havoc_flags}) f0 sM ) (ensures eval_code (IfElse ifb ct cf) s0 f0 sM )
val va_lemma_ifElseTrue_total (ifb:ocmp) (ct:va_code) (cf:va_code) (s0:va_state) (f0:va_fuel) (sM:va_state) : Lemma (requires valid_ocmp ifb s0 /\ eval_ocmp s0 ifb /\ eval_code ct ({s0 with vs_flags = havoc_flags}) f0 sM ) (ensures eval_code (IfElse ifb ct cf) s0 f0 sM )
let va_lemma_ifElseTrue_total = Lemmas.lemma_ifElseTrue_total
{ "file_name": "vale/code/arch/x64/Vale.X64.Decls.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 61, "end_line": 137, "start_col": 0, "start_line": 137 }
module Vale.X64.Decls open FStar.Mul open Vale.X64.Machine_s open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open FStar.UInt module P = Vale.X64.Print_s module BC = Vale.X64.Bytes_Code_s module BS = Vale.X64.Machine_Semantics_s #reset-options "--max_fuel 0 --max_ifuel 0 --smtencoding.elim_box true --smtencoding.l_arith_repr boxwrap --smtencoding.nl_arith_repr boxwrap --z3cliopt smt.arith.nl=true --using_facts_from 'Prims FStar.UInt Vale.Def.Words_s FStar.UInt64'" let lemma_mul_in_bounds (x y:nat64) : Lemma (requires x * y < pow2_64) (ensures FStar.UInt.mul_mod #64 x y == x * y) = () #reset-options "--z3cliopt smt.arith.nl=true --using_facts_from Prims --using_facts_from FStar.Math" let lemma_mul_nat (x:nat) (y:nat) : Lemma (ensures 0 <= (x * y)) = () #reset-options "--initial_fuel 2 --max_fuel 2" let cf flags = match Lemmas.cf flags with | Some v -> v | None -> false let overflow flags = match Lemmas.overflow flags with | Some v -> v | None -> false let valid_cf flags = match Lemmas.cf flags with | Some v -> true | None -> false let valid_of flags = match Lemmas.overflow flags with | Some v -> true | None -> false let updated_cf new_flags new_cf = Lemmas.cf new_flags = Some new_cf let updated_of new_flags new_cf = Lemmas.overflow new_flags = Some new_cf let maintained_cf new_flags flags = Lemmas.cf new_flags = Lemmas.cf flags let maintained_of new_flags flags = Lemmas.overflow new_flags = Lemmas.overflow flags let ins = BS.ins type ocmp = BS.ocmp type va_fuel = nat type va_pbool = Vale.Def.PossiblyMonad.pbool let va_ttrue () = Vale.Def.PossiblyMonad.ttrue let va_ffalse = Vale.Def.PossiblyMonad.ffalse let va_pbool_and x y = Vale.Def.PossiblyMonad.((&&.)) x y let get_reason p = match p with | Vale.Def.PossiblyMonad.Ok () -> None | Vale.Def.PossiblyMonad.Err reason -> Some reason let mul_nat_helper x y = FStar.Math.Lemmas.nat_times_nat_is_nat x y let va_fuel_default () = 0 let lemma_opr_Mem64 (id:heaplet_id) (s:va_state) (base:operand64) (offset:int) (b:M.buffer64) (index:int) (t:taint) : Lemma (requires ( let h = Map16.sel s.vs_heap.vf_heaplets id in M.mem_inv s.vs_heap /\ OReg? base /\ valid_src_addr h b index /\ M.valid_layout_buffer b (s.vs_heap.vf_layout) h false /\ M.valid_taint_buf64 b h (full_heap_taint s.vs_heap) t /\ eval_operand base s + offset == M.buffer_addr b h + 8 * index )) (ensures ( let h = Map16.sel s.vs_heap.vf_heaplets id in valid_operand (va_opr_code_Mem64 id base offset t) s /\ M.load_mem64 (M.buffer_addr b h + 8 * index) (s.vs_heap.vf_heap) == M.buffer_read b index h )) = Vale.X64.Memory_Sems.low_lemma_load_mem64_full b index s.vs_heap t id; let h = M.get_vale_heap s.vs_heap in let t = va_opr_code_Mem64 id base offset t in M.lemma_valid_mem64 b index h; let OMem (m, t) = t in assert (valid_buf_maddr64 (eval_maddr m s) h s.vs_heap.vf_layout b index t); M.lemma_load_mem64 b index h let lemma_opr_Mem128 (id:heaplet_id) (s:va_state) (base:operand64) (offset:int) (t:taint) (b:M.buffer128) (index:int) : Lemma (requires ( let h = Map16.sel s.vs_heap.vf_heaplets id in M.mem_inv s.vs_heap /\ OReg? base /\ valid_src_addr h b index /\ M.valid_layout_buffer b (s.vs_heap.vf_layout) h false /\ M.valid_taint_buf128 b h (full_heap_taint s.vs_heap) t /\ eval_operand base s + offset == M.buffer_addr b h + 16 * index )) (ensures ( let h = Map16.sel s.vs_heap.vf_heaplets id in valid_operand128 (va_opr_code_Mem128 id base offset t) s /\ M.load_mem128 (M.buffer_addr b h + 16 * index) (M.get_vale_heap s.vs_heap) == M.buffer_read b index h )) = Vale.X64.Memory_Sems.low_lemma_load_mem128_full b index s.vs_heap t id; let h = M.get_vale_heap s.vs_heap in let t = va_opr_code_Mem128 id base offset t in M.lemma_valid_mem128 b index h; let OMem (m, t) = t in assert (valid_buf_maddr128 (eval_maddr m s) h s.vs_heap.vf_layout b index t); M.lemma_load_mem128 b index h let taint_at memTaint addr = Map.sel memTaint addr let va_cmp_eq o1 o2 = BC.OEq o1 o2 let va_cmp_ne o1 o2 = BC.ONe o1 o2 let va_cmp_le o1 o2 = BC.OLe o1 o2 let va_cmp_ge o1 o2 = BC.OGe o1 o2 let va_cmp_lt o1 o2 = BC.OLt o1 o2 let va_cmp_gt o1 o2 = BC.OGt o1 o2 let eval_code = Lemmas.eval_code let eval_while_inv = Lemmas.eval_while_inv let va_ins_lemma (c0:va_code) (s0:va_state) : Lemma (requires True) (ensures (forall (i:ins) (s:BS.machine_state).{:pattern (BS.machine_eval_code_ins i s)} BS.machine_eval_code_ins i s == BS.machine_eval_code_ins_def i s) ) = reveal_opaque (`%BS.machine_eval_code_ins) BS.machine_eval_code_ins let eval_ocmp = Lemmas.eval_ocmp let valid_ocmp = Lemmas.valid_ocmp let havoc_flags = Lemmas.havoc_flags unfold let va_eval_ins = Lemmas.eval_ins let lemma_cmp_eq s o1 o2 = () let lemma_cmp_ne s o1 o2 = () let lemma_cmp_le s o1 o2 = () let lemma_cmp_ge s o1 o2 = () let lemma_cmp_lt s o1 o2 = () let lemma_cmp_gt s o1 o2 = () let lemma_valid_cmp_eq s o1 o2 = () let lemma_valid_cmp_ne s o1 o2 = () let lemma_valid_cmp_le s o1 o2 = () let lemma_valid_cmp_ge s o1 o2 = () let lemma_valid_cmp_lt s o1 o2 = () let lemma_valid_cmp_gt s o1 o2 = () let va_compute_merge_total = Lemmas.compute_merge_total let va_lemma_merge_total b0 s0 f0 sM fM sN = Lemmas.lemma_merge_total b0 s0 f0 sM fM sN; Lemmas.compute_merge_total f0 fM let va_lemma_empty_total = Lemmas.lemma_empty_total
{ "checked_file": "/", "dependencies": [ "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory_Sems.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Lemmas.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Def.PossiblyMonad.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Map.fsti.checked", "FStar.IO.fst.checked" ], "interface_file": true, "source_file": "Vale.X64.Decls.fst" }
[ { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Stack_i", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "M" }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 2, "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
ifb: Vale.X64.Decls.ocmp -> ct: Vale.X64.Decls.va_code -> cf: Vale.X64.Decls.va_code -> s0: Vale.X64.Decls.va_state -> f0: Vale.X64.Decls.va_fuel -> sM: Vale.X64.Decls.va_state -> FStar.Pervasives.Lemma (requires Vale.X64.Decls.valid_ocmp ifb s0 /\ Vale.X64.Decls.eval_ocmp s0 ifb /\ Vale.X64.Decls.eval_code ct (Vale.X64.State.Mkvale_state (Mkvale_state?.vs_ok s0) (Mkvale_state?.vs_regs s0) Vale.X64.Decls.havoc_flags (Mkvale_state?.vs_heap s0) (Mkvale_state?.vs_stack s0) (Mkvale_state?.vs_stackTaint s0)) f0 sM) (ensures Vale.X64.Decls.eval_code (Vale.X64.Machine_s.IfElse ifb ct cf) s0 f0 sM)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.X64.Lemmas.lemma_ifElseTrue_total" ]
[]
true
false
true
false
false
let va_lemma_ifElseTrue_total =
Lemmas.lemma_ifElseTrue_total
false
FStar.UInt32.fsti
FStar.UInt32.op_Greater_Greater_Hat
val op_Greater_Greater_Hat : a: FStar.UInt32.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t
let op_Greater_Greater_Hat = shift_right
{ "file_name": "ulib/FStar.UInt32.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 47, "end_line": 331, "start_col": 7, "start_line": 331 }
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt32 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) unfold let n = 32 /// For FStar.UIntN.fstp: anything that you fix/update here should be /// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of /// this module. /// /// Except, as compared to [FStar.IntN.fstp], here: /// - every occurrence of [int_t] has been replaced with [uint_t] /// - every occurrence of [@%] has been replaced with [%]. /// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers /// This module provides an abstract type for machine integers of a /// given signedness and width. The interface is designed to be safe /// with respect to arithmetic underflow and overflow. /// Note, we have attempted several times to re-design this module to /// make it more amenable to normalization and to impose less overhead /// on the SMT solver when reasoning about machine integer /// arithmetic. The following github issue reports on the current /// status of that work. /// /// https://github.com/FStarLang/FStar/issues/1757 open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (** Abstract type of machine integers, with an underlying representation using a bounded mathematical integer *) new val t : eqtype (** A coercion that projects a bounded mathematical integer from a machine integer *) val v (x:t) : Tot (uint_t n) (** A coercion that injects a bounded mathematical integers into a machine integer *) val uint_to_t (x:uint_t n) : Pure t (requires True) (ensures (fun y -> v y = x)) (** Injection/projection inverse *) val uv_inv (x : t) : Lemma (ensures (uint_to_t (v x) == x)) [SMTPat (v x)] (** Projection/injection inverse *) val vu_inv (x : uint_t n) : Lemma (ensures (v (uint_to_t x) == x)) [SMTPat (uint_to_t x)] (** An alternate form of the injectivity of the [v] projection *) val v_inj (x1 x2: t): Lemma (requires (v x1 == v x2)) (ensures (x1 == x2)) (** Constants 0 and 1 *) val zero : x:t{v x = 0} val one : x:t{v x = 1} (**** Addition primitives *) (** Bounds-respecting addition The precondition enforces that the sum does not overflow, expressing the bound as an addition on mathematical integers *) val add (a:t) (b:t) : Pure t (requires (size (v a + v b) n)) (ensures (fun c -> v a + v b = v c)) (** Underspecified, possibly overflowing addition: The postcondition only enures that the result is the sum of the arguments in case there is no overflow *) val add_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a + v b) n ==> v a + v b = v c)) (** Addition modulo [2^n] Machine integers can always be added, but the postcondition is now in terms of addition modulo [2^n] on mathematical integers *) val add_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c)) (**** Subtraction primitives *) (** Bounds-respecting subtraction The precondition enforces that the difference does not underflow, expressing the bound as a difference on mathematical integers *) val sub (a:t) (b:t) : Pure t (requires (size (v a - v b) n)) (ensures (fun c -> v a - v b = v c)) (** Underspecified, possibly overflowing subtraction: The postcondition only enures that the result is the difference of the arguments in case there is no underflow *) val sub_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a - v b) n ==> v a - v b = v c)) (** Subtraction modulo [2^n] Machine integers can always be subtractd, but the postcondition is now in terms of subtraction modulo [2^n] on mathematical integers *) val sub_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c)) (**** Multiplication primitives *) (** Bounds-respecting multiplication The precondition enforces that the product does not overflow, expressing the bound as a product on mathematical integers *) val mul (a:t) (b:t) : Pure t (requires (size (v a * v b) n)) (ensures (fun c -> v a * v b = v c)) (** Underspecified, possibly overflowing product The postcondition only enures that the result is the product of the arguments in case there is no overflow *) val mul_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a * v b) n ==> v a * v b = v c)) (** Multiplication modulo [2^n] Machine integers can always be multiplied, but the postcondition is now in terms of product modulo [2^n] on mathematical integers *) val mul_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c)) (**** Division primitives *) (** Euclidean division of [a] and [b], with [b] non-zero *) val div (a:t) (b:t{v b <> 0}) : Pure t (requires (True)) (ensures (fun c -> v a / v b = v c)) (**** Modulo primitives *) (** Euclidean remainder The result is the modulus of [a] with respect to a non-zero [b] *) val rem (a:t) (b:t{v b <> 0}) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c)) (**** Bitwise operators *) /// Also see FStar.BV (** Bitwise logical conjunction *) val logand (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logand` v y = v z)) (** Bitwise logical exclusive-or *) val logxor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logxor` v y == v z)) (** Bitwise logical disjunction *) val logor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logor` v y == v z)) (** Bitwise logical negation *) val lognot (x:t) : Pure t (requires True) (ensures (fun z -> lognot (v x) == v z)) (**** Shift operators *) (** Shift right with zero fill, shifting at most the integer width *) val shift_right (a:t) (s:t) : Pure t (requires (v s < n)) (ensures (fun c -> FStar.UInt.shift_right (v a) (v s) = v c)) (** Shift left with zero fill, shifting at most the integer width *) val shift_left (a:t) (s:t) : Pure t (requires (v s < n)) (ensures (fun c -> FStar.UInt.shift_left (v a) (v s) = v c)) (**** Comparison operators *) (** Equality Note, it is safe to also use the polymorphic decidable equality operator [=] *) let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b) (** Greater than *) let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b) (** Greater than or equal *) let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b) (** Less than *) let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b) (** Less than or equal *) let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b) (** Unary negation *) inline_for_extraction let minus (a:t) = add_mod (lognot a) (uint_to_t 1) (** The maximum shift value for this type, i.e. its width minus one, as an *) inline_for_extraction let n_minus_one = uint_to_t (n - 1) #set-options "--z3rlimit 80 --initial_fuel 1 --max_fuel 1" (** A constant-time way to compute the equality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=2e60bb395c1f589a398ec606d611132ef9ef764b Note, the branching on [a=b] is just for proof-purposes. *) [@ CNoInline ] let eq_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\ (v a <> v b ==> v c = 0))) = let x = logxor a b in let minus_x = minus x in let x_or_minus_x = logor x minus_x in let xnx = shift_right x_or_minus_x n_minus_one in let c = sub_mod xnx (uint_to_t 1) in if a = b then begin logxor_self (v a); lognot_lemma_1 #n; logor_lemma_1 (v x); assert (v x = 0 /\ v minus_x = 0 /\ v x_or_minus_x = 0 /\ v xnx = 0); assert (v c = ones n) end else begin logxor_neq_nonzero (v a) (v b); lemma_msb_pow2 #n (v (lognot x)); lemma_msb_pow2 #n (v minus_x); lemma_minus_zero #n (v x); assert (v c = FStar.UInt.zero n) end; c private val lemma_sub_msbs (a:t) (b:t) : Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b)))) (** A constant-time way to compute the [>=] inequality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=0a483a9b431d87eca1b275463c632f8d5551978a *) [@ CNoInline ] let gte_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\ (v a < v b ==> v c = 0))) = let x = a in let y = b in let x_xor_y = logxor x y in let x_sub_y = sub_mod x y in let x_sub_y_xor_y = logxor x_sub_y y in let q = logor x_xor_y x_sub_y_xor_y in let x_xor_q = logxor x q in let x_xor_q_ = shift_right x_xor_q n_minus_one in let c = sub_mod x_xor_q_ (uint_to_t 1) in lemma_sub_msbs x y; lemma_msb_gte (v x) (v y); lemma_msb_gte (v y) (v x); c #reset-options (*** Infix notations *) unfold let op_Plus_Hat = add unfold let op_Plus_Question_Hat = add_underspec unfold let op_Plus_Percent_Hat = add_mod unfold let op_Subtraction_Hat = sub unfold let op_Subtraction_Question_Hat = sub_underspec unfold let op_Subtraction_Percent_Hat = sub_mod unfold let op_Star_Hat = mul unfold let op_Star_Question_Hat = mul_underspec unfold let op_Star_Percent_Hat = mul_mod unfold let op_Slash_Hat = div unfold let op_Percent_Hat = rem unfold let op_Hat_Hat = logxor unfold let op_Amp_Hat = logand unfold let op_Bar_Hat = logor
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt32.fsti" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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
a: FStar.UInt32.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t
Prims.Pure
[]
[]
[ "FStar.UInt32.shift_right" ]
[]
false
false
false
false
false
let op_Greater_Greater_Hat =
shift_right
false
FStar.UInt32.fsti
FStar.UInt32.op_Greater_Equals_Hat
val op_Greater_Equals_Hat : a: FStar.UInt32.t -> b: FStar.UInt32.t -> Prims.bool
let op_Greater_Equals_Hat = gte
{ "file_name": "ulib/FStar.UInt32.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 38, "end_line": 334, "start_col": 7, "start_line": 334 }
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt32 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) unfold let n = 32 /// For FStar.UIntN.fstp: anything that you fix/update here should be /// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of /// this module. /// /// Except, as compared to [FStar.IntN.fstp], here: /// - every occurrence of [int_t] has been replaced with [uint_t] /// - every occurrence of [@%] has been replaced with [%]. /// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers /// This module provides an abstract type for machine integers of a /// given signedness and width. The interface is designed to be safe /// with respect to arithmetic underflow and overflow. /// Note, we have attempted several times to re-design this module to /// make it more amenable to normalization and to impose less overhead /// on the SMT solver when reasoning about machine integer /// arithmetic. The following github issue reports on the current /// status of that work. /// /// https://github.com/FStarLang/FStar/issues/1757 open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (** Abstract type of machine integers, with an underlying representation using a bounded mathematical integer *) new val t : eqtype (** A coercion that projects a bounded mathematical integer from a machine integer *) val v (x:t) : Tot (uint_t n) (** A coercion that injects a bounded mathematical integers into a machine integer *) val uint_to_t (x:uint_t n) : Pure t (requires True) (ensures (fun y -> v y = x)) (** Injection/projection inverse *) val uv_inv (x : t) : Lemma (ensures (uint_to_t (v x) == x)) [SMTPat (v x)] (** Projection/injection inverse *) val vu_inv (x : uint_t n) : Lemma (ensures (v (uint_to_t x) == x)) [SMTPat (uint_to_t x)] (** An alternate form of the injectivity of the [v] projection *) val v_inj (x1 x2: t): Lemma (requires (v x1 == v x2)) (ensures (x1 == x2)) (** Constants 0 and 1 *) val zero : x:t{v x = 0} val one : x:t{v x = 1} (**** Addition primitives *) (** Bounds-respecting addition The precondition enforces that the sum does not overflow, expressing the bound as an addition on mathematical integers *) val add (a:t) (b:t) : Pure t (requires (size (v a + v b) n)) (ensures (fun c -> v a + v b = v c)) (** Underspecified, possibly overflowing addition: The postcondition only enures that the result is the sum of the arguments in case there is no overflow *) val add_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a + v b) n ==> v a + v b = v c)) (** Addition modulo [2^n] Machine integers can always be added, but the postcondition is now in terms of addition modulo [2^n] on mathematical integers *) val add_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c)) (**** Subtraction primitives *) (** Bounds-respecting subtraction The precondition enforces that the difference does not underflow, expressing the bound as a difference on mathematical integers *) val sub (a:t) (b:t) : Pure t (requires (size (v a - v b) n)) (ensures (fun c -> v a - v b = v c)) (** Underspecified, possibly overflowing subtraction: The postcondition only enures that the result is the difference of the arguments in case there is no underflow *) val sub_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a - v b) n ==> v a - v b = v c)) (** Subtraction modulo [2^n] Machine integers can always be subtractd, but the postcondition is now in terms of subtraction modulo [2^n] on mathematical integers *) val sub_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c)) (**** Multiplication primitives *) (** Bounds-respecting multiplication The precondition enforces that the product does not overflow, expressing the bound as a product on mathematical integers *) val mul (a:t) (b:t) : Pure t (requires (size (v a * v b) n)) (ensures (fun c -> v a * v b = v c)) (** Underspecified, possibly overflowing product The postcondition only enures that the result is the product of the arguments in case there is no overflow *) val mul_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a * v b) n ==> v a * v b = v c)) (** Multiplication modulo [2^n] Machine integers can always be multiplied, but the postcondition is now in terms of product modulo [2^n] on mathematical integers *) val mul_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c)) (**** Division primitives *) (** Euclidean division of [a] and [b], with [b] non-zero *) val div (a:t) (b:t{v b <> 0}) : Pure t (requires (True)) (ensures (fun c -> v a / v b = v c)) (**** Modulo primitives *) (** Euclidean remainder The result is the modulus of [a] with respect to a non-zero [b] *) val rem (a:t) (b:t{v b <> 0}) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c)) (**** Bitwise operators *) /// Also see FStar.BV (** Bitwise logical conjunction *) val logand (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logand` v y = v z)) (** Bitwise logical exclusive-or *) val logxor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logxor` v y == v z)) (** Bitwise logical disjunction *) val logor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logor` v y == v z)) (** Bitwise logical negation *) val lognot (x:t) : Pure t (requires True) (ensures (fun z -> lognot (v x) == v z)) (**** Shift operators *) (** Shift right with zero fill, shifting at most the integer width *) val shift_right (a:t) (s:t) : Pure t (requires (v s < n)) (ensures (fun c -> FStar.UInt.shift_right (v a) (v s) = v c)) (** Shift left with zero fill, shifting at most the integer width *) val shift_left (a:t) (s:t) : Pure t (requires (v s < n)) (ensures (fun c -> FStar.UInt.shift_left (v a) (v s) = v c)) (**** Comparison operators *) (** Equality Note, it is safe to also use the polymorphic decidable equality operator [=] *) let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b) (** Greater than *) let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b) (** Greater than or equal *) let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b) (** Less than *) let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b) (** Less than or equal *) let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b) (** Unary negation *) inline_for_extraction let minus (a:t) = add_mod (lognot a) (uint_to_t 1) (** The maximum shift value for this type, i.e. its width minus one, as an *) inline_for_extraction let n_minus_one = uint_to_t (n - 1) #set-options "--z3rlimit 80 --initial_fuel 1 --max_fuel 1" (** A constant-time way to compute the equality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=2e60bb395c1f589a398ec606d611132ef9ef764b Note, the branching on [a=b] is just for proof-purposes. *) [@ CNoInline ] let eq_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\ (v a <> v b ==> v c = 0))) = let x = logxor a b in let minus_x = minus x in let x_or_minus_x = logor x minus_x in let xnx = shift_right x_or_minus_x n_minus_one in let c = sub_mod xnx (uint_to_t 1) in if a = b then begin logxor_self (v a); lognot_lemma_1 #n; logor_lemma_1 (v x); assert (v x = 0 /\ v minus_x = 0 /\ v x_or_minus_x = 0 /\ v xnx = 0); assert (v c = ones n) end else begin logxor_neq_nonzero (v a) (v b); lemma_msb_pow2 #n (v (lognot x)); lemma_msb_pow2 #n (v minus_x); lemma_minus_zero #n (v x); assert (v c = FStar.UInt.zero n) end; c private val lemma_sub_msbs (a:t) (b:t) : Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b)))) (** A constant-time way to compute the [>=] inequality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=0a483a9b431d87eca1b275463c632f8d5551978a *) [@ CNoInline ] let gte_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\ (v a < v b ==> v c = 0))) = let x = a in let y = b in let x_xor_y = logxor x y in let x_sub_y = sub_mod x y in let x_sub_y_xor_y = logxor x_sub_y y in let q = logor x_xor_y x_sub_y_xor_y in let x_xor_q = logxor x q in let x_xor_q_ = shift_right x_xor_q n_minus_one in let c = sub_mod x_xor_q_ (uint_to_t 1) in lemma_sub_msbs x y; lemma_msb_gte (v x) (v y); lemma_msb_gte (v y) (v x); c #reset-options (*** Infix notations *) unfold let op_Plus_Hat = add unfold let op_Plus_Question_Hat = add_underspec unfold let op_Plus_Percent_Hat = add_mod unfold let op_Subtraction_Hat = sub unfold let op_Subtraction_Question_Hat = sub_underspec unfold let op_Subtraction_Percent_Hat = sub_mod unfold let op_Star_Hat = mul unfold let op_Star_Question_Hat = mul_underspec unfold let op_Star_Percent_Hat = mul_mod unfold let op_Slash_Hat = div unfold let op_Percent_Hat = rem unfold let op_Hat_Hat = logxor unfold let op_Amp_Hat = logand unfold let op_Bar_Hat = logor unfold let op_Less_Less_Hat = shift_left unfold let op_Greater_Greater_Hat = shift_right unfold let op_Equals_Hat = eq
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt32.fsti" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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
a: FStar.UInt32.t -> b: FStar.UInt32.t -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.gte" ]
[]
false
false
false
true
false
let op_Greater_Equals_Hat =
gte
false
Vale.PPC64LE.Stack_i.fst
Vale.PPC64LE.Stack_i.lemma_store_new_valid64
val lemma_store_new_valid64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma (valid_src_stack64 ptr (store_stack64 ptr v h)) [SMTPat (valid_src_stack64 ptr (store_stack64 ptr v h))]
val lemma_store_new_valid64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma (valid_src_stack64 ptr (store_stack64 ptr v h)) [SMTPat (valid_src_stack64 ptr (store_stack64 ptr v h))]
let lemma_store_new_valid64 ptr v h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap64_reveal ()
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Stack_i.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 28, "end_line": 45, "start_col": 0, "start_line": 43 }
module Vale.PPC64LE.Stack_i open FStar.Mul module BS = Vale.PPC64LE.Semantics_s open Vale.Arch.MachineHeap let vale_stack = machine_stack let valid_src_stack64 i st = BS.valid_src_stack64 i st let load_stack64 i st = BS.eval_stack i st let store_stack64 i v h = BS.update_stack64' i v h let free_stack64 start finish h = BS.free_stack' start finish h let valid_src_stack128 i st = BS.valid_src_stack128 i st let load_stack128 i st = BS.eval_stack128 i st let store_stack128 i v h = BS.update_stack128' i v h let free_stack128 start finish h = BS.free_stack' start finish h let init_r1 h = h.initial_r1 (* Lemmas *) #push-options "--z3rlimit 40" let lemma_store_stack_same_valid64 ptr v h i = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap64_reveal () let lemma_free_stack_same_valid64 start finish ptr h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish) let lemma_store_stack_same_valid128 ptr v h i = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; BS.update_heap32_reveal (); BS.update_heap128_reveal () let lemma_free_stack_same_valid128 start finish ptr h = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish)
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.Stack_i.fst" }
[ { "abbrev": false, "full_module": "Vale.Arch.MachineHeap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "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": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ptr: Prims.int -> v: Vale.PPC64LE.Memory.nat64 -> h: Vale.PPC64LE.Stack_i.vale_stack -> FStar.Pervasives.Lemma (ensures Vale.PPC64LE.Stack_i.valid_src_stack64 ptr (Vale.PPC64LE.Stack_i.store_stack64 ptr v h)) [ SMTPat (Vale.PPC64LE.Stack_i.valid_src_stack64 ptr (Vale.PPC64LE.Stack_i.store_stack64 ptr v h)) ]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.int", "Vale.PPC64LE.Memory.nat64", "Vale.PPC64LE.Stack_i.vale_stack", "Vale.Arch.MachineHeap_s.update_heap64_reveal", "Prims.unit", "FStar.Pervasives.reveal_opaque", "Vale.Arch.MachineHeap_s.machine_heap", "Prims.bool", "Vale.Arch.MachineHeap_s.valid_addr64" ]
[]
true
false
true
false
false
let lemma_store_new_valid64 ptr v h =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap64_reveal ()
false
Vale.PPC64LE.Stack_i.fst
Vale.PPC64LE.Stack_i.lemma_store_new_valid128
val lemma_store_new_valid128 (ptr:int) (v:quad32) (h:vale_stack) : Lemma (valid_src_stack128 ptr (store_stack128 ptr v h)) [SMTPat (valid_src_stack128 ptr (store_stack128 ptr v h))]
val lemma_store_new_valid128 (ptr:int) (v:quad32) (h:vale_stack) : Lemma (valid_src_stack128 ptr (store_stack128 ptr v h)) [SMTPat (valid_src_stack128 ptr (store_stack128 ptr v h))]
let lemma_store_new_valid128 ptr v h = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; BS.update_heap32_reveal (); BS.update_heap128_reveal ()
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Stack_i.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 29, "end_line": 50, "start_col": 0, "start_line": 47 }
module Vale.PPC64LE.Stack_i open FStar.Mul module BS = Vale.PPC64LE.Semantics_s open Vale.Arch.MachineHeap let vale_stack = machine_stack let valid_src_stack64 i st = BS.valid_src_stack64 i st let load_stack64 i st = BS.eval_stack i st let store_stack64 i v h = BS.update_stack64' i v h let free_stack64 start finish h = BS.free_stack' start finish h let valid_src_stack128 i st = BS.valid_src_stack128 i st let load_stack128 i st = BS.eval_stack128 i st let store_stack128 i v h = BS.update_stack128' i v h let free_stack128 start finish h = BS.free_stack' start finish h let init_r1 h = h.initial_r1 (* Lemmas *) #push-options "--z3rlimit 40" let lemma_store_stack_same_valid64 ptr v h i = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap64_reveal () let lemma_free_stack_same_valid64 start finish ptr h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish) let lemma_store_stack_same_valid128 ptr v h i = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; BS.update_heap32_reveal (); BS.update_heap128_reveal () let lemma_free_stack_same_valid128 start finish ptr h = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish) let lemma_store_new_valid64 ptr v h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap64_reveal ()
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.Stack_i.fst" }
[ { "abbrev": false, "full_module": "Vale.Arch.MachineHeap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "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": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ptr: Prims.int -> v: Vale.PPC64LE.Memory.quad32 -> h: Vale.PPC64LE.Stack_i.vale_stack -> FStar.Pervasives.Lemma (ensures Vale.PPC64LE.Stack_i.valid_src_stack128 ptr (Vale.PPC64LE.Stack_i.store_stack128 ptr v h)) [ SMTPat (Vale.PPC64LE.Stack_i.valid_src_stack128 ptr (Vale.PPC64LE.Stack_i.store_stack128 ptr v h)) ]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.int", "Vale.PPC64LE.Memory.quad32", "Vale.PPC64LE.Stack_i.vale_stack", "Vale.Arch.MachineHeap_s.update_heap128_reveal", "Prims.unit", "Vale.Arch.MachineHeap_s.update_heap32_reveal", "FStar.Pervasives.reveal_opaque", "Vale.Arch.MachineHeap_s.machine_heap", "Prims.bool", "Vale.Arch.MachineHeap_s.valid_addr128" ]
[]
true
false
true
false
false
let lemma_store_new_valid128 ptr v h =
reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; BS.update_heap32_reveal (); BS.update_heap128_reveal ()
false
Vale.PPC64LE.Stack_i.fst
Vale.PPC64LE.Stack_i.lemma_frame_store_load_stack64
val lemma_frame_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack64 i h /\ (i >= ptr + 8 \/ i + 8 <= ptr)) (ensures (load_stack64 i (store_stack64 ptr v h) == load_stack64 i h)) [SMTPat (load_stack64 i (store_stack64 ptr v h))]
val lemma_frame_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack64 i h /\ (i >= ptr + 8 \/ i + 8 <= ptr)) (ensures (load_stack64 i (store_stack64 ptr v h) == load_stack64 i h)) [SMTPat (load_stack64 i (store_stack64 ptr v h))]
let lemma_frame_store_load_stack64 ptr v h i = let Machine_stack _ mem = h in frame_update_heap64 ptr v mem; BS.get_heap_val64_reveal ()
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Stack_i.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 29, "end_line": 60, "start_col": 0, "start_line": 57 }
module Vale.PPC64LE.Stack_i open FStar.Mul module BS = Vale.PPC64LE.Semantics_s open Vale.Arch.MachineHeap let vale_stack = machine_stack let valid_src_stack64 i st = BS.valid_src_stack64 i st let load_stack64 i st = BS.eval_stack i st let store_stack64 i v h = BS.update_stack64' i v h let free_stack64 start finish h = BS.free_stack' start finish h let valid_src_stack128 i st = BS.valid_src_stack128 i st let load_stack128 i st = BS.eval_stack128 i st let store_stack128 i v h = BS.update_stack128' i v h let free_stack128 start finish h = BS.free_stack' start finish h let init_r1 h = h.initial_r1 (* Lemmas *) #push-options "--z3rlimit 40" let lemma_store_stack_same_valid64 ptr v h i = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap64_reveal () let lemma_free_stack_same_valid64 start finish ptr h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish) let lemma_store_stack_same_valid128 ptr v h i = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; BS.update_heap32_reveal (); BS.update_heap128_reveal () let lemma_free_stack_same_valid128 start finish ptr h = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish) let lemma_store_new_valid64 ptr v h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap64_reveal () let lemma_store_new_valid128 ptr v h = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; BS.update_heap32_reveal (); BS.update_heap128_reveal () #pop-options let lemma_correct_store_load_stack64 ptr v h = let Machine_stack _ mem = h in correct_update_get64 ptr v mem
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.Stack_i.fst" }
[ { "abbrev": false, "full_module": "Vale.Arch.MachineHeap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "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
ptr: Prims.int -> v: Vale.PPC64LE.Memory.nat64 -> h: Vale.PPC64LE.Stack_i.vale_stack -> i: Prims.int -> FStar.Pervasives.Lemma (requires Vale.PPC64LE.Stack_i.valid_src_stack64 i h /\ (i >= ptr + 8 \/ i + 8 <= ptr)) (ensures Vale.PPC64LE.Stack_i.load_stack64 i (Vale.PPC64LE.Stack_i.store_stack64 ptr v h) == Vale.PPC64LE.Stack_i.load_stack64 i h) [SMTPat (Vale.PPC64LE.Stack_i.load_stack64 i (Vale.PPC64LE.Stack_i.store_stack64 ptr v h))]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.int", "Vale.PPC64LE.Memory.nat64", "Vale.PPC64LE.Stack_i.vale_stack", "Vale.PPC64LE.Machine_s.nat64", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.Map.t", "Vale.PPC64LE.Machine_s.nat8", "Vale.Arch.MachineHeap_s.get_heap_val64_reveal", "Prims.unit", "Vale.Arch.MachineHeap.frame_update_heap64" ]
[]
false
false
true
false
false
let lemma_frame_store_load_stack64 ptr v h i =
let Machine_stack _ mem = h in frame_update_heap64 ptr v mem; BS.get_heap_val64_reveal ()
false
FStar.UInt32.fsti
FStar.UInt32.op_Less_Equals_Hat
val op_Less_Equals_Hat : a: FStar.UInt32.t -> b: FStar.UInt32.t -> Prims.bool
let op_Less_Equals_Hat = lte
{ "file_name": "ulib/FStar.UInt32.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 35, "end_line": 336, "start_col": 7, "start_line": 336 }
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt32 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) unfold let n = 32 /// For FStar.UIntN.fstp: anything that you fix/update here should be /// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of /// this module. /// /// Except, as compared to [FStar.IntN.fstp], here: /// - every occurrence of [int_t] has been replaced with [uint_t] /// - every occurrence of [@%] has been replaced with [%]. /// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers /// This module provides an abstract type for machine integers of a /// given signedness and width. The interface is designed to be safe /// with respect to arithmetic underflow and overflow. /// Note, we have attempted several times to re-design this module to /// make it more amenable to normalization and to impose less overhead /// on the SMT solver when reasoning about machine integer /// arithmetic. The following github issue reports on the current /// status of that work. /// /// https://github.com/FStarLang/FStar/issues/1757 open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (** Abstract type of machine integers, with an underlying representation using a bounded mathematical integer *) new val t : eqtype (** A coercion that projects a bounded mathematical integer from a machine integer *) val v (x:t) : Tot (uint_t n) (** A coercion that injects a bounded mathematical integers into a machine integer *) val uint_to_t (x:uint_t n) : Pure t (requires True) (ensures (fun y -> v y = x)) (** Injection/projection inverse *) val uv_inv (x : t) : Lemma (ensures (uint_to_t (v x) == x)) [SMTPat (v x)] (** Projection/injection inverse *) val vu_inv (x : uint_t n) : Lemma (ensures (v (uint_to_t x) == x)) [SMTPat (uint_to_t x)] (** An alternate form of the injectivity of the [v] projection *) val v_inj (x1 x2: t): Lemma (requires (v x1 == v x2)) (ensures (x1 == x2)) (** Constants 0 and 1 *) val zero : x:t{v x = 0} val one : x:t{v x = 1} (**** Addition primitives *) (** Bounds-respecting addition The precondition enforces that the sum does not overflow, expressing the bound as an addition on mathematical integers *) val add (a:t) (b:t) : Pure t (requires (size (v a + v b) n)) (ensures (fun c -> v a + v b = v c)) (** Underspecified, possibly overflowing addition: The postcondition only enures that the result is the sum of the arguments in case there is no overflow *) val add_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a + v b) n ==> v a + v b = v c)) (** Addition modulo [2^n] Machine integers can always be added, but the postcondition is now in terms of addition modulo [2^n] on mathematical integers *) val add_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c)) (**** Subtraction primitives *) (** Bounds-respecting subtraction The precondition enforces that the difference does not underflow, expressing the bound as a difference on mathematical integers *) val sub (a:t) (b:t) : Pure t (requires (size (v a - v b) n)) (ensures (fun c -> v a - v b = v c)) (** Underspecified, possibly overflowing subtraction: The postcondition only enures that the result is the difference of the arguments in case there is no underflow *) val sub_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a - v b) n ==> v a - v b = v c)) (** Subtraction modulo [2^n] Machine integers can always be subtractd, but the postcondition is now in terms of subtraction modulo [2^n] on mathematical integers *) val sub_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c)) (**** Multiplication primitives *) (** Bounds-respecting multiplication The precondition enforces that the product does not overflow, expressing the bound as a product on mathematical integers *) val mul (a:t) (b:t) : Pure t (requires (size (v a * v b) n)) (ensures (fun c -> v a * v b = v c)) (** Underspecified, possibly overflowing product The postcondition only enures that the result is the product of the arguments in case there is no overflow *) val mul_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a * v b) n ==> v a * v b = v c)) (** Multiplication modulo [2^n] Machine integers can always be multiplied, but the postcondition is now in terms of product modulo [2^n] on mathematical integers *) val mul_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c)) (**** Division primitives *) (** Euclidean division of [a] and [b], with [b] non-zero *) val div (a:t) (b:t{v b <> 0}) : Pure t (requires (True)) (ensures (fun c -> v a / v b = v c)) (**** Modulo primitives *) (** Euclidean remainder The result is the modulus of [a] with respect to a non-zero [b] *) val rem (a:t) (b:t{v b <> 0}) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c)) (**** Bitwise operators *) /// Also see FStar.BV (** Bitwise logical conjunction *) val logand (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logand` v y = v z)) (** Bitwise logical exclusive-or *) val logxor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logxor` v y == v z)) (** Bitwise logical disjunction *) val logor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logor` v y == v z)) (** Bitwise logical negation *) val lognot (x:t) : Pure t (requires True) (ensures (fun z -> lognot (v x) == v z)) (**** Shift operators *) (** Shift right with zero fill, shifting at most the integer width *) val shift_right (a:t) (s:t) : Pure t (requires (v s < n)) (ensures (fun c -> FStar.UInt.shift_right (v a) (v s) = v c)) (** Shift left with zero fill, shifting at most the integer width *) val shift_left (a:t) (s:t) : Pure t (requires (v s < n)) (ensures (fun c -> FStar.UInt.shift_left (v a) (v s) = v c)) (**** Comparison operators *) (** Equality Note, it is safe to also use the polymorphic decidable equality operator [=] *) let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b) (** Greater than *) let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b) (** Greater than or equal *) let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b) (** Less than *) let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b) (** Less than or equal *) let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b) (** Unary negation *) inline_for_extraction let minus (a:t) = add_mod (lognot a) (uint_to_t 1) (** The maximum shift value for this type, i.e. its width minus one, as an *) inline_for_extraction let n_minus_one = uint_to_t (n - 1) #set-options "--z3rlimit 80 --initial_fuel 1 --max_fuel 1" (** A constant-time way to compute the equality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=2e60bb395c1f589a398ec606d611132ef9ef764b Note, the branching on [a=b] is just for proof-purposes. *) [@ CNoInline ] let eq_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\ (v a <> v b ==> v c = 0))) = let x = logxor a b in let minus_x = minus x in let x_or_minus_x = logor x minus_x in let xnx = shift_right x_or_minus_x n_minus_one in let c = sub_mod xnx (uint_to_t 1) in if a = b then begin logxor_self (v a); lognot_lemma_1 #n; logor_lemma_1 (v x); assert (v x = 0 /\ v minus_x = 0 /\ v x_or_minus_x = 0 /\ v xnx = 0); assert (v c = ones n) end else begin logxor_neq_nonzero (v a) (v b); lemma_msb_pow2 #n (v (lognot x)); lemma_msb_pow2 #n (v minus_x); lemma_minus_zero #n (v x); assert (v c = FStar.UInt.zero n) end; c private val lemma_sub_msbs (a:t) (b:t) : Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b)))) (** A constant-time way to compute the [>=] inequality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=0a483a9b431d87eca1b275463c632f8d5551978a *) [@ CNoInline ] let gte_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\ (v a < v b ==> v c = 0))) = let x = a in let y = b in let x_xor_y = logxor x y in let x_sub_y = sub_mod x y in let x_sub_y_xor_y = logxor x_sub_y y in let q = logor x_xor_y x_sub_y_xor_y in let x_xor_q = logxor x q in let x_xor_q_ = shift_right x_xor_q n_minus_one in let c = sub_mod x_xor_q_ (uint_to_t 1) in lemma_sub_msbs x y; lemma_msb_gte (v x) (v y); lemma_msb_gte (v y) (v x); c #reset-options (*** Infix notations *) unfold let op_Plus_Hat = add unfold let op_Plus_Question_Hat = add_underspec unfold let op_Plus_Percent_Hat = add_mod unfold let op_Subtraction_Hat = sub unfold let op_Subtraction_Question_Hat = sub_underspec unfold let op_Subtraction_Percent_Hat = sub_mod unfold let op_Star_Hat = mul unfold let op_Star_Question_Hat = mul_underspec unfold let op_Star_Percent_Hat = mul_mod unfold let op_Slash_Hat = div unfold let op_Percent_Hat = rem unfold let op_Hat_Hat = logxor unfold let op_Amp_Hat = logand unfold let op_Bar_Hat = logor unfold let op_Less_Less_Hat = shift_left unfold let op_Greater_Greater_Hat = shift_right unfold let op_Equals_Hat = eq unfold let op_Greater_Hat = gt unfold let op_Greater_Equals_Hat = gte
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt32.fsti" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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
a: FStar.UInt32.t -> b: FStar.UInt32.t -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.lte" ]
[]
false
false
false
true
false
let op_Less_Equals_Hat =
lte
false
Vale.PPC64LE.Stack_i.fst
Vale.PPC64LE.Stack_i.lemma_correct_store_load_stack64
val lemma_correct_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma (load_stack64 ptr (store_stack64 ptr v h) == v) [SMTPat (load_stack64 ptr (store_stack64 ptr v h))]
val lemma_correct_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma (load_stack64 ptr (store_stack64 ptr v h) == v) [SMTPat (load_stack64 ptr (store_stack64 ptr v h))]
let lemma_correct_store_load_stack64 ptr v h = let Machine_stack _ mem = h in correct_update_get64 ptr v mem
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Stack_i.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 32, "end_line": 55, "start_col": 0, "start_line": 53 }
module Vale.PPC64LE.Stack_i open FStar.Mul module BS = Vale.PPC64LE.Semantics_s open Vale.Arch.MachineHeap let vale_stack = machine_stack let valid_src_stack64 i st = BS.valid_src_stack64 i st let load_stack64 i st = BS.eval_stack i st let store_stack64 i v h = BS.update_stack64' i v h let free_stack64 start finish h = BS.free_stack' start finish h let valid_src_stack128 i st = BS.valid_src_stack128 i st let load_stack128 i st = BS.eval_stack128 i st let store_stack128 i v h = BS.update_stack128' i v h let free_stack128 start finish h = BS.free_stack' start finish h let init_r1 h = h.initial_r1 (* Lemmas *) #push-options "--z3rlimit 40" let lemma_store_stack_same_valid64 ptr v h i = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap64_reveal () let lemma_free_stack_same_valid64 start finish ptr h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish) let lemma_store_stack_same_valid128 ptr v h i = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; BS.update_heap32_reveal (); BS.update_heap128_reveal () let lemma_free_stack_same_valid128 start finish ptr h = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish) let lemma_store_new_valid64 ptr v h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap64_reveal () let lemma_store_new_valid128 ptr v h = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; BS.update_heap32_reveal (); BS.update_heap128_reveal () #pop-options
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.Stack_i.fst" }
[ { "abbrev": false, "full_module": "Vale.Arch.MachineHeap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "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
ptr: Prims.int -> v: Vale.PPC64LE.Memory.nat64 -> h: Vale.PPC64LE.Stack_i.vale_stack -> FStar.Pervasives.Lemma (ensures Vale.PPC64LE.Stack_i.load_stack64 ptr (Vale.PPC64LE.Stack_i.store_stack64 ptr v h) == v) [SMTPat (Vale.PPC64LE.Stack_i.load_stack64 ptr (Vale.PPC64LE.Stack_i.store_stack64 ptr v h))]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.int", "Vale.PPC64LE.Memory.nat64", "Vale.PPC64LE.Stack_i.vale_stack", "Vale.PPC64LE.Machine_s.nat64", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.Map.t", "Vale.PPC64LE.Machine_s.nat8", "Vale.Arch.MachineHeap.correct_update_get64", "Prims.unit" ]
[]
false
false
true
false
false
let lemma_correct_store_load_stack64 ptr v h =
let Machine_stack _ mem = h in correct_update_get64 ptr v mem
false
Vale.PPC64LE.Stack_i.fst
Vale.PPC64LE.Stack_i.lemma_store_stack_same_valid128
val lemma_store_stack_same_valid128 (ptr:int) (v:quad32) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack128 i h /\ (i >= ptr + 16 \/ i + 16 <= ptr)) (ensures valid_src_stack128 i (store_stack128 ptr v h)) [SMTPat (valid_src_stack128 i (store_stack128 ptr v h))]
val lemma_store_stack_same_valid128 (ptr:int) (v:quad32) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack128 i h /\ (i >= ptr + 16 \/ i + 16 <= ptr)) (ensures valid_src_stack128 i (store_stack128 ptr v h)) [SMTPat (valid_src_stack128 i (store_stack128 ptr v h))]
let lemma_store_stack_same_valid128 ptr v h i = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; BS.update_heap32_reveal (); BS.update_heap128_reveal ()
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Stack_i.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 29, "end_line": 35, "start_col": 0, "start_line": 32 }
module Vale.PPC64LE.Stack_i open FStar.Mul module BS = Vale.PPC64LE.Semantics_s open Vale.Arch.MachineHeap let vale_stack = machine_stack let valid_src_stack64 i st = BS.valid_src_stack64 i st let load_stack64 i st = BS.eval_stack i st let store_stack64 i v h = BS.update_stack64' i v h let free_stack64 start finish h = BS.free_stack' start finish h let valid_src_stack128 i st = BS.valid_src_stack128 i st let load_stack128 i st = BS.eval_stack128 i st let store_stack128 i v h = BS.update_stack128' i v h let free_stack128 start finish h = BS.free_stack' start finish h let init_r1 h = h.initial_r1 (* Lemmas *) #push-options "--z3rlimit 40" let lemma_store_stack_same_valid64 ptr v h i = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap64_reveal () let lemma_free_stack_same_valid64 start finish ptr h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish)
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.Stack_i.fst" }
[ { "abbrev": false, "full_module": "Vale.Arch.MachineHeap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "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": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ptr: Prims.int -> v: Vale.PPC64LE.Memory.quad32 -> h: Vale.PPC64LE.Stack_i.vale_stack -> i: Prims.int -> FStar.Pervasives.Lemma (requires Vale.PPC64LE.Stack_i.valid_src_stack128 i h /\ (i >= ptr + 16 \/ i + 16 <= ptr)) (ensures Vale.PPC64LE.Stack_i.valid_src_stack128 i (Vale.PPC64LE.Stack_i.store_stack128 ptr v h)) [ SMTPat (Vale.PPC64LE.Stack_i.valid_src_stack128 i (Vale.PPC64LE.Stack_i.store_stack128 ptr v h)) ]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.int", "Vale.PPC64LE.Memory.quad32", "Vale.PPC64LE.Stack_i.vale_stack", "Vale.Arch.MachineHeap_s.update_heap128_reveal", "Prims.unit", "Vale.Arch.MachineHeap_s.update_heap32_reveal", "FStar.Pervasives.reveal_opaque", "Vale.Arch.MachineHeap_s.machine_heap", "Prims.bool", "Vale.Arch.MachineHeap_s.valid_addr128" ]
[]
true
false
true
false
false
let lemma_store_stack_same_valid128 ptr v h i =
reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; BS.update_heap32_reveal (); BS.update_heap128_reveal ()
false
Vale.PPC64LE.Stack_i.fst
Vale.PPC64LE.Stack_i.lemma_free_stack_same_valid128
val lemma_free_stack_same_valid128 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma (requires valid_src_stack128 ptr h /\ (ptr >= finish \/ ptr + 16 <= start)) (ensures valid_src_stack128 ptr (free_stack128 start finish h)) [SMTPat (valid_src_stack128 ptr (free_stack128 start finish h))]
val lemma_free_stack_same_valid128 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma (requires valid_src_stack128 ptr h /\ (ptr >= finish \/ ptr + 16 <= start)) (ensures valid_src_stack128 ptr (free_stack128 start finish h)) [SMTPat (valid_src_stack128 ptr (free_stack128 start finish h))]
let lemma_free_stack_same_valid128 start finish ptr h = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish)
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Stack_i.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 81, "end_line": 41, "start_col": 0, "start_line": 37 }
module Vale.PPC64LE.Stack_i open FStar.Mul module BS = Vale.PPC64LE.Semantics_s open Vale.Arch.MachineHeap let vale_stack = machine_stack let valid_src_stack64 i st = BS.valid_src_stack64 i st let load_stack64 i st = BS.eval_stack i st let store_stack64 i v h = BS.update_stack64' i v h let free_stack64 start finish h = BS.free_stack' start finish h let valid_src_stack128 i st = BS.valid_src_stack128 i st let load_stack128 i st = BS.eval_stack128 i st let store_stack128 i v h = BS.update_stack128' i v h let free_stack128 start finish h = BS.free_stack' start finish h let init_r1 h = h.initial_r1 (* Lemmas *) #push-options "--z3rlimit 40" let lemma_store_stack_same_valid64 ptr v h i = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap64_reveal () let lemma_free_stack_same_valid64 start finish ptr h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish) let lemma_store_stack_same_valid128 ptr v h i = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; BS.update_heap32_reveal (); BS.update_heap128_reveal ()
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.Stack_i.fst" }
[ { "abbrev": false, "full_module": "Vale.Arch.MachineHeap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "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": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
start: Prims.int -> finish: Prims.int -> ptr: Prims.int -> h: Vale.PPC64LE.Stack_i.vale_stack -> FStar.Pervasives.Lemma (requires Vale.PPC64LE.Stack_i.valid_src_stack128 ptr h /\ (ptr >= finish \/ ptr + 16 <= start)) (ensures Vale.PPC64LE.Stack_i.valid_src_stack128 ptr (Vale.PPC64LE.Stack_i.free_stack128 start finish h)) [ SMTPat (Vale.PPC64LE.Stack_i.valid_src_stack128 ptr (Vale.PPC64LE.Stack_i.free_stack128 start finish h)) ]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.int", "Vale.PPC64LE.Stack_i.vale_stack", "Vale.PPC64LE.Machine_s.nat64", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.Map.t", "Vale.PPC64LE.Machine_s.nat8", "FStar.Classical.forall_intro", "Prims.l_and", "Prims.l_imp", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "Prims.op_Negation", "FStar.Set.mem", "Vale.Lib.Set.remove_between", "Prims.l_or", "Prims.op_Equality", "Prims.bool", "Vale.Lib.Set.remove_between_reveal", "FStar.Set.set", "FStar.Map.domain", "Prims.unit", "FStar.Pervasives.reveal_opaque", "Vale.Arch.MachineHeap_s.machine_heap", "Vale.Arch.MachineHeap_s.valid_addr128" ]
[]
false
false
true
false
false
let lemma_free_stack_same_valid128 start finish ptr h =
reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish)
false
Vale.PPC64LE.Stack_i.fst
Vale.PPC64LE.Stack_i.lemma_correct_store_load_stack128
val lemma_correct_store_load_stack128 (ptr:int) (v:quad32) (h:vale_stack) : Lemma (load_stack128 ptr (store_stack128 ptr v h) == v) [SMTPat (load_stack128 ptr (store_stack128 ptr v h))]
val lemma_correct_store_load_stack128 (ptr:int) (v:quad32) (h:vale_stack) : Lemma (load_stack128 ptr (store_stack128 ptr v h) == v) [SMTPat (load_stack128 ptr (store_stack128 ptr v h))]
let lemma_correct_store_load_stack128 ptr v h = let Machine_stack _ mem = h in correct_update_get128 ptr v mem
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Stack_i.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 33, "end_line": 71, "start_col": 0, "start_line": 69 }
module Vale.PPC64LE.Stack_i open FStar.Mul module BS = Vale.PPC64LE.Semantics_s open Vale.Arch.MachineHeap let vale_stack = machine_stack let valid_src_stack64 i st = BS.valid_src_stack64 i st let load_stack64 i st = BS.eval_stack i st let store_stack64 i v h = BS.update_stack64' i v h let free_stack64 start finish h = BS.free_stack' start finish h let valid_src_stack128 i st = BS.valid_src_stack128 i st let load_stack128 i st = BS.eval_stack128 i st let store_stack128 i v h = BS.update_stack128' i v h let free_stack128 start finish h = BS.free_stack' start finish h let init_r1 h = h.initial_r1 (* Lemmas *) #push-options "--z3rlimit 40" let lemma_store_stack_same_valid64 ptr v h i = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap64_reveal () let lemma_free_stack_same_valid64 start finish ptr h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish) let lemma_store_stack_same_valid128 ptr v h i = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; BS.update_heap32_reveal (); BS.update_heap128_reveal () let lemma_free_stack_same_valid128 start finish ptr h = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish) let lemma_store_new_valid64 ptr v h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap64_reveal () let lemma_store_new_valid128 ptr v h = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; BS.update_heap32_reveal (); BS.update_heap128_reveal () #pop-options let lemma_correct_store_load_stack64 ptr v h = let Machine_stack _ mem = h in correct_update_get64 ptr v mem let lemma_frame_store_load_stack64 ptr v h i = let Machine_stack _ mem = h in frame_update_heap64 ptr v mem; BS.get_heap_val64_reveal () let lemma_free_stack_same_load64 start finish ptr h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish); BS.get_heap_val64_reveal ()
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.Stack_i.fst" }
[ { "abbrev": false, "full_module": "Vale.Arch.MachineHeap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "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
ptr: Prims.int -> v: Vale.PPC64LE.Memory.quad32 -> h: Vale.PPC64LE.Stack_i.vale_stack -> FStar.Pervasives.Lemma (ensures Vale.PPC64LE.Stack_i.load_stack128 ptr (Vale.PPC64LE.Stack_i.store_stack128 ptr v h) == v) [ SMTPat (Vale.PPC64LE.Stack_i.load_stack128 ptr (Vale.PPC64LE.Stack_i.store_stack128 ptr v h) ) ]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.int", "Vale.PPC64LE.Memory.quad32", "Vale.PPC64LE.Stack_i.vale_stack", "Vale.PPC64LE.Machine_s.nat64", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.Map.t", "Vale.PPC64LE.Machine_s.nat8", "Vale.Arch.MachineHeap.correct_update_get128", "Prims.unit" ]
[]
false
false
true
false
false
let lemma_correct_store_load_stack128 ptr v h =
let Machine_stack _ mem = h in correct_update_get128 ptr v mem
false
Vale.PPC64LE.Stack_i.fst
Vale.PPC64LE.Stack_i.lemma_store_stack_same_valid64
val lemma_store_stack_same_valid64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack64 i h /\ (i >= ptr + 8 \/ i + 8 <= ptr)) (ensures valid_src_stack64 i (store_stack64 ptr v h)) [SMTPat (valid_src_stack64 i (store_stack64 ptr v h))]
val lemma_store_stack_same_valid64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack64 i h /\ (i >= ptr + 8 \/ i + 8 <= ptr)) (ensures valid_src_stack64 i (store_stack64 ptr v h)) [SMTPat (valid_src_stack64 i (store_stack64 ptr v h))]
let lemma_store_stack_same_valid64 ptr v h i = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap64_reveal ()
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Stack_i.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 28, "end_line": 24, "start_col": 0, "start_line": 22 }
module Vale.PPC64LE.Stack_i open FStar.Mul module BS = Vale.PPC64LE.Semantics_s open Vale.Arch.MachineHeap let vale_stack = machine_stack let valid_src_stack64 i st = BS.valid_src_stack64 i st let load_stack64 i st = BS.eval_stack i st let store_stack64 i v h = BS.update_stack64' i v h let free_stack64 start finish h = BS.free_stack' start finish h let valid_src_stack128 i st = BS.valid_src_stack128 i st let load_stack128 i st = BS.eval_stack128 i st let store_stack128 i v h = BS.update_stack128' i v h let free_stack128 start finish h = BS.free_stack' start finish h let init_r1 h = h.initial_r1 (* Lemmas *)
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.Stack_i.fst" }
[ { "abbrev": false, "full_module": "Vale.Arch.MachineHeap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "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": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ptr: Prims.int -> v: Vale.PPC64LE.Memory.nat64 -> h: Vale.PPC64LE.Stack_i.vale_stack -> i: Prims.int -> FStar.Pervasives.Lemma (requires Vale.PPC64LE.Stack_i.valid_src_stack64 i h /\ (i >= ptr + 8 \/ i + 8 <= ptr)) (ensures Vale.PPC64LE.Stack_i.valid_src_stack64 i (Vale.PPC64LE.Stack_i.store_stack64 ptr v h) ) [ SMTPat (Vale.PPC64LE.Stack_i.valid_src_stack64 i (Vale.PPC64LE.Stack_i.store_stack64 ptr v h)) ]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.int", "Vale.PPC64LE.Memory.nat64", "Vale.PPC64LE.Stack_i.vale_stack", "Vale.Arch.MachineHeap_s.update_heap64_reveal", "Prims.unit", "FStar.Pervasives.reveal_opaque", "Vale.Arch.MachineHeap_s.machine_heap", "Prims.bool", "Vale.Arch.MachineHeap_s.valid_addr64" ]
[]
true
false
true
false
false
let lemma_store_stack_same_valid64 ptr v h i =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap64_reveal ()
false
Vale.PPC64LE.Stack_i.fst
Vale.PPC64LE.Stack_i.lemma_free_stack_same_load128
val lemma_free_stack_same_load128 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma (requires valid_src_stack128 ptr h /\ (ptr >= finish \/ ptr + 16 <= start)) (ensures load_stack128 ptr h == load_stack128 ptr (free_stack128 start finish h)) [SMTPat (load_stack128 ptr (free_stack128 start finish h))]
val lemma_free_stack_same_load128 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma (requires valid_src_stack128 ptr h /\ (ptr >= finish \/ ptr + 16 <= start)) (ensures load_stack128 ptr h == load_stack128 ptr (free_stack128 start finish h)) [SMTPat (load_stack128 ptr (free_stack128 start finish h))]
let lemma_free_stack_same_load128 start finish ptr h = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish); BS.get_heap_val32_reveal (); BS.get_heap_val128_reveal ()
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Stack_i.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 30, "end_line": 85, "start_col": 0, "start_line": 79 }
module Vale.PPC64LE.Stack_i open FStar.Mul module BS = Vale.PPC64LE.Semantics_s open Vale.Arch.MachineHeap let vale_stack = machine_stack let valid_src_stack64 i st = BS.valid_src_stack64 i st let load_stack64 i st = BS.eval_stack i st let store_stack64 i v h = BS.update_stack64' i v h let free_stack64 start finish h = BS.free_stack' start finish h let valid_src_stack128 i st = BS.valid_src_stack128 i st let load_stack128 i st = BS.eval_stack128 i st let store_stack128 i v h = BS.update_stack128' i v h let free_stack128 start finish h = BS.free_stack' start finish h let init_r1 h = h.initial_r1 (* Lemmas *) #push-options "--z3rlimit 40" let lemma_store_stack_same_valid64 ptr v h i = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap64_reveal () let lemma_free_stack_same_valid64 start finish ptr h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish) let lemma_store_stack_same_valid128 ptr v h i = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; BS.update_heap32_reveal (); BS.update_heap128_reveal () let lemma_free_stack_same_valid128 start finish ptr h = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish) let lemma_store_new_valid64 ptr v h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap64_reveal () let lemma_store_new_valid128 ptr v h = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; BS.update_heap32_reveal (); BS.update_heap128_reveal () #pop-options let lemma_correct_store_load_stack64 ptr v h = let Machine_stack _ mem = h in correct_update_get64 ptr v mem let lemma_frame_store_load_stack64 ptr v h i = let Machine_stack _ mem = h in frame_update_heap64 ptr v mem; BS.get_heap_val64_reveal () let lemma_free_stack_same_load64 start finish ptr h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish); BS.get_heap_val64_reveal () let lemma_correct_store_load_stack128 ptr v h = let Machine_stack _ mem = h in correct_update_get128 ptr v mem let lemma_frame_store_load_stack128 ptr v h i = let Machine_stack _ mem = h in frame_update_heap128 ptr v mem; BS.get_heap_val32_reveal (); BS.get_heap_val128_reveal ()
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.Stack_i.fst" }
[ { "abbrev": false, "full_module": "Vale.Arch.MachineHeap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "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
start: Prims.int -> finish: Prims.int -> ptr: Prims.int -> h: Vale.PPC64LE.Stack_i.vale_stack -> FStar.Pervasives.Lemma (requires Vale.PPC64LE.Stack_i.valid_src_stack128 ptr h /\ (ptr >= finish \/ ptr + 16 <= start)) (ensures Vale.PPC64LE.Stack_i.load_stack128 ptr h == Vale.PPC64LE.Stack_i.load_stack128 ptr (Vale.PPC64LE.Stack_i.free_stack128 start finish h)) [ SMTPat (Vale.PPC64LE.Stack_i.load_stack128 ptr (Vale.PPC64LE.Stack_i.free_stack128 start finish h)) ]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.int", "Vale.PPC64LE.Stack_i.vale_stack", "Vale.PPC64LE.Machine_s.nat64", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.Map.t", "Vale.PPC64LE.Machine_s.nat8", "Vale.Arch.MachineHeap_s.get_heap_val128_reveal", "Prims.unit", "Vale.Arch.MachineHeap_s.get_heap_val32_reveal", "FStar.Classical.forall_intro", "Prims.l_and", "Prims.l_imp", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "Prims.op_Negation", "FStar.Set.mem", "Vale.Lib.Set.remove_between", "Prims.l_or", "Prims.op_Equality", "Prims.bool", "Vale.Lib.Set.remove_between_reveal", "FStar.Set.set", "FStar.Map.domain", "FStar.Pervasives.reveal_opaque", "Vale.Arch.MachineHeap_s.machine_heap", "Vale.Arch.MachineHeap_s.valid_addr128" ]
[]
false
false
true
false
false
let lemma_free_stack_same_load128 start finish ptr h =
reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish); BS.get_heap_val32_reveal (); BS.get_heap_val128_reveal ()
false
Vale.PPC64LE.Stack_i.fst
Vale.PPC64LE.Stack_i.lemma_free_stack_same_load64
val lemma_free_stack_same_load64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma (requires valid_src_stack64 ptr h /\ (ptr >= finish \/ ptr + 8 <= start)) (ensures load_stack64 ptr h == load_stack64 ptr (free_stack64 start finish h)) [SMTPat (load_stack64 ptr (free_stack64 start finish h))]
val lemma_free_stack_same_load64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma (requires valid_src_stack64 ptr h /\ (ptr >= finish \/ ptr + 8 <= start)) (ensures load_stack64 ptr h == load_stack64 ptr (free_stack64 start finish h)) [SMTPat (load_stack64 ptr (free_stack64 start finish h))]
let lemma_free_stack_same_load64 start finish ptr h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish); BS.get_heap_val64_reveal ()
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Stack_i.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 29, "end_line": 67, "start_col": 0, "start_line": 62 }
module Vale.PPC64LE.Stack_i open FStar.Mul module BS = Vale.PPC64LE.Semantics_s open Vale.Arch.MachineHeap let vale_stack = machine_stack let valid_src_stack64 i st = BS.valid_src_stack64 i st let load_stack64 i st = BS.eval_stack i st let store_stack64 i v h = BS.update_stack64' i v h let free_stack64 start finish h = BS.free_stack' start finish h let valid_src_stack128 i st = BS.valid_src_stack128 i st let load_stack128 i st = BS.eval_stack128 i st let store_stack128 i v h = BS.update_stack128' i v h let free_stack128 start finish h = BS.free_stack' start finish h let init_r1 h = h.initial_r1 (* Lemmas *) #push-options "--z3rlimit 40" let lemma_store_stack_same_valid64 ptr v h i = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap64_reveal () let lemma_free_stack_same_valid64 start finish ptr h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish) let lemma_store_stack_same_valid128 ptr v h i = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; BS.update_heap32_reveal (); BS.update_heap128_reveal () let lemma_free_stack_same_valid128 start finish ptr h = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish) let lemma_store_new_valid64 ptr v h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap64_reveal () let lemma_store_new_valid128 ptr v h = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; BS.update_heap32_reveal (); BS.update_heap128_reveal () #pop-options let lemma_correct_store_load_stack64 ptr v h = let Machine_stack _ mem = h in correct_update_get64 ptr v mem let lemma_frame_store_load_stack64 ptr v h i = let Machine_stack _ mem = h in frame_update_heap64 ptr v mem; BS.get_heap_val64_reveal ()
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.Stack_i.fst" }
[ { "abbrev": false, "full_module": "Vale.Arch.MachineHeap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "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
start: Prims.int -> finish: Prims.int -> ptr: Prims.int -> h: Vale.PPC64LE.Stack_i.vale_stack -> FStar.Pervasives.Lemma (requires Vale.PPC64LE.Stack_i.valid_src_stack64 ptr h /\ (ptr >= finish \/ ptr + 8 <= start)) (ensures Vale.PPC64LE.Stack_i.load_stack64 ptr h == Vale.PPC64LE.Stack_i.load_stack64 ptr (Vale.PPC64LE.Stack_i.free_stack64 start finish h)) [ SMTPat (Vale.PPC64LE.Stack_i.load_stack64 ptr (Vale.PPC64LE.Stack_i.free_stack64 start finish h)) ]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.int", "Vale.PPC64LE.Stack_i.vale_stack", "Vale.PPC64LE.Machine_s.nat64", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.Map.t", "Vale.PPC64LE.Machine_s.nat8", "Vale.Arch.MachineHeap_s.get_heap_val64_reveal", "Prims.unit", "FStar.Classical.forall_intro", "Prims.l_and", "Prims.l_imp", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "Prims.op_Negation", "FStar.Set.mem", "Vale.Lib.Set.remove_between", "Prims.l_or", "Prims.op_Equality", "Prims.bool", "Vale.Lib.Set.remove_between_reveal", "FStar.Set.set", "FStar.Map.domain", "FStar.Pervasives.reveal_opaque", "Vale.Arch.MachineHeap_s.machine_heap", "Vale.Arch.MachineHeap_s.valid_addr64" ]
[]
false
false
true
false
false
let lemma_free_stack_same_load64 start finish ptr h =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish); BS.get_heap_val64_reveal ()
false
Steel.ST.HigherArray.fst
Steel.ST.HigherArray.ghost_split
val ghost_split (#opened: _) (#elt: Type) (#x: Seq.seq elt) (#p: P.perm) (a: array elt) (i: US.t) : STGhost (squash (US.v i <= length a /\ US.v i <= Seq.length x)) opened (pts_to a p x) (fun res -> pts_to (split_l a i) p (Seq.slice x 0 (US.v i)) `star` pts_to (split_r a i) p (Seq.slice x (US.v i) (Seq.length x))) (US.v i <= length a) (fun res -> x == Seq.append (Seq.slice x 0 (US.v i)) (Seq.slice x (US.v i) (Seq.length x)) )
val ghost_split (#opened: _) (#elt: Type) (#x: Seq.seq elt) (#p: P.perm) (a: array elt) (i: US.t) : STGhost (squash (US.v i <= length a /\ US.v i <= Seq.length x)) opened (pts_to a p x) (fun res -> pts_to (split_l a i) p (Seq.slice x 0 (US.v i)) `star` pts_to (split_r a i) p (Seq.slice x (US.v i) (Seq.length x))) (US.v i <= length a) (fun res -> x == Seq.append (Seq.slice x 0 (US.v i)) (Seq.slice x (US.v i) (Seq.length x)) )
let ghost_split #_ #_ #x #p a i = elim_pts_to a p x; mk_carrier_split (US.v (ptr_of a).base_len) ((ptr_of a).offset) x (p) (US.v i); Seq.lemma_split x (US.v i); let xl = Seq.slice x 0 (US.v i) in let xr = Seq.slice x (US.v i) (Seq.length x) in let vl = mk_carrier (US.v (ptr_of a).base_len) ((ptr_of a).offset) xl (p) in let vr = mk_carrier (US.v (ptr_of a).base_len) ((ptr_of a).offset + US.v i) xr (p) in R.split (ptr_of a).base _ vl vr; change_r_pts_to (ptr_of a).base vl (ptr_of (split_l a i)).base vl; intro_pts_to (split_l a i) #vl p (Seq.slice x 0 (US.v i)); change_r_pts_to (ptr_of a).base vr (ptr_of (split_r a i)).base vr; intro_pts_to (split_r a i) #vr p (Seq.slice x (US.v i) (Seq.length x))
{ "file_name": "lib/steel/Steel.ST.HigherArray.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 72, "end_line": 584, "start_col": 0, "start_line": 561 }
(* 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. *) module Steel.ST.HigherArray module P = Steel.PCMFrac module R = Steel.ST.PCMReference module M = FStar.Map module PM = Steel.PCMMap [@@noextract_to "krml"] let index_t (len: Ghost.erased nat) : Tot Type0 = (i: nat { i < len }) [@@noextract_to "krml"] let carrier (elt: Type u#a) (len: Ghost.erased nat) : Tot Type = PM.map (index_t len) (P.fractional elt) [@@noextract_to "krml"] let pcm (elt: Type u#a) (len: Ghost.erased nat) : Tot (P.pcm (carrier elt len)) = PM.pointwise (index_t len) (P.pcm_frac #elt) [@@noextract_to "krml"] let one (#elt: Type) (#len: Ghost.erased nat) = (pcm elt len).P.p.P.one let composable (#elt: Type) (#len: Ghost.erased nat) = (pcm elt len).P.p.P.composable [@@noextract_to "krml"] let compose (#elt: Type) (#len: Ghost.erased nat) = (pcm elt len).P.p.P.op [@@noextract_to "krml"] let mk_carrier (#elt: Type) (len: nat) (offset: nat) (s: Seq.seq elt) (p: P.perm) : Tot (carrier elt len) = let f (i: nat) : Tot (P.fractional elt) = if offset + Seq.length s > len || i < offset || i >= offset + Seq.length s then None else Some (Seq.index s (i - offset), p) in M.map_literal f let mk_carrier_inj (#elt: Type) (len: nat) (offset: nat) (s1 s2: Seq.seq elt) (p1 p2: P.perm) : Lemma (requires ( mk_carrier len offset s1 p1 == mk_carrier len offset s2 p2 /\ offset + Seq.length s1 <= len /\ offset + Seq.length s2 <= len )) (ensures ( s1 `Seq.equal` s2 /\ (Seq.length s1 > 0 ==> p1 == p2) )) = assert (forall (i: nat) . i < Seq.length s1 ==> (M.sel (mk_carrier len offset s1 p1) (offset + i) == Some (Seq.index s1 i, p1))); assert (forall (i: nat) . i < Seq.length s2 ==> M.sel (mk_carrier len offset s2 p2) (offset + i) == Some (Seq.index s2 i, p2)) [@@erasable] let base_t (elt: Type u#a) : Tot Type0 = Ghost.erased (base_len: US.t & ref _ (pcm elt (US.v base_len))) let base_len (#elt: Type) (b: base_t elt) : GTot nat = US.v (dfst b) [@@noextract_to "krml"] noeq type ptr (elt: Type u#a) : Type0 = { base_len: Ghost.erased US.t; // U32.t to prove that A.read, A.write offset computation does not overflow. TODO: replace U32.t with size_t base: (r: ref _ (pcm elt (US.v base_len)) { core_ref_is_null r ==> US.v base_len == 0 }); offset: (offset: nat { offset <= US.v base_len }); } let null_ptr a = { base_len = 0sz; base = null #_ #(pcm a 0) ; offset = 0 } let is_null_ptr p = is_null p.base let base (#elt: Type) (p: ptr elt) : Tot (base_t elt) = (| Ghost.reveal p.base_len, p.base |) let offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p))) = p.offset let ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma (requires ( base p1 == base p2 /\ offset p1 == offset p2 )) (ensures ( p1 == p2 )) = () let base_len_null_ptr _ = () let length_fits #elt a = () let valid_perm (len: nat) (offset: nat) (slice_len: nat) (p: P.perm) : Tot prop = let open FStar.Real in ((offset + slice_len <= len /\ slice_len > 0) ==> (p.P.v <=. one)) [@__reduce__] let pts_to0 (#elt: Type u#1) (a: array elt) (p: P.perm) (s: Seq.seq elt) : Tot vprop = R.pts_to (ptr_of a).base (mk_carrier (US.v (ptr_of a).base_len) (ptr_of a).offset s p) `star` pure ( valid_perm (US.v (ptr_of a).base_len) (ptr_of a).offset (Seq.length s) p /\ Seq.length s == length a ) let pts_to (#elt: Type u#1) (a: array elt) ([@@@ smt_fallback ] p: P.perm) ([@@@ smt_fallback ] s: Seq.seq elt) : Tot vprop = pts_to0 a p s // this lemma is necessary because Steel.PCMReference is marked unfold let change_r_pts_to (#opened: _) (#carrier: Type u#1) (#pcm: P.pcm carrier) (p: ref carrier pcm) (v: carrier) (#carrier': Type u#1) (#pcm': P.pcm carrier') (p': ref carrier' pcm') (v': carrier') : STGhost unit opened (R.pts_to p v) (fun _ -> R.pts_to p' v') (// keep on distinct lines for error messages carrier == carrier' /\ pcm == pcm' /\ p == p' /\ v == v') (fun _ -> True) = rewrite (R.pts_to p v) (R.pts_to p' v') let intro_pts_to (#opened: _) (#elt: Type u#1) (a: array elt) (#v: _) (p: P.perm) (s: Seq.seq elt) : STGhost unit opened (R.pts_to (ptr_of a).base v) (fun _ -> pts_to a p s) ( v == mk_carrier (US.v (ptr_of a).base_len) (ptr_of a).offset s p /\ valid_perm (US.v (ptr_of a).base_len) (ptr_of a).offset (Seq.length s) p /\ Seq.length s == length a ) (fun _ -> True) = change_r_pts_to (ptr_of a).base v (ptr_of a).base (mk_carrier (US.v (ptr_of a).base_len) (ptr_of a).offset s p); intro_pure _; rewrite (pts_to0 a p s) (pts_to a p s) let elim_pts_to (#opened: _) (#elt: Type u#1) (a: array elt) (p: P.perm) (s: Seq.seq elt) : STGhost unit opened (pts_to a p s) (fun _ -> R.pts_to (ptr_of a).base (mk_carrier (US.v (ptr_of a).base_len) (ptr_of a).offset s p)) (True) (fun _ -> valid_perm (US.v (ptr_of a).base_len) (ptr_of a).offset (Seq.length s) p /\ Seq.length s == length a ) = rewrite (pts_to a p s) (pts_to0 a p s); elim_pure _ let pts_to_length a s = elim_pts_to a _ s; intro_pts_to a _ s let pts_to_not_null a s = elim_pts_to a _ s; R.pts_to_not_null _ _; intro_pts_to a _ s let mk_carrier_joinable (#elt: Type) (len: nat) (offset: nat) (s1: Seq.seq elt) (p1: P.perm) (s2: Seq.seq elt) (p2: P.perm) : Lemma (requires ( offset + Seq.length s1 <= len /\ Seq.length s1 == Seq.length s2 /\ P.joinable (pcm elt len) (mk_carrier len offset s1 p1) (mk_carrier len offset s2 p2) )) (ensures ( s1 `Seq.equal` s2 )) = let lem (i: nat { 0 <= i /\ i < Seq.length s1 }) : Lemma (Seq.index s1 i == Seq.index s2 i) [SMTPat (Seq.index s1 i); SMTPat (Seq.index s2 i)] = assert ( forall z . ( P.compatible (pcm elt len) (mk_carrier len offset s1 p1) z /\ P.compatible (pcm elt len) (mk_carrier len offset s2 p2) z ) ==> begin match M.sel z (offset + i) with | None -> False | Some (v, _) -> v == Seq.index s1 i /\ v == Seq.index s2 i end ) in () let pure_star_interp' (p:slprop u#a) (q:prop) (m:mem) : Lemma (interp (p `Steel.Memory.star` Steel.Memory.pure q) m <==> interp p m /\ q) = pure_star_interp p q m; emp_unit p let pts_to_inj a p1 s1 p2 s2 m = Classical.forall_intro reveal_pure; pure_star_interp' (hp_of (R.pts_to (ptr_of a).base (mk_carrier (US.v (ptr_of a).base_len) (ptr_of a).offset s1 p1))) ( valid_perm (US.v (ptr_of a).base_len) (ptr_of a).offset (Seq.length s1) p1 /\ Seq.length s1 == length a ) m; pure_star_interp' (hp_of (R.pts_to (ptr_of a).base (mk_carrier (US.v (ptr_of a).base_len) (ptr_of a).offset s2 p2))) ( valid_perm (US.v (ptr_of a).base_len) (ptr_of a).offset (Seq.length s2) p2 /\ Seq.length s2 == length a ) m; pts_to_join (ptr_of a).base (mk_carrier (US.v (ptr_of a).base_len) (ptr_of a).offset s1 p1) (mk_carrier (US.v (ptr_of a).base_len) (ptr_of a).offset s2 p2) m; mk_carrier_joinable (US.v (ptr_of a).base_len) (ptr_of a).offset s1 p1 s2 p2 [@@noextract_to "krml"] let malloc0 (#elt: Type) (x: elt) (n: US.t) : ST (array elt) emp (fun a -> pts_to a P.full_perm (Seq.create (US.v n) x)) (True) (fun a -> length a == US.v n /\ base_len (base (ptr_of a)) == US.v n ) = let c : carrier elt (US.v n) = mk_carrier (US.v n) 0 (Seq.create (US.v n) x) P.full_perm in let base : ref (carrier elt (US.v n)) (pcm elt (US.v n)) = R.alloc c in R.pts_to_not_null base _; let p = { base_len = n; base = base; offset = 0; } in let a = (| p, Ghost.hide (US.v n) |) in change_r_pts_to base c (ptr_of a).base c; intro_pts_to a P.full_perm (Seq.create (US.v n) x); return a let malloc_ptr x n = let a = malloc0 x n in let (| p, _ |) = a in rewrite (pts_to _ _ _) (pts_to (| p, Ghost.hide (US.v n) |) _ _); return p [@@noextract_to "krml"] let free0 (#elt: Type) (#s: Ghost.erased (Seq.seq elt)) (a: array elt) : ST unit (pts_to a P.full_perm s) (fun _ -> emp) ( length a == base_len (base (ptr_of a)) ) (fun _ -> True) = drop (pts_to a _ _) let free_ptr a = free0 _ let valid_sum_perm (len: nat) (offset: nat) (slice_len: nat) (p1 p2: P.perm) : Tot prop = let open FStar.Real in valid_perm len offset slice_len (P.sum_perm p1 p2) let mk_carrier_share (#elt: Type) (len: nat) (offset: nat) (s: Seq.seq elt) (p1 p2: P.perm) : Lemma (requires (valid_sum_perm len offset (Seq.length s) p1 p2)) (ensures ( let c1 = mk_carrier len offset s p1 in let c2 = mk_carrier len offset s p2 in composable c1 c2 /\ mk_carrier len offset s (p1 `P.sum_perm` p2) `M.equal` (c1 `compose` c2) )) = () let share #_ #_ #x a p p1 p2 = elim_pts_to a p x; mk_carrier_share (US.v (ptr_of a).base_len) (ptr_of a).offset x p1 p2; R.split (ptr_of a).base _ (mk_carrier (US.v (ptr_of a).base_len) (ptr_of a).offset x p1) (mk_carrier (US.v (ptr_of a).base_len) (ptr_of a).offset x p2); intro_pts_to a p1 x; intro_pts_to a p2 x let mk_carrier_gather (#elt: Type) (len: nat) (offset: nat) (s1 s2: Seq.seq elt) (p1 p2: P.perm) : Lemma (requires ( let c1 = mk_carrier len offset s1 p1 in let c2 = mk_carrier len offset s2 p2 in composable c1 c2 /\ Seq.length s1 == Seq.length s2 /\ offset + Seq.length s1 <= len )) (ensures ( let c1 = mk_carrier len offset s1 p1 in let c2 = mk_carrier len offset s2 p2 in composable c1 c2 /\ mk_carrier len offset s1 (p1 `P.sum_perm` p2) == (c1 `compose` c2) /\ mk_carrier len offset s2 (p1 `P.sum_perm` p2) == (c1 `compose` c2) /\ s1 == s2 )) = let c1 = mk_carrier len offset s1 p1 in let c2 = mk_carrier len offset s2 p2 in assert (composable c1 c2); assert (mk_carrier len offset s1 (p1 `P.sum_perm` p2) `M.equal` (c1 `compose` c2)); assert (mk_carrier len offset s2 (p1 `P.sum_perm` p2) `M.equal` (c1 `compose` c2)); mk_carrier_inj len offset s1 s2 (p1 `P.sum_perm` p2) (p1 `P.sum_perm` p2) let mk_carrier_valid_sum_perm (#elt: Type) (len: nat) (offset: nat) (s: Seq.seq elt) (p1 p2: P.perm) : Lemma (let c1 = mk_carrier len offset s p1 in let c2 = mk_carrier len offset s p2 in composable c1 c2 <==> valid_sum_perm len offset (Seq.length s) p1 p2) = let c1 = mk_carrier len offset s p1 in let c2 = mk_carrier len offset s p2 in if Seq.length s > 0 && offset + Seq.length s <= len then let open FStar.Real in assert (P.composable (M.sel c1 offset) (M.sel c2 offset) <==> valid_perm len offset (Seq.length s) (P.sum_perm p1 p2)) else () let gather a #x1 p1 #x2 p2 = elim_pts_to a p1 x1; elim_pts_to a p2 x2; let _ = R.gather (ptr_of a).base (mk_carrier (US.v (ptr_of a).base_len) ((ptr_of a).offset) x1 p1) (mk_carrier (US.v (ptr_of a).base_len) ((ptr_of a).offset) x2 p2) in mk_carrier_gather (US.v (ptr_of a).base_len) ((ptr_of a).offset) x1 x2 p1 p2; mk_carrier_valid_sum_perm (US.v (ptr_of a).base_len) ((ptr_of a).offset) x1 p1 p2; intro_pts_to a (p1 `P.sum_perm` p2) x1 #push-options "--z3rlimit 16" [@@noextract_to "krml"] let index0 (#t: Type) (#p: P.perm) (a: array t) (#s: Ghost.erased (Seq.seq t)) (i: US.t) : ST t (pts_to a p s) (fun _ -> pts_to a p s) (US.v i < length a \/ US.v i < Seq.length s) (fun res -> Seq.length s == length a /\ US.v i < Seq.length s /\ res == Seq.index s (US.v i)) = elim_pts_to a p s; let s' = R.read (ptr_of a).base _ in let res = fst (Some?.v (M.sel s' ((ptr_of a).offset + US.v i))) in intro_pts_to a p s; return res #pop-options let index_ptr a i = index0 _ i let mk_carrier_upd (#elt: Type) (len: nat) (offset: nat) (s: Seq.seq elt) (i: nat) (v: elt) (_: squash ( offset + Seq.length s <= len /\ i < Seq.length s )) : Lemma (ensures ( let o = mk_carrier len offset s P.full_perm in let o' = mk_carrier len offset (Seq.upd s i v) P.full_perm in o' `Map.equal` Map.upd o (offset + i) (Some (v, P.full_perm)) )) = () #push-options "--z3rlimit 20" [@@noextract_to "krml"] let upd0 (#t: Type) (a: array t) (#s: Ghost.erased (Seq.seq t)) (i: US.t { US.v i < Seq.length s }) (v: t) : STT unit (pts_to a P.full_perm s) (fun res -> pts_to a P.full_perm (Seq.upd s (US.v i) v)) = elim_pts_to a _ _; mk_carrier_upd (US.v (ptr_of a).base_len) ((ptr_of a).offset) s (US.v i) v (); R.upd_gen (ptr_of a).base _ _ (PM.lift_frame_preserving_upd _ _ (P.mk_frame_preserving_upd (Seq.index s (US.v i)) v ) _ ((ptr_of a).offset + US.v i) ); intro_pts_to a _ _ #pop-options let upd_ptr a i v = upd0 _ i v; rewrite (pts_to _ _ _) (pts_to _ _ _) let mk_carrier_merge (#elt: Type) (len: nat) (offset: nat) (s1 s2: Seq.seq elt) (p: P.perm) : Lemma (requires ( offset + Seq.length s1 + Seq.length s2 <= len )) (ensures ( let c1 = mk_carrier len offset s1 p in let c2 = mk_carrier len (offset + Seq.length s1) s2 p in composable c1 c2 /\ mk_carrier len offset (s1 `Seq.append` s2) p `M.equal` (c1 `compose` c2) )) = () let ghost_join #_ #_ #x1 #x2 #p a1 a2 h = elim_pts_to a1 p x1; elim_pts_to a2 p x2; mk_carrier_merge (US.v (ptr_of a1).base_len) ((ptr_of a1).offset) x1 x2 (p); change_r_pts_to (ptr_of a2).base _ (ptr_of a1).base (mk_carrier (US.v (ptr_of a1).base_len) ((ptr_of a1).offset + Seq.length x1) x2 p); R.gather (ptr_of a1).base (mk_carrier (US.v (ptr_of a1).base_len) ((ptr_of a1).offset) x1 (p)) (mk_carrier (US.v (ptr_of a1).base_len) ((ptr_of a1).offset + Seq.length x1) x2 (p)); change_r_pts_to (ptr_of a1).base _ (ptr_of (merge a1 a2)).base (mk_carrier (US.v (ptr_of (merge a1 a2)).base_len) ((ptr_of (merge a1 a2)).offset) (x1 `Seq.append` x2) (p)); intro_pts_to (merge a1 a2) p (Seq.append x1 x2) let mk_carrier_split (#elt: Type) (len: nat) (offset: nat) (s: Seq.seq elt) (p: P.perm) (i: nat) : Lemma (requires ( offset + Seq.length s <= len /\ i <= Seq.length s )) (ensures ( let c1 = mk_carrier len offset (Seq.slice s 0 i) p in let c2 = mk_carrier len (offset + i) (Seq.slice s i (Seq.length s)) p in composable c1 c2 /\ mk_carrier len offset s p `M.equal` (c1 `compose` c2) )) = () // TODO: replace with Ghost, introduce pointer shifting operations in SteelAtomicBase Unobservable [@@noextract_to "krml"] let ptr_shift (#elt: Type) (p: ptr elt) (off: US.t) : Pure (ptr elt) (requires (offset p + US.v off <= base_len (base p))) (ensures (fun p' -> base p' == base p /\ offset p' == offset p + US.v off )) = { base_len = p.base_len; base = p.base; offset = p.offset + US.v off; }
{ "checked_file": "/", "dependencies": [ "Steel.ST.PCMReference.fsti.checked", "Steel.ST.Loops.fsti.checked", "Steel.PCMMap.fst.checked", "Steel.PCMFrac.fst.checked", "Steel.Memory.fsti.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Real.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.HigherArray.fst" }
[ { "abbrev": true, "full_module": "Steel.PCMMap", "short_module": "PM" }, { "abbrev": true, "full_module": "FStar.Map", "short_module": "M" }, { "abbrev": true, "full_module": "Steel.ST.PCMReference", "short_module": "R" }, { "abbrev": true, "full_module": "Steel.PCMFrac", "short_module": "P" }, { "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
a: Steel.ST.HigherArray.array elt -> i: FStar.SizeT.t -> Steel.ST.Effect.Ghost.STGhost (Prims.squash (FStar.SizeT.v i <= Steel.ST.HigherArray.length a /\ FStar.SizeT.v i <= FStar.Seq.Base.length x))
Steel.ST.Effect.Ghost.STGhost
[]
[]
[ "Steel.Memory.inames", "FStar.Seq.Base.seq", "Steel.FractionalPermission.perm", "Steel.ST.HigherArray.array", "FStar.SizeT.t", "Steel.ST.HigherArray.intro_pts_to", "Steel.ST.HigherArray.split_r", "FStar.Seq.Base.slice", "FStar.SizeT.v", "FStar.Seq.Base.length", "Prims.unit", "Steel.ST.HigherArray.change_r_pts_to", "Steel.ST.HigherArray.carrier", "FStar.Ghost.hide", "Prims.nat", "FStar.Ghost.reveal", "Steel.ST.HigherArray.__proj__Mkptr__item__base_len", "Steel.ST.HigherArray.ptr_of", "Steel.ST.HigherArray.pcm", "Steel.ST.HigherArray.__proj__Mkptr__item__base", "Prims.squash", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Steel.ST.HigherArray.length", "Steel.ST.HigherArray.split_l", "Steel.ST.PCMReference.split", "Steel.ST.HigherArray.mk_carrier", "Steel.ST.HigherArray.__proj__Mkptr__item__offset", "Prims.op_Addition", "FStar.Seq.Properties.lemma_split", "Steel.ST.HigherArray.mk_carrier_split", "Steel.ST.HigherArray.elim_pts_to" ]
[]
false
true
true
false
false
let ghost_split #_ #_ #x #p a i =
elim_pts_to a p x; mk_carrier_split (US.v (ptr_of a).base_len) ((ptr_of a).offset) x (p) (US.v i); Seq.lemma_split x (US.v i); let xl = Seq.slice x 0 (US.v i) in let xr = Seq.slice x (US.v i) (Seq.length x) in let vl = mk_carrier (US.v (ptr_of a).base_len) ((ptr_of a).offset) xl (p) in let vr = mk_carrier (US.v (ptr_of a).base_len) ((ptr_of a).offset + US.v i) xr (p) in R.split (ptr_of a).base _ vl vr; change_r_pts_to (ptr_of a).base vl (ptr_of (split_l a i)).base vl; intro_pts_to (split_l a i) #vl p (Seq.slice x 0 (US.v i)); change_r_pts_to (ptr_of a).base vr (ptr_of (split_r a i)).base vr; intro_pts_to (split_r a i) #vr p (Seq.slice x (US.v i) (Seq.length x))
false
Vale.PPC64LE.Stack_i.fst
Vale.PPC64LE.Stack_i.lemma_frame_store_load_stack64_128
val lemma_frame_store_load_stack64_128 (ptr:int) (v:quad32) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack64 i h /\ (i >= ptr + 16 \/ i + 8 <= ptr)) (ensures (load_stack64 i (store_stack128 ptr v h) == load_stack64 i h)) [SMTPat (load_stack64 i (store_stack128 ptr v h))]
val lemma_frame_store_load_stack64_128 (ptr:int) (v:quad32) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack64 i h /\ (i >= ptr + 16 \/ i + 8 <= ptr)) (ensures (load_stack64 i (store_stack128 ptr v h) == load_stack64 i h)) [SMTPat (load_stack64 i (store_stack128 ptr v h))]
let lemma_frame_store_load_stack64_128 ptr v h i = let Machine_stack _ mem = h in frame_update_heap128 ptr v mem; BS.get_heap_val64_reveal ()
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Stack_i.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 29, "end_line": 167, "start_col": 0, "start_line": 164 }
module Vale.PPC64LE.Stack_i open FStar.Mul module BS = Vale.PPC64LE.Semantics_s open Vale.Arch.MachineHeap let vale_stack = machine_stack let valid_src_stack64 i st = BS.valid_src_stack64 i st let load_stack64 i st = BS.eval_stack i st let store_stack64 i v h = BS.update_stack64' i v h let free_stack64 start finish h = BS.free_stack' start finish h let valid_src_stack128 i st = BS.valid_src_stack128 i st let load_stack128 i st = BS.eval_stack128 i st let store_stack128 i v h = BS.update_stack128' i v h let free_stack128 start finish h = BS.free_stack' start finish h let init_r1 h = h.initial_r1 (* Lemmas *) #push-options "--z3rlimit 40" let lemma_store_stack_same_valid64 ptr v h i = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap64_reveal () let lemma_free_stack_same_valid64 start finish ptr h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish) let lemma_store_stack_same_valid128 ptr v h i = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; BS.update_heap32_reveal (); BS.update_heap128_reveal () let lemma_free_stack_same_valid128 start finish ptr h = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish) let lemma_store_new_valid64 ptr v h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap64_reveal () let lemma_store_new_valid128 ptr v h = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; BS.update_heap32_reveal (); BS.update_heap128_reveal () #pop-options let lemma_correct_store_load_stack64 ptr v h = let Machine_stack _ mem = h in correct_update_get64 ptr v mem let lemma_frame_store_load_stack64 ptr v h i = let Machine_stack _ mem = h in frame_update_heap64 ptr v mem; BS.get_heap_val64_reveal () let lemma_free_stack_same_load64 start finish ptr h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish); BS.get_heap_val64_reveal () let lemma_correct_store_load_stack128 ptr v h = let Machine_stack _ mem = h in correct_update_get128 ptr v mem let lemma_frame_store_load_stack128 ptr v h i = let Machine_stack _ mem = h in frame_update_heap128 ptr v mem; BS.get_heap_val32_reveal (); BS.get_heap_val128_reveal () let lemma_free_stack_same_load128 start finish ptr h = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish); BS.get_heap_val32_reveal (); BS.get_heap_val128_reveal () let lemma_compose_free_stack64 start inter finish h = let Machine_stack _ mem = h in let domain = Map.domain mem in let map_restr = Map.restrict (Vale.Lib.Set.remove_between domain start inter) mem in let restrict = Map.domain map_restr in let Machine_stack _ mem1 = free_stack64 inter finish (free_stack64 start inter h) in let Machine_stack _ mem2 = free_stack64 start finish h in let aux (i:int) : Lemma (Map.contains mem1 i = Map.contains mem2 i /\ Map.sel mem1 i = Map.sel mem2 i) = Vale.Lib.Set.remove_between_reveal domain start inter i; Vale.Lib.Set.remove_between_reveal restrict inter finish i; Vale.Lib.Set.remove_between_reveal domain start finish i; Vale.Lib.Set.lemma_sel_restrict (Vale.Lib.Set.remove_between domain start inter) mem i; Vale.Lib.Set.lemma_sel_restrict (Vale.Lib.Set.remove_between restrict inter finish) map_restr i; Vale.Lib.Set.lemma_sel_restrict (Vale.Lib.Set.remove_between domain start finish) mem i in Classical.forall_intro aux; assert (Map.equal mem1 mem2) let lemma_same_init_r1_free_stack64 start finish h = () let lemma_same_init_r1_store_stack64 ptr v h = () let lemma_same_init_r1_free_stack128 start finish h = () let lemma_same_init_r1_store_stack128 ptr v h = () let valid_taint_stack64 ptr t stackTaint = Map.sel stackTaint ptr = t && Map.sel stackTaint (ptr + 1) = t && Map.sel stackTaint (ptr + 2) = t && Map.sel stackTaint (ptr + 3) = t && Map.sel stackTaint (ptr + 4) = t && Map.sel stackTaint (ptr + 5) = t && Map.sel stackTaint (ptr + 6) = t && Map.sel stackTaint (ptr + 7) = t let valid_taint_stack128 ptr t stackTaint = Map.sel stackTaint ptr = t && Map.sel stackTaint (ptr + 1) = t && Map.sel stackTaint (ptr + 2) = t && Map.sel stackTaint (ptr + 3) = t && Map.sel stackTaint (ptr + 4) = t && Map.sel stackTaint (ptr + 5) = t && Map.sel stackTaint (ptr + 6) = t && Map.sel stackTaint (ptr + 7) = t && Map.sel stackTaint (ptr + 8) = t && Map.sel stackTaint (ptr + 9) = t && Map.sel stackTaint (ptr + 10) = t && Map.sel stackTaint (ptr + 11) = t && Map.sel stackTaint (ptr + 12) = t && Map.sel stackTaint (ptr + 13) = t && Map.sel stackTaint (ptr + 14) = t && Map.sel stackTaint (ptr + 15) = t let store_taint_stack64 ptr t stackTaint = BS.update_n ptr 8 stackTaint t let store_taint_stack128 ptr t stackTaint = BS.update_n ptr 16 stackTaint t let lemma_valid_taint_stack64 ptr t stackTaint = () let lemma_valid_taint_stack128 ptr t stackTaint = () let lemma_valid_taint_stack64_reveal ptr t stackTaint = () let lemma_correct_store_load_taint_stack64 ptr t stackTaint = () let lemma_frame_store_load_taint_stack64 ptr t stackTaint i t' = () let lemma_valid_taint_stack128_reveal ptr t stackTaint = () let lemma_correct_store_load_taint_stack128 ptr t stackTaint = () let lemma_frame_store_load_taint_stack128 ptr t stackTaint i t' = () let lemma_store_stack_same_valid64_128 ptr v h i = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap128_reveal (); BS.update_heap32_reveal ()
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.Stack_i.fst" }
[ { "abbrev": false, "full_module": "Vale.Arch.MachineHeap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "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
ptr: Prims.int -> v: Vale.PPC64LE.Memory.quad32 -> h: Vale.PPC64LE.Stack_i.vale_stack -> i: Prims.int -> FStar.Pervasives.Lemma (requires Vale.PPC64LE.Stack_i.valid_src_stack64 i h /\ (i >= ptr + 16 \/ i + 8 <= ptr)) (ensures Vale.PPC64LE.Stack_i.load_stack64 i (Vale.PPC64LE.Stack_i.store_stack128 ptr v h) == Vale.PPC64LE.Stack_i.load_stack64 i h) [SMTPat (Vale.PPC64LE.Stack_i.load_stack64 i (Vale.PPC64LE.Stack_i.store_stack128 ptr v h))]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.int", "Vale.PPC64LE.Memory.quad32", "Vale.PPC64LE.Stack_i.vale_stack", "Vale.PPC64LE.Machine_s.nat64", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.Map.t", "Vale.PPC64LE.Machine_s.nat8", "Vale.Arch.MachineHeap_s.get_heap_val64_reveal", "Prims.unit", "Vale.Arch.MachineHeap.frame_update_heap128" ]
[]
false
false
true
false
false
let lemma_frame_store_load_stack64_128 ptr v h i =
let Machine_stack _ mem = h in frame_update_heap128 ptr v mem; BS.get_heap_val64_reveal ()
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.ln_comp
val ln_comp : Type0
let ln_comp = c:comp_st { ln_c c }
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 34, "end_line": 28, "start_col": 0, "start_line": 28 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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" ]
[]
[ "Pulse.Syntax.Base.comp_st", "Prims.b2t", "Pulse.Syntax.Naming.ln_c" ]
[]
false
false
false
true
true
let ln_comp =
c: comp_st{ln_c c}
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.bind_res
val bind_res : u2: FStar.Stubs.Reflection.Types.universe -> t2: FStar.Stubs.Reflection.Types.term -> pre: FStar.Stubs.Reflection.Types.term -> post2: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 29, "end_line": 181, "start_col": 0, "start_line": 180 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u2: FStar.Stubs.Reflection.Types.universe -> t2: FStar.Stubs.Reflection.Types.term -> pre: FStar.Stubs.Reflection.Types.term -> post2: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.universe", "FStar.Stubs.Reflection.Types.term", "Pulse.Reflection.Util.mk_stt_comp" ]
[]
false
false
false
true
false
let bind_res (u2: R.universe) (t2 pre post2: R.term) =
mk_stt_comp u2 t2 pre post2
false
Vale.PPC64LE.Stack_i.fst
Vale.PPC64LE.Stack_i.lemma_compose_free_stack64
val lemma_compose_free_stack64 (start:int) (inter:int) (finish:int) (h:vale_stack) : Lemma (requires start <= inter /\ inter <= finish) (ensures free_stack64 inter finish (free_stack64 start inter h) == free_stack64 start finish h) [SMTPat (free_stack64 inter finish (free_stack64 start inter h))]
val lemma_compose_free_stack64 (start:int) (inter:int) (finish:int) (h:vale_stack) : Lemma (requires start <= inter /\ inter <= finish) (ensures free_stack64 inter finish (free_stack64 start inter h) == free_stack64 start finish h) [SMTPat (free_stack64 inter finish (free_stack64 start inter h))]
let lemma_compose_free_stack64 start inter finish h = let Machine_stack _ mem = h in let domain = Map.domain mem in let map_restr = Map.restrict (Vale.Lib.Set.remove_between domain start inter) mem in let restrict = Map.domain map_restr in let Machine_stack _ mem1 = free_stack64 inter finish (free_stack64 start inter h) in let Machine_stack _ mem2 = free_stack64 start finish h in let aux (i:int) : Lemma (Map.contains mem1 i = Map.contains mem2 i /\ Map.sel mem1 i = Map.sel mem2 i) = Vale.Lib.Set.remove_between_reveal domain start inter i; Vale.Lib.Set.remove_between_reveal restrict inter finish i; Vale.Lib.Set.remove_between_reveal domain start finish i; Vale.Lib.Set.lemma_sel_restrict (Vale.Lib.Set.remove_between domain start inter) mem i; Vale.Lib.Set.lemma_sel_restrict (Vale.Lib.Set.remove_between restrict inter finish) map_restr i; Vale.Lib.Set.lemma_sel_restrict (Vale.Lib.Set.remove_between domain start finish) mem i in Classical.forall_intro aux; assert (Map.equal mem1 mem2)
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Stack_i.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 30, "end_line": 102, "start_col": 0, "start_line": 87 }
module Vale.PPC64LE.Stack_i open FStar.Mul module BS = Vale.PPC64LE.Semantics_s open Vale.Arch.MachineHeap let vale_stack = machine_stack let valid_src_stack64 i st = BS.valid_src_stack64 i st let load_stack64 i st = BS.eval_stack i st let store_stack64 i v h = BS.update_stack64' i v h let free_stack64 start finish h = BS.free_stack' start finish h let valid_src_stack128 i st = BS.valid_src_stack128 i st let load_stack128 i st = BS.eval_stack128 i st let store_stack128 i v h = BS.update_stack128' i v h let free_stack128 start finish h = BS.free_stack' start finish h let init_r1 h = h.initial_r1 (* Lemmas *) #push-options "--z3rlimit 40" let lemma_store_stack_same_valid64 ptr v h i = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap64_reveal () let lemma_free_stack_same_valid64 start finish ptr h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish) let lemma_store_stack_same_valid128 ptr v h i = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; BS.update_heap32_reveal (); BS.update_heap128_reveal () let lemma_free_stack_same_valid128 start finish ptr h = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish) let lemma_store_new_valid64 ptr v h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap64_reveal () let lemma_store_new_valid128 ptr v h = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; BS.update_heap32_reveal (); BS.update_heap128_reveal () #pop-options let lemma_correct_store_load_stack64 ptr v h = let Machine_stack _ mem = h in correct_update_get64 ptr v mem let lemma_frame_store_load_stack64 ptr v h i = let Machine_stack _ mem = h in frame_update_heap64 ptr v mem; BS.get_heap_val64_reveal () let lemma_free_stack_same_load64 start finish ptr h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish); BS.get_heap_val64_reveal () let lemma_correct_store_load_stack128 ptr v h = let Machine_stack _ mem = h in correct_update_get128 ptr v mem let lemma_frame_store_load_stack128 ptr v h i = let Machine_stack _ mem = h in frame_update_heap128 ptr v mem; BS.get_heap_val32_reveal (); BS.get_heap_val128_reveal () let lemma_free_stack_same_load128 start finish ptr h = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish); BS.get_heap_val32_reveal (); BS.get_heap_val128_reveal ()
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.Stack_i.fst" }
[ { "abbrev": false, "full_module": "Vale.Arch.MachineHeap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "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
start: Prims.int -> inter: Prims.int -> finish: Prims.int -> h: Vale.PPC64LE.Stack_i.vale_stack -> FStar.Pervasives.Lemma (requires start <= inter /\ inter <= finish) (ensures Vale.PPC64LE.Stack_i.free_stack64 inter finish (Vale.PPC64LE.Stack_i.free_stack64 start inter h) == Vale.PPC64LE.Stack_i.free_stack64 start finish h) [ SMTPat (Vale.PPC64LE.Stack_i.free_stack64 inter finish (Vale.PPC64LE.Stack_i.free_stack64 start inter h)) ]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.int", "Vale.PPC64LE.Stack_i.vale_stack", "Vale.PPC64LE.Machine_s.nat64", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.Map.t", "Vale.PPC64LE.Machine_s.nat8", "Prims._assert", "FStar.Map.equal", "Prims.unit", "FStar.Classical.forall_intro", "Prims.l_and", "Prims.op_Equality", "Prims.bool", "FStar.Map.contains", "FStar.Map.sel", "Prims.l_True", "Prims.squash", "Vale.Def.Words_s.nat8", "Prims.Nil", "FStar.Pervasives.pattern", "Vale.Lib.Set.lemma_sel_restrict", "Vale.Lib.Set.remove_between", "Vale.Lib.Set.remove_between_reveal", "Vale.PPC64LE.Stack_i.free_stack64", "FStar.Set.set", "FStar.Map.domain", "FStar.Map.restrict" ]
[]
false
false
true
false
false
let lemma_compose_free_stack64 start inter finish h =
let Machine_stack _ mem = h in let domain = Map.domain mem in let map_restr = Map.restrict (Vale.Lib.Set.remove_between domain start inter) mem in let restrict = Map.domain map_restr in let Machine_stack _ mem1 = free_stack64 inter finish (free_stack64 start inter h) in let Machine_stack _ mem2 = free_stack64 start finish h in let aux (i: int) : Lemma (Map.contains mem1 i = Map.contains mem2 i /\ Map.sel mem1 i = Map.sel mem2 i) = Vale.Lib.Set.remove_between_reveal domain start inter i; Vale.Lib.Set.remove_between_reveal restrict inter finish i; Vale.Lib.Set.remove_between_reveal domain start finish i; Vale.Lib.Set.lemma_sel_restrict (Vale.Lib.Set.remove_between domain start inter) mem i; Vale.Lib.Set.lemma_sel_restrict (Vale.Lib.Set.remove_between restrict inter finish) map_restr i; Vale.Lib.Set.lemma_sel_restrict (Vale.Lib.Set.remove_between domain start finish) mem i in Classical.forall_intro aux; assert (Map.equal mem1 mem2)
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.bind_type_t1_t2_pre_post1_post2_f
val bind_type_t1_t2_pre_post1_post2_f : u1: FStar.Stubs.Reflection.Types.universe -> u2: FStar.Stubs.Reflection.Types.universe -> t1: FStar.Stubs.Reflection.Types.term -> t2: FStar.Stubs.Reflection.Types.term -> pre: FStar.Stubs.Reflection.Types.term -> post1: FStar.Stubs.Reflection.Types.term -> post2: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2)
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 37, "end_line": 189, "start_col": 0, "start_line": 187 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u1: FStar.Stubs.Reflection.Types.universe -> u2: FStar.Stubs.Reflection.Types.universe -> t1: FStar.Stubs.Reflection.Types.term -> t2: FStar.Stubs.Reflection.Types.term -> pre: FStar.Stubs.Reflection.Types.term -> post1: FStar.Stubs.Reflection.Types.term -> post2: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.universe", "FStar.Stubs.Reflection.Types.term", "Pulse.Reflection.Util.mk_arrow", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.aqualv", "Pulse.Soundness.Common.g_type_bind", "FStar.Stubs.Reflection.V2.Data.Q_Explicit", "Pulse.Soundness.Common.bind_res" ]
[]
false
false
false
true
false
let bind_type_t1_t2_pre_post1_post2_f (u1 u2: R.universe) (t1 t2 pre post1 post2: R.term) =
mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2)
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.g_type_bind
val g_type_bind : u2: FStar.Stubs.Reflection.Types.universe -> t1: FStar.Stubs.Reflection.Types.term -> t2: FStar.Stubs.Reflection.Types.term -> post1: FStar.Stubs.Reflection.Types.term -> post2: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2)
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 88, "end_line": 185, "start_col": 0, "start_line": 183 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u2: FStar.Stubs.Reflection.Types.universe -> t1: FStar.Stubs.Reflection.Types.term -> t2: FStar.Stubs.Reflection.Types.term -> post1: FStar.Stubs.Reflection.Types.term -> post2: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.universe", "FStar.Stubs.Reflection.Types.term", "Pulse.Reflection.Util.mk_arrow", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Stubs.Reflection.V2.Data.Q_Explicit", "Pulse.Soundness.Common.bind_res", "FStar.Reflection.V2.Derived.mk_app", "Prims.Cons", "FStar.Stubs.Reflection.V2.Data.argv", "Pulse.Reflection.Util.bound_var", "Prims.Nil" ]
[]
false
false
false
true
false
let g_type_bind (u2: R.universe) (t1 t2 post1 post2: R.term) =
mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0, R.Q_Explicit]) post2)
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.ghost_typing_soundness
val ghost_typing_soundness (#g: env) (#e #t: term) (d: ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t))
val ghost_typing_soundness (#g: env) (#e #t: term) (d: ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t))
let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 5, "end_line": 76, "start_col": 0, "start_line": 70 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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: Pulse.Typing.ghost_typing g e t -> Prims.GTot (FStar.Reflection.Typing.ghost_typing (Pulse.Typing.elab_env g) (Pulse.Elaborate.Pure.elab_term e) (Pulse.Elaborate.Pure.elab_term t))
Prims.GTot
[ "sometrivial" ]
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.term", "Pulse.Typing.ghost_typing", "FStar.Reflection.Typing.typing", "Pulse.Typing.elab_env", "Pulse.Elaborate.Pure.elab_term", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.TypeChecker.Core.tot_or_ghost", "FStar.Stubs.Reflection.Types.typ", "FStar.Stubs.TypeChecker.Core.E_Ghost", "FStar.Reflection.Typing.ghost_typing" ]
[]
false
false
false
false
false
let ghost_typing_soundness (#g: env) (#e #t: term) (d: ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) =
let E d = d in d
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.mk_star
val mk_star : l: FStar.Stubs.Reflection.Types.term -> r: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
let mk_star (l r:R.term) = let open R in let head = pack_ln (Tv_FVar (pack_fv star_lid)) in R.mk_app head [(l, Q_Explicit); (r, Q_Explicit)]
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 50, "end_line": 241, "start_col": 0, "start_line": 238 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ]) let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ]) let bind_type_t1 (u1 u2:R.universe) (t1:R.term) = let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [ RT.ND var 0 ]) let bind_type (u1 u2:R.universe) = let var = 4 in let t1 = mk_name var in let t1_type = RT.tm_type u1 in mk_arrow (t1_type, R.Q_Implicit) (RT.subst_term (bind_type_t1 u1 u2 t1) [ RT.ND var 0 ]) (** Type of frame **)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
l: FStar.Stubs.Reflection.Types.term -> r: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.V2.Derived.mk_app", "Prims.Cons", "FStar.Stubs.Reflection.V2.Data.argv", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Stubs.Reflection.V2.Data.Q_Explicit", "Prims.Nil", "FStar.Stubs.Reflection.V2.Builtins.pack_ln", "FStar.Stubs.Reflection.V2.Data.Tv_FVar", "FStar.Stubs.Reflection.V2.Builtins.pack_fv", "Pulse.Reflection.Util.star_lid" ]
[]
false
false
false
true
false
let mk_star (l r: R.term) =
let open R in let head = pack_ln (Tv_FVar (pack_fv star_lid)) in R.mk_app head [(l, Q_Explicit); (r, Q_Explicit)]
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.bind_type_t1_t2
val bind_type_t1_t2 : u1: FStar.Stubs.Reflection.Types.universe -> u2: FStar.Stubs.Reflection.Types.universe -> t1: FStar.Stubs.Reflection.Types.term -> t2: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ])
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 42, "end_line": 218, "start_col": 0, "start_line": 212 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ])
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u1: FStar.Stubs.Reflection.Types.universe -> u2: FStar.Stubs.Reflection.Types.universe -> t1: FStar.Stubs.Reflection.Types.term -> t2: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.universe", "FStar.Stubs.Reflection.Types.term", "Pulse.Reflection.Util.mk_arrow", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Stubs.Reflection.V2.Data.Q_Implicit", "FStar.Reflection.Typing.subst_term", "Pulse.Soundness.Common.bind_type_t1_t2_pre", "Prims.Cons", "FStar.Reflection.Typing.subst_elt", "FStar.Reflection.Typing.ND", "Prims.Nil", "Pulse.Reflection.Util.vprop_tm", "Pulse.Reflection.Util.mk_name", "Prims.int" ]
[]
false
false
false
true
false
let bind_type_t1_t2 (u1 u2: R.universe) (t1 t2: R.term) =
let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [RT.ND var 0])
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.tot_typing_soundness
val tot_typing_soundness (#g: env) (#e #t: term) (d: tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t))
val tot_typing_soundness (#g: env) (#e #t: term) (d: tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t))
let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 5, "end_line": 68, "start_col": 0, "start_line": 62 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!!
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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: Pulse.Typing.tot_typing g e t -> Prims.GTot (FStar.Reflection.Typing.tot_typing (Pulse.Typing.elab_env g) (Pulse.Elaborate.Pure.elab_term e) (Pulse.Elaborate.Pure.elab_term t))
Prims.GTot
[ "sometrivial" ]
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.term", "Pulse.Typing.tot_typing", "FStar.Reflection.Typing.typing", "Pulse.Typing.elab_env", "Pulse.Elaborate.Pure.elab_term", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.TypeChecker.Core.tot_or_ghost", "FStar.Stubs.Reflection.Types.typ", "FStar.Stubs.TypeChecker.Core.E_Total", "FStar.Reflection.Typing.tot_typing" ]
[]
false
false
false
false
false
let tot_typing_soundness (#g: env) (#e #t: term) (d: tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) =
let E d = d in d
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.post2_type_bind
val post2_type_bind : t2: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 61, "end_line": 196, "start_col": 0, "start_line": 196 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t2: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "Pulse.Reflection.Util.mk_arrow", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Stubs.Reflection.V2.Data.Q_Explicit", "Pulse.Reflection.Util.vprop_tm" ]
[]
false
false
false
true
false
let post2_type_bind t2 =
mk_arrow (t2, R.Q_Explicit) vprop_tm
false
Vale.PPC64LE.Stack_i.fst
Vale.PPC64LE.Stack_i.lemma_store_stack_same_valid64_128
val lemma_store_stack_same_valid64_128 (ptr:int) (v:quad32) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack64 i h /\ (i >= ptr + 16 \/ i + 8 <= ptr)) (ensures valid_src_stack64 i (store_stack128 ptr v h)) [SMTPat (valid_src_stack64 i (store_stack128 ptr v h))]
val lemma_store_stack_same_valid64_128 (ptr:int) (v:quad32) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack64 i h /\ (i >= ptr + 16 \/ i + 8 <= ptr)) (ensures valid_src_stack64 i (store_stack128 ptr v h)) [SMTPat (valid_src_stack64 i (store_stack128 ptr v h))]
let lemma_store_stack_same_valid64_128 ptr v h i = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap128_reveal (); BS.update_heap32_reveal ()
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Stack_i.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 28, "end_line": 162, "start_col": 0, "start_line": 159 }
module Vale.PPC64LE.Stack_i open FStar.Mul module BS = Vale.PPC64LE.Semantics_s open Vale.Arch.MachineHeap let vale_stack = machine_stack let valid_src_stack64 i st = BS.valid_src_stack64 i st let load_stack64 i st = BS.eval_stack i st let store_stack64 i v h = BS.update_stack64' i v h let free_stack64 start finish h = BS.free_stack' start finish h let valid_src_stack128 i st = BS.valid_src_stack128 i st let load_stack128 i st = BS.eval_stack128 i st let store_stack128 i v h = BS.update_stack128' i v h let free_stack128 start finish h = BS.free_stack' start finish h let init_r1 h = h.initial_r1 (* Lemmas *) #push-options "--z3rlimit 40" let lemma_store_stack_same_valid64 ptr v h i = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap64_reveal () let lemma_free_stack_same_valid64 start finish ptr h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish) let lemma_store_stack_same_valid128 ptr v h i = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; BS.update_heap32_reveal (); BS.update_heap128_reveal () let lemma_free_stack_same_valid128 start finish ptr h = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish) let lemma_store_new_valid64 ptr v h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap64_reveal () let lemma_store_new_valid128 ptr v h = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; BS.update_heap32_reveal (); BS.update_heap128_reveal () #pop-options let lemma_correct_store_load_stack64 ptr v h = let Machine_stack _ mem = h in correct_update_get64 ptr v mem let lemma_frame_store_load_stack64 ptr v h i = let Machine_stack _ mem = h in frame_update_heap64 ptr v mem; BS.get_heap_val64_reveal () let lemma_free_stack_same_load64 start finish ptr h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish); BS.get_heap_val64_reveal () let lemma_correct_store_load_stack128 ptr v h = let Machine_stack _ mem = h in correct_update_get128 ptr v mem let lemma_frame_store_load_stack128 ptr v h i = let Machine_stack _ mem = h in frame_update_heap128 ptr v mem; BS.get_heap_val32_reveal (); BS.get_heap_val128_reveal () let lemma_free_stack_same_load128 start finish ptr h = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish); BS.get_heap_val32_reveal (); BS.get_heap_val128_reveal () let lemma_compose_free_stack64 start inter finish h = let Machine_stack _ mem = h in let domain = Map.domain mem in let map_restr = Map.restrict (Vale.Lib.Set.remove_between domain start inter) mem in let restrict = Map.domain map_restr in let Machine_stack _ mem1 = free_stack64 inter finish (free_stack64 start inter h) in let Machine_stack _ mem2 = free_stack64 start finish h in let aux (i:int) : Lemma (Map.contains mem1 i = Map.contains mem2 i /\ Map.sel mem1 i = Map.sel mem2 i) = Vale.Lib.Set.remove_between_reveal domain start inter i; Vale.Lib.Set.remove_between_reveal restrict inter finish i; Vale.Lib.Set.remove_between_reveal domain start finish i; Vale.Lib.Set.lemma_sel_restrict (Vale.Lib.Set.remove_between domain start inter) mem i; Vale.Lib.Set.lemma_sel_restrict (Vale.Lib.Set.remove_between restrict inter finish) map_restr i; Vale.Lib.Set.lemma_sel_restrict (Vale.Lib.Set.remove_between domain start finish) mem i in Classical.forall_intro aux; assert (Map.equal mem1 mem2) let lemma_same_init_r1_free_stack64 start finish h = () let lemma_same_init_r1_store_stack64 ptr v h = () let lemma_same_init_r1_free_stack128 start finish h = () let lemma_same_init_r1_store_stack128 ptr v h = () let valid_taint_stack64 ptr t stackTaint = Map.sel stackTaint ptr = t && Map.sel stackTaint (ptr + 1) = t && Map.sel stackTaint (ptr + 2) = t && Map.sel stackTaint (ptr + 3) = t && Map.sel stackTaint (ptr + 4) = t && Map.sel stackTaint (ptr + 5) = t && Map.sel stackTaint (ptr + 6) = t && Map.sel stackTaint (ptr + 7) = t let valid_taint_stack128 ptr t stackTaint = Map.sel stackTaint ptr = t && Map.sel stackTaint (ptr + 1) = t && Map.sel stackTaint (ptr + 2) = t && Map.sel stackTaint (ptr + 3) = t && Map.sel stackTaint (ptr + 4) = t && Map.sel stackTaint (ptr + 5) = t && Map.sel stackTaint (ptr + 6) = t && Map.sel stackTaint (ptr + 7) = t && Map.sel stackTaint (ptr + 8) = t && Map.sel stackTaint (ptr + 9) = t && Map.sel stackTaint (ptr + 10) = t && Map.sel stackTaint (ptr + 11) = t && Map.sel stackTaint (ptr + 12) = t && Map.sel stackTaint (ptr + 13) = t && Map.sel stackTaint (ptr + 14) = t && Map.sel stackTaint (ptr + 15) = t let store_taint_stack64 ptr t stackTaint = BS.update_n ptr 8 stackTaint t let store_taint_stack128 ptr t stackTaint = BS.update_n ptr 16 stackTaint t let lemma_valid_taint_stack64 ptr t stackTaint = () let lemma_valid_taint_stack128 ptr t stackTaint = () let lemma_valid_taint_stack64_reveal ptr t stackTaint = () let lemma_correct_store_load_taint_stack64 ptr t stackTaint = () let lemma_frame_store_load_taint_stack64 ptr t stackTaint i t' = () let lemma_valid_taint_stack128_reveal ptr t stackTaint = () let lemma_correct_store_load_taint_stack128 ptr t stackTaint = () let lemma_frame_store_load_taint_stack128 ptr t stackTaint i t' = ()
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.Stack_i.fst" }
[ { "abbrev": false, "full_module": "Vale.Arch.MachineHeap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "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
ptr: Prims.int -> v: Vale.PPC64LE.Memory.quad32 -> h: Vale.PPC64LE.Stack_i.vale_stack -> i: Prims.int -> FStar.Pervasives.Lemma (requires Vale.PPC64LE.Stack_i.valid_src_stack64 i h /\ (i >= ptr + 16 \/ i + 8 <= ptr)) (ensures Vale.PPC64LE.Stack_i.valid_src_stack64 i (Vale.PPC64LE.Stack_i.store_stack128 ptr v h)) [ SMTPat (Vale.PPC64LE.Stack_i.valid_src_stack64 i (Vale.PPC64LE.Stack_i.store_stack128 ptr v h)) ]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.int", "Vale.PPC64LE.Memory.quad32", "Vale.PPC64LE.Stack_i.vale_stack", "Vale.Arch.MachineHeap_s.update_heap32_reveal", "Prims.unit", "Vale.Arch.MachineHeap_s.update_heap128_reveal", "FStar.Pervasives.reveal_opaque", "Vale.Arch.MachineHeap_s.machine_heap", "Prims.bool", "Vale.Arch.MachineHeap_s.valid_addr64" ]
[]
true
false
true
false
false
let lemma_store_stack_same_valid64_128 ptr v h i =
reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap128_reveal (); BS.update_heap32_reveal ()
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.bind_type_t1_t2_pre
val bind_type_t1_t2_pre : u1: FStar.Stubs.Reflection.Types.universe -> u2: FStar.Stubs.Reflection.Types.universe -> t1: FStar.Stubs.Reflection.Types.term -> t2: FStar.Stubs.Reflection.Types.term -> pre: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ])
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 42, "end_line": 210, "start_col": 0, "start_line": 205 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ])
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u1: FStar.Stubs.Reflection.Types.universe -> u2: FStar.Stubs.Reflection.Types.universe -> t1: FStar.Stubs.Reflection.Types.term -> t2: FStar.Stubs.Reflection.Types.term -> pre: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.universe", "FStar.Stubs.Reflection.Types.term", "Pulse.Reflection.Util.mk_arrow", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.aqualv", "Pulse.Soundness.Common.post1_type_bind", "FStar.Stubs.Reflection.V2.Data.Q_Implicit", "FStar.Reflection.Typing.subst_term", "Pulse.Soundness.Common.bind_type_t1_t2_pre_post1", "Prims.Cons", "FStar.Reflection.Typing.subst_elt", "FStar.Reflection.Typing.ND", "Prims.Nil", "Pulse.Reflection.Util.mk_name", "Prims.int" ]
[]
false
false
false
true
false
let bind_type_t1_t2_pre (u1 u2: R.universe) (t1 t2 pre: R.term) =
let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [RT.ND var 0])
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.frame_type_t_pre
val frame_type_t_pre : u204: FStar.Stubs.Reflection.Types.universe -> t: FStar.Stubs.Reflection.Types.term -> pre: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
let frame_type_t_pre (u:R.universe) (t pre:R.term) = let var = 1 in let post = mk_name var in let post_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre_post u t pre post) var)
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 67, "end_line": 265, "start_col": 0, "start_line": 260 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ]) let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ]) let bind_type_t1 (u1 u2:R.universe) (t1:R.term) = let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [ RT.ND var 0 ]) let bind_type (u1 u2:R.universe) = let var = 4 in let t1 = mk_name var in let t1_type = RT.tm_type u1 in mk_arrow (t1_type, R.Q_Implicit) (RT.subst_term (bind_type_t1 u1 u2 t1) [ RT.ND var 0 ]) (** Type of frame **) let mk_star (l r:R.term) = let open R in let head = pack_ln (Tv_FVar (pack_fv star_lid)) in R.mk_app head [(l, Q_Explicit); (r, Q_Explicit)] let frame_res (u:R.universe) (t pre post frame:R.term) = mk_stt_comp u t (mk_star pre frame) (mk_abs t R.Q_Explicit (mk_star (R.mk_app post [bound_var 0, R.Q_Explicit]) frame)) let frame_type_t_pre_post_frame (u:R.universe) (t pre post frame:R.term) = let open R in let f_type = mk_stt_comp u t pre post in mk_arrow (f_type, Q_Explicit) (frame_res u t pre post frame) let frame_type_t_pre_post (u:R.universe) (t pre post:R.term) = let var = 0 in let frame = mk_name var in mk_arrow (vprop_tm, R.Q_Explicit) (RT.close_term (frame_res u t pre post frame) var)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u204: FStar.Stubs.Reflection.Types.universe -> t: FStar.Stubs.Reflection.Types.term -> pre: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.universe", "FStar.Stubs.Reflection.Types.term", "Pulse.Reflection.Util.mk_arrow", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Stubs.Reflection.V2.Data.Q_Implicit", "FStar.Reflection.Typing.close_term", "Pulse.Soundness.Common.frame_type_t_pre_post", "FStar.Stubs.Reflection.V2.Data.Q_Explicit", "Pulse.Reflection.Util.vprop_tm", "Pulse.Reflection.Util.mk_name", "Prims.int" ]
[]
false
false
false
true
false
let frame_type_t_pre (u: R.universe) (t pre: R.term) =
let var = 1 in let post = mk_name var in let post_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre_post u t pre post) var)
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.post1_type_bind
val post1_type_bind : t1: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 61, "end_line": 204, "start_col": 0, "start_line": 204 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ])
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t1: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "Pulse.Reflection.Util.mk_arrow", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Stubs.Reflection.V2.Data.Q_Explicit", "Pulse.Reflection.Util.vprop_tm" ]
[]
false
false
false
true
false
let post1_type_bind t1 =
mk_arrow (t1, R.Q_Explicit) vprop_tm
false
FStar.UInt32.fsti
FStar.UInt32.gte_mask
val gte_mask (a b: t) : Pure t (requires True) (ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\ (v a < v b ==> v c = 0)))
val gte_mask (a b: t) : Pure t (requires True) (ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\ (v a < v b ==> v c = 0)))
let gte_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\ (v a < v b ==> v c = 0))) = let x = a in let y = b in let x_xor_y = logxor x y in let x_sub_y = sub_mod x y in let x_sub_y_xor_y = logxor x_sub_y y in let q = logor x_xor_y x_sub_y_xor_y in let x_xor_q = logxor x q in let x_xor_q_ = shift_right x_xor_q n_minus_one in let c = sub_mod x_xor_q_ (uint_to_t 1) in lemma_sub_msbs x y; lemma_msb_gte (v x) (v y); lemma_msb_gte (v y) (v x); c
{ "file_name": "ulib/FStar.UInt32.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 5, "end_line": 312, "start_col": 0, "start_line": 295 }
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt32 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) unfold let n = 32 /// For FStar.UIntN.fstp: anything that you fix/update here should be /// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of /// this module. /// /// Except, as compared to [FStar.IntN.fstp], here: /// - every occurrence of [int_t] has been replaced with [uint_t] /// - every occurrence of [@%] has been replaced with [%]. /// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers /// This module provides an abstract type for machine integers of a /// given signedness and width. The interface is designed to be safe /// with respect to arithmetic underflow and overflow. /// Note, we have attempted several times to re-design this module to /// make it more amenable to normalization and to impose less overhead /// on the SMT solver when reasoning about machine integer /// arithmetic. The following github issue reports on the current /// status of that work. /// /// https://github.com/FStarLang/FStar/issues/1757 open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (** Abstract type of machine integers, with an underlying representation using a bounded mathematical integer *) new val t : eqtype (** A coercion that projects a bounded mathematical integer from a machine integer *) val v (x:t) : Tot (uint_t n) (** A coercion that injects a bounded mathematical integers into a machine integer *) val uint_to_t (x:uint_t n) : Pure t (requires True) (ensures (fun y -> v y = x)) (** Injection/projection inverse *) val uv_inv (x : t) : Lemma (ensures (uint_to_t (v x) == x)) [SMTPat (v x)] (** Projection/injection inverse *) val vu_inv (x : uint_t n) : Lemma (ensures (v (uint_to_t x) == x)) [SMTPat (uint_to_t x)] (** An alternate form of the injectivity of the [v] projection *) val v_inj (x1 x2: t): Lemma (requires (v x1 == v x2)) (ensures (x1 == x2)) (** Constants 0 and 1 *) val zero : x:t{v x = 0} val one : x:t{v x = 1} (**** Addition primitives *) (** Bounds-respecting addition The precondition enforces that the sum does not overflow, expressing the bound as an addition on mathematical integers *) val add (a:t) (b:t) : Pure t (requires (size (v a + v b) n)) (ensures (fun c -> v a + v b = v c)) (** Underspecified, possibly overflowing addition: The postcondition only enures that the result is the sum of the arguments in case there is no overflow *) val add_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a + v b) n ==> v a + v b = v c)) (** Addition modulo [2^n] Machine integers can always be added, but the postcondition is now in terms of addition modulo [2^n] on mathematical integers *) val add_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c)) (**** Subtraction primitives *) (** Bounds-respecting subtraction The precondition enforces that the difference does not underflow, expressing the bound as a difference on mathematical integers *) val sub (a:t) (b:t) : Pure t (requires (size (v a - v b) n)) (ensures (fun c -> v a - v b = v c)) (** Underspecified, possibly overflowing subtraction: The postcondition only enures that the result is the difference of the arguments in case there is no underflow *) val sub_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a - v b) n ==> v a - v b = v c)) (** Subtraction modulo [2^n] Machine integers can always be subtractd, but the postcondition is now in terms of subtraction modulo [2^n] on mathematical integers *) val sub_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c)) (**** Multiplication primitives *) (** Bounds-respecting multiplication The precondition enforces that the product does not overflow, expressing the bound as a product on mathematical integers *) val mul (a:t) (b:t) : Pure t (requires (size (v a * v b) n)) (ensures (fun c -> v a * v b = v c)) (** Underspecified, possibly overflowing product The postcondition only enures that the result is the product of the arguments in case there is no overflow *) val mul_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a * v b) n ==> v a * v b = v c)) (** Multiplication modulo [2^n] Machine integers can always be multiplied, but the postcondition is now in terms of product modulo [2^n] on mathematical integers *) val mul_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c)) (**** Division primitives *) (** Euclidean division of [a] and [b], with [b] non-zero *) val div (a:t) (b:t{v b <> 0}) : Pure t (requires (True)) (ensures (fun c -> v a / v b = v c)) (**** Modulo primitives *) (** Euclidean remainder The result is the modulus of [a] with respect to a non-zero [b] *) val rem (a:t) (b:t{v b <> 0}) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c)) (**** Bitwise operators *) /// Also see FStar.BV (** Bitwise logical conjunction *) val logand (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logand` v y = v z)) (** Bitwise logical exclusive-or *) val logxor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logxor` v y == v z)) (** Bitwise logical disjunction *) val logor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logor` v y == v z)) (** Bitwise logical negation *) val lognot (x:t) : Pure t (requires True) (ensures (fun z -> lognot (v x) == v z)) (**** Shift operators *) (** Shift right with zero fill, shifting at most the integer width *) val shift_right (a:t) (s:t) : Pure t (requires (v s < n)) (ensures (fun c -> FStar.UInt.shift_right (v a) (v s) = v c)) (** Shift left with zero fill, shifting at most the integer width *) val shift_left (a:t) (s:t) : Pure t (requires (v s < n)) (ensures (fun c -> FStar.UInt.shift_left (v a) (v s) = v c)) (**** Comparison operators *) (** Equality Note, it is safe to also use the polymorphic decidable equality operator [=] *) let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b) (** Greater than *) let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b) (** Greater than or equal *) let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b) (** Less than *) let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b) (** Less than or equal *) let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b) (** Unary negation *) inline_for_extraction let minus (a:t) = add_mod (lognot a) (uint_to_t 1) (** The maximum shift value for this type, i.e. its width minus one, as an *) inline_for_extraction let n_minus_one = uint_to_t (n - 1) #set-options "--z3rlimit 80 --initial_fuel 1 --max_fuel 1" (** A constant-time way to compute the equality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=2e60bb395c1f589a398ec606d611132ef9ef764b Note, the branching on [a=b] is just for proof-purposes. *) [@ CNoInline ] let eq_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\ (v a <> v b ==> v c = 0))) = let x = logxor a b in let minus_x = minus x in let x_or_minus_x = logor x minus_x in let xnx = shift_right x_or_minus_x n_minus_one in let c = sub_mod xnx (uint_to_t 1) in if a = b then begin logxor_self (v a); lognot_lemma_1 #n; logor_lemma_1 (v x); assert (v x = 0 /\ v minus_x = 0 /\ v x_or_minus_x = 0 /\ v xnx = 0); assert (v c = ones n) end else begin logxor_neq_nonzero (v a) (v b); lemma_msb_pow2 #n (v (lognot x)); lemma_msb_pow2 #n (v minus_x); lemma_minus_zero #n (v x); assert (v c = FStar.UInt.zero n) end; c private val lemma_sub_msbs (a:t) (b:t) : Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b)))) (** A constant-time way to compute the [>=] inequality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=0a483a9b431d87eca1b275463c632f8d5551978a *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt32.fsti" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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": 1, "initial_ifuel": 1, "max_fuel": 1, "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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 80, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: FStar.UInt32.t -> b: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t
Prims.Pure
[]
[]
[ "FStar.UInt32.t", "Prims.unit", "FStar.UInt.lemma_msb_gte", "FStar.UInt32.n", "FStar.UInt32.v", "FStar.UInt32.lemma_sub_msbs", "FStar.UInt32.sub_mod", "FStar.UInt32.uint_to_t", "FStar.UInt32.shift_right", "FStar.UInt32.n_minus_one", "FStar.UInt32.logxor", "FStar.UInt32.logor", "Prims.l_True", "Prims.l_and", "Prims.l_imp", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_Equality", "Prims.int", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_LessThan" ]
[]
false
false
false
false
false
let gte_mask (a b: t) : Pure t (requires True) (ensures (fun c -> (v a >= v b ==> v c = pow2 n - 1) /\ (v a < v b ==> v c = 0))) =
let x = a in let y = b in let x_xor_y = logxor x y in let x_sub_y = sub_mod x y in let x_sub_y_xor_y = logxor x_sub_y y in let q = logor x_xor_y x_sub_y_xor_y in let x_xor_q = logxor x q in let x_xor_q_ = shift_right x_xor_q n_minus_one in let c = sub_mod x_xor_q_ (uint_to_t 1) in lemma_sub_msbs x y; lemma_msb_gte (v x) (v y); lemma_msb_gte (v y) (v x); c
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.bind_type_t1_t2_pre_post1
val bind_type_t1_t2_pre_post1 : u1: FStar.Stubs.Reflection.Types.universe -> u2: FStar.Stubs.Reflection.Types.universe -> t1: FStar.Stubs.Reflection.Types.term -> t2: FStar.Stubs.Reflection.Types.term -> pre: FStar.Stubs.Reflection.Types.term -> post1: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ])
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 42, "end_line": 202, "start_col": 0, "start_line": 197 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u1: FStar.Stubs.Reflection.Types.universe -> u2: FStar.Stubs.Reflection.Types.universe -> t1: FStar.Stubs.Reflection.Types.term -> t2: FStar.Stubs.Reflection.Types.term -> pre: FStar.Stubs.Reflection.Types.term -> post1: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.universe", "FStar.Stubs.Reflection.Types.term", "Pulse.Reflection.Util.mk_arrow", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.aqualv", "Pulse.Soundness.Common.post2_type_bind", "FStar.Stubs.Reflection.V2.Data.Q_Implicit", "FStar.Reflection.Typing.subst_term", "Pulse.Soundness.Common.bind_type_t1_t2_pre_post1_post2", "Prims.Cons", "FStar.Reflection.Typing.subst_elt", "FStar.Reflection.Typing.ND", "Prims.Nil", "Pulse.Reflection.Util.mk_name", "Prims.int" ]
[]
false
false
false
true
false
let bind_type_t1_t2_pre_post1 (u1 u2: R.universe) (t1 t2 pre post1: R.term) =
let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [RT.ND var 0])
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.frame_type_t_pre_post
val frame_type_t_pre_post : u198: FStar.Stubs.Reflection.Types.universe -> t: FStar.Stubs.Reflection.Types.term -> pre: FStar.Stubs.Reflection.Types.term -> post: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
let frame_type_t_pre_post (u:R.universe) (t pre post:R.term) = let var = 0 in let frame = mk_name var in mk_arrow (vprop_tm, R.Q_Explicit) (RT.close_term (frame_res u t pre post frame) var)
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 61, "end_line": 258, "start_col": 0, "start_line": 254 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ]) let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ]) let bind_type_t1 (u1 u2:R.universe) (t1:R.term) = let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [ RT.ND var 0 ]) let bind_type (u1 u2:R.universe) = let var = 4 in let t1 = mk_name var in let t1_type = RT.tm_type u1 in mk_arrow (t1_type, R.Q_Implicit) (RT.subst_term (bind_type_t1 u1 u2 t1) [ RT.ND var 0 ]) (** Type of frame **) let mk_star (l r:R.term) = let open R in let head = pack_ln (Tv_FVar (pack_fv star_lid)) in R.mk_app head [(l, Q_Explicit); (r, Q_Explicit)] let frame_res (u:R.universe) (t pre post frame:R.term) = mk_stt_comp u t (mk_star pre frame) (mk_abs t R.Q_Explicit (mk_star (R.mk_app post [bound_var 0, R.Q_Explicit]) frame)) let frame_type_t_pre_post_frame (u:R.universe) (t pre post frame:R.term) = let open R in let f_type = mk_stt_comp u t pre post in mk_arrow (f_type, Q_Explicit) (frame_res u t pre post frame)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u198: FStar.Stubs.Reflection.Types.universe -> t: FStar.Stubs.Reflection.Types.term -> pre: FStar.Stubs.Reflection.Types.term -> post: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.universe", "FStar.Stubs.Reflection.Types.term", "Pulse.Reflection.Util.mk_arrow", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.aqualv", "Pulse.Reflection.Util.vprop_tm", "FStar.Stubs.Reflection.V2.Data.Q_Explicit", "FStar.Reflection.Typing.close_term", "Pulse.Soundness.Common.frame_res", "Pulse.Reflection.Util.mk_name", "Prims.int" ]
[]
false
false
false
true
false
let frame_type_t_pre_post (u: R.universe) (t pre post: R.term) =
let var = 0 in let frame = mk_name var in mk_arrow (vprop_tm, R.Q_Explicit) (RT.close_term (frame_res u t pre post frame) var)
false
Vale.PPC64LE.Stack_i.fst
Vale.PPC64LE.Stack_i.lemma_frame_store_load_stack128
val lemma_frame_store_load_stack128 (ptr:int) (v:quad32) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack128 i h /\ (i >= ptr + 16 \/ i + 16 <= ptr)) (ensures (load_stack128 i (store_stack128 ptr v h) == load_stack128 i h)) [SMTPat (load_stack128 i (store_stack128 ptr v h))]
val lemma_frame_store_load_stack128 (ptr:int) (v:quad32) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack128 i h /\ (i >= ptr + 16 \/ i + 16 <= ptr)) (ensures (load_stack128 i (store_stack128 ptr v h) == load_stack128 i h)) [SMTPat (load_stack128 i (store_stack128 ptr v h))]
let lemma_frame_store_load_stack128 ptr v h i = let Machine_stack _ mem = h in frame_update_heap128 ptr v mem; BS.get_heap_val32_reveal (); BS.get_heap_val128_reveal ()
{ "file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Stack_i.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 30, "end_line": 77, "start_col": 0, "start_line": 73 }
module Vale.PPC64LE.Stack_i open FStar.Mul module BS = Vale.PPC64LE.Semantics_s open Vale.Arch.MachineHeap let vale_stack = machine_stack let valid_src_stack64 i st = BS.valid_src_stack64 i st let load_stack64 i st = BS.eval_stack i st let store_stack64 i v h = BS.update_stack64' i v h let free_stack64 start finish h = BS.free_stack' start finish h let valid_src_stack128 i st = BS.valid_src_stack128 i st let load_stack128 i st = BS.eval_stack128 i st let store_stack128 i v h = BS.update_stack128' i v h let free_stack128 start finish h = BS.free_stack' start finish h let init_r1 h = h.initial_r1 (* Lemmas *) #push-options "--z3rlimit 40" let lemma_store_stack_same_valid64 ptr v h i = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap64_reveal () let lemma_free_stack_same_valid64 start finish ptr h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish) let lemma_store_stack_same_valid128 ptr v h i = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; BS.update_heap32_reveal (); BS.update_heap128_reveal () let lemma_free_stack_same_valid128 start finish ptr h = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish) let lemma_store_new_valid64 ptr v h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; BS.update_heap64_reveal () let lemma_store_new_valid128 ptr v h = reveal_opaque (`%BS.valid_addr128) BS.valid_addr128; BS.update_heap32_reveal (); BS.update_heap128_reveal () #pop-options let lemma_correct_store_load_stack64 ptr v h = let Machine_stack _ mem = h in correct_update_get64 ptr v mem let lemma_frame_store_load_stack64 ptr v h i = let Machine_stack _ mem = h in frame_update_heap64 ptr v mem; BS.get_heap_val64_reveal () let lemma_free_stack_same_load64 start finish ptr h = reveal_opaque (`%BS.valid_addr64) BS.valid_addr64; let Machine_stack _ mem = h in let domain = Map.domain mem in Classical.forall_intro (Vale.Lib.Set.remove_between_reveal domain start finish); BS.get_heap_val64_reveal () let lemma_correct_store_load_stack128 ptr v h = let Machine_stack _ mem = h in correct_update_get128 ptr v mem
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.Semantics_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Arch.MachineHeap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.PPC64LE.Stack_i.fst" }
[ { "abbrev": false, "full_module": "Vale.Arch.MachineHeap", "short_module": null }, { "abbrev": true, "full_module": "Vale.PPC64LE.Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "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
ptr: Prims.int -> v: Vale.PPC64LE.Memory.quad32 -> h: Vale.PPC64LE.Stack_i.vale_stack -> i: Prims.int -> FStar.Pervasives.Lemma (requires Vale.PPC64LE.Stack_i.valid_src_stack128 i h /\ (i >= ptr + 16 \/ i + 16 <= ptr)) (ensures Vale.PPC64LE.Stack_i.load_stack128 i (Vale.PPC64LE.Stack_i.store_stack128 ptr v h) == Vale.PPC64LE.Stack_i.load_stack128 i h) [SMTPat (Vale.PPC64LE.Stack_i.load_stack128 i (Vale.PPC64LE.Stack_i.store_stack128 ptr v h))]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.int", "Vale.PPC64LE.Memory.quad32", "Vale.PPC64LE.Stack_i.vale_stack", "Vale.PPC64LE.Machine_s.nat64", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.Map.t", "Vale.PPC64LE.Machine_s.nat8", "Vale.Arch.MachineHeap_s.get_heap_val128_reveal", "Prims.unit", "Vale.Arch.MachineHeap_s.get_heap_val32_reveal", "Vale.Arch.MachineHeap.frame_update_heap128" ]
[]
false
false
true
false
false
let lemma_frame_store_load_stack128 ptr v h i =
let Machine_stack _ mem = h in frame_update_heap128 ptr v mem; BS.get_heap_val32_reveal (); BS.get_heap_val128_reveal ()
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.frame_res
val frame_res : u180: FStar.Stubs.Reflection.Types.universe -> t: FStar.Stubs.Reflection.Types.term -> pre: FStar.Stubs.Reflection.Types.term -> post: FStar.Stubs.Reflection.Types.term -> frame: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
let frame_res (u:R.universe) (t pre post frame:R.term) = mk_stt_comp u t (mk_star pre frame) (mk_abs t R.Q_Explicit (mk_star (R.mk_app post [bound_var 0, R.Q_Explicit]) frame))
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 101, "end_line": 246, "start_col": 0, "start_line": 243 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ]) let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ]) let bind_type_t1 (u1 u2:R.universe) (t1:R.term) = let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [ RT.ND var 0 ]) let bind_type (u1 u2:R.universe) = let var = 4 in let t1 = mk_name var in let t1_type = RT.tm_type u1 in mk_arrow (t1_type, R.Q_Implicit) (RT.subst_term (bind_type_t1 u1 u2 t1) [ RT.ND var 0 ]) (** Type of frame **) let mk_star (l r:R.term) = let open R in let head = pack_ln (Tv_FVar (pack_fv star_lid)) in R.mk_app head [(l, Q_Explicit); (r, Q_Explicit)]
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u180: FStar.Stubs.Reflection.Types.universe -> t: FStar.Stubs.Reflection.Types.term -> pre: FStar.Stubs.Reflection.Types.term -> post: FStar.Stubs.Reflection.Types.term -> frame: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.universe", "FStar.Stubs.Reflection.Types.term", "Pulse.Reflection.Util.mk_stt_comp", "Pulse.Soundness.Common.mk_star", "Pulse.Reflection.Util.mk_abs", "FStar.Stubs.Reflection.V2.Data.Q_Explicit", "FStar.Reflection.V2.Derived.mk_app", "Prims.Cons", "FStar.Stubs.Reflection.V2.Data.argv", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.aqualv", "Pulse.Reflection.Util.bound_var", "Prims.Nil" ]
[]
false
false
false
true
false
let frame_res (u: R.universe) (t pre post frame: R.term) =
mk_stt_comp u t (mk_star pre frame) (mk_abs t R.Q_Explicit (mk_star (R.mk_app post [bound_var 0, R.Q_Explicit]) frame))
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.bind_type_t1_t2_pre_post1_post2
val bind_type_t1_t2_pre_post1_post2 : u1: FStar.Stubs.Reflection.Types.universe -> u2: FStar.Stubs.Reflection.Types.universe -> t1: FStar.Stubs.Reflection.Types.term -> t2: FStar.Stubs.Reflection.Types.term -> pre: FStar.Stubs.Reflection.Types.term -> post1: FStar.Stubs.Reflection.Types.term -> post2: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2)
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 74, "end_line": 194, "start_col": 0, "start_line": 191 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u1: FStar.Stubs.Reflection.Types.universe -> u2: FStar.Stubs.Reflection.Types.universe -> t1: FStar.Stubs.Reflection.Types.term -> t2: FStar.Stubs.Reflection.Types.term -> pre: FStar.Stubs.Reflection.Types.term -> post1: FStar.Stubs.Reflection.Types.term -> post2: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.universe", "FStar.Stubs.Reflection.Types.term", "Pulse.Reflection.Util.mk_arrow", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Stubs.Reflection.V2.Data.Q_Explicit", "Pulse.Soundness.Common.bind_type_t1_t2_pre_post1_post2_f", "Pulse.Reflection.Util.mk_stt_comp" ]
[]
false
false
false
true
false
let bind_type_t1_t2_pre_post1_post2 (u1 u2: R.universe) (t1 t2 pre post1 post2: R.term) =
let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2)
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.bind_type
val bind_type : u1: FStar.Stubs.Reflection.Types.universe -> u2: FStar.Stubs.Reflection.Types.universe -> FStar.Stubs.Reflection.Types.term
let bind_type (u1 u2:R.universe) = let var = 4 in let t1 = mk_name var in let t1_type = RT.tm_type u1 in mk_arrow (t1_type, R.Q_Implicit) (RT.subst_term (bind_type_t1 u1 u2 t1) [ RT.ND var 0 ])
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 42, "end_line": 234, "start_col": 0, "start_line": 228 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ]) let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ]) let bind_type_t1 (u1 u2:R.universe) (t1:R.term) = let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [ RT.ND var 0 ])
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u1: FStar.Stubs.Reflection.Types.universe -> u2: FStar.Stubs.Reflection.Types.universe -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.universe", "Pulse.Reflection.Util.mk_arrow", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Stubs.Reflection.V2.Data.Q_Implicit", "FStar.Reflection.Typing.subst_term", "Pulse.Soundness.Common.bind_type_t1", "Prims.Cons", "FStar.Reflection.Typing.subst_elt", "FStar.Reflection.Typing.ND", "Prims.Nil", "FStar.Reflection.Typing.tm_type", "Pulse.Reflection.Util.mk_name", "Prims.int" ]
[]
false
false
false
true
false
let bind_type (u1 u2: R.universe) =
let var = 4 in let t1 = mk_name var in let t1_type = RT.tm_type u1 in mk_arrow (t1_type, R.Q_Implicit) (RT.subst_term (bind_type_t1 u1 u2 t1) [RT.ND var 0])
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.frame_type_t_pre_post_frame
val frame_type_t_pre_post_frame : u190: FStar.Stubs.Reflection.Types.universe -> t: FStar.Stubs.Reflection.Types.term -> pre: FStar.Stubs.Reflection.Types.term -> post: FStar.Stubs.Reflection.Types.term -> frame: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
let frame_type_t_pre_post_frame (u:R.universe) (t pre post frame:R.term) = let open R in let f_type = mk_stt_comp u t pre post in mk_arrow (f_type, Q_Explicit) (frame_res u t pre post frame)
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 41, "end_line": 252, "start_col": 0, "start_line": 248 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ]) let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ]) let bind_type_t1 (u1 u2:R.universe) (t1:R.term) = let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [ RT.ND var 0 ]) let bind_type (u1 u2:R.universe) = let var = 4 in let t1 = mk_name var in let t1_type = RT.tm_type u1 in mk_arrow (t1_type, R.Q_Implicit) (RT.subst_term (bind_type_t1 u1 u2 t1) [ RT.ND var 0 ]) (** Type of frame **) let mk_star (l r:R.term) = let open R in let head = pack_ln (Tv_FVar (pack_fv star_lid)) in R.mk_app head [(l, Q_Explicit); (r, Q_Explicit)] let frame_res (u:R.universe) (t pre post frame:R.term) = mk_stt_comp u t (mk_star pre frame) (mk_abs t R.Q_Explicit (mk_star (R.mk_app post [bound_var 0, R.Q_Explicit]) frame))
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u190: FStar.Stubs.Reflection.Types.universe -> t: FStar.Stubs.Reflection.Types.term -> pre: FStar.Stubs.Reflection.Types.term -> post: FStar.Stubs.Reflection.Types.term -> frame: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.universe", "FStar.Stubs.Reflection.Types.term", "Pulse.Reflection.Util.mk_arrow", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Stubs.Reflection.V2.Data.Q_Explicit", "Pulse.Soundness.Common.frame_res", "Pulse.Reflection.Util.mk_stt_comp" ]
[]
false
false
false
true
false
let frame_type_t_pre_post_frame (u: R.universe) (t pre post frame: R.term) =
let open R in let f_type = mk_stt_comp u t pre post in mk_arrow (f_type, Q_Explicit) (frame_res u t pre post frame)
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.bind_type_t1
val bind_type_t1 : u1: FStar.Stubs.Reflection.Types.universe -> u2: FStar.Stubs.Reflection.Types.universe -> t1: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
let bind_type_t1 (u1 u2:R.universe) (t1:R.term) = let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [ RT.ND var 0 ])
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 42, "end_line": 226, "start_col": 0, "start_line": 220 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ]) let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ])
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u1: FStar.Stubs.Reflection.Types.universe -> u2: FStar.Stubs.Reflection.Types.universe -> t1: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.universe", "FStar.Stubs.Reflection.Types.term", "Pulse.Reflection.Util.mk_arrow", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Stubs.Reflection.V2.Data.Q_Implicit", "FStar.Reflection.Typing.subst_term", "Pulse.Soundness.Common.bind_type_t1_t2", "Prims.Cons", "FStar.Reflection.Typing.subst_elt", "FStar.Reflection.Typing.ND", "Prims.Nil", "FStar.Reflection.Typing.tm_type", "Pulse.Reflection.Util.mk_name", "Prims.int" ]
[]
false
false
false
true
false
let bind_type_t1 (u1 u2: R.universe) (t1: R.term) =
let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [RT.ND var 0])
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.frame_type_t
val frame_type_t : u208: FStar.Stubs.Reflection.Types.universe -> t: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
let frame_type_t (u:R.universe) (t:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre u t pre) var)
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 57, "end_line": 272, "start_col": 0, "start_line": 267 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ]) let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ]) let bind_type_t1 (u1 u2:R.universe) (t1:R.term) = let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [ RT.ND var 0 ]) let bind_type (u1 u2:R.universe) = let var = 4 in let t1 = mk_name var in let t1_type = RT.tm_type u1 in mk_arrow (t1_type, R.Q_Implicit) (RT.subst_term (bind_type_t1 u1 u2 t1) [ RT.ND var 0 ]) (** Type of frame **) let mk_star (l r:R.term) = let open R in let head = pack_ln (Tv_FVar (pack_fv star_lid)) in R.mk_app head [(l, Q_Explicit); (r, Q_Explicit)] let frame_res (u:R.universe) (t pre post frame:R.term) = mk_stt_comp u t (mk_star pre frame) (mk_abs t R.Q_Explicit (mk_star (R.mk_app post [bound_var 0, R.Q_Explicit]) frame)) let frame_type_t_pre_post_frame (u:R.universe) (t pre post frame:R.term) = let open R in let f_type = mk_stt_comp u t pre post in mk_arrow (f_type, Q_Explicit) (frame_res u t pre post frame) let frame_type_t_pre_post (u:R.universe) (t pre post:R.term) = let var = 0 in let frame = mk_name var in mk_arrow (vprop_tm, R.Q_Explicit) (RT.close_term (frame_res u t pre post frame) var) let frame_type_t_pre (u:R.universe) (t pre:R.term) = let var = 1 in let post = mk_name var in let post_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre_post u t pre post) var)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u208: FStar.Stubs.Reflection.Types.universe -> t: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.universe", "FStar.Stubs.Reflection.Types.term", "Pulse.Reflection.Util.mk_arrow", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Stubs.Reflection.V2.Data.Q_Implicit", "FStar.Reflection.Typing.close_term", "Pulse.Soundness.Common.frame_type_t_pre", "Pulse.Reflection.Util.vprop_tm", "Pulse.Reflection.Util.mk_name", "Prims.int" ]
[]
false
false
false
true
false
let frame_type_t (u: R.universe) (t: R.term) =
let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre u t pre) var)
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.stt_vprop_post_equiv
val stt_vprop_post_equiv : u220: FStar.Stubs.Reflection.Types.universe -> t: FStar.Stubs.Reflection.Types.term -> t1: FStar.Stubs.Reflection.Types.term -> t2: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
let stt_vprop_post_equiv (u:R.universe) (t t1 t2:R.term) = R.mk_app (stt_vprop_post_equiv_univ_inst u) [(t, R.Q_Implicit); (t1, R.Q_Explicit); (t2, R.Q_Explicit)]
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 70, "end_line": 288, "start_col": 0, "start_line": 286 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ]) let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ]) let bind_type_t1 (u1 u2:R.universe) (t1:R.term) = let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [ RT.ND var 0 ]) let bind_type (u1 u2:R.universe) = let var = 4 in let t1 = mk_name var in let t1_type = RT.tm_type u1 in mk_arrow (t1_type, R.Q_Implicit) (RT.subst_term (bind_type_t1 u1 u2 t1) [ RT.ND var 0 ]) (** Type of frame **) let mk_star (l r:R.term) = let open R in let head = pack_ln (Tv_FVar (pack_fv star_lid)) in R.mk_app head [(l, Q_Explicit); (r, Q_Explicit)] let frame_res (u:R.universe) (t pre post frame:R.term) = mk_stt_comp u t (mk_star pre frame) (mk_abs t R.Q_Explicit (mk_star (R.mk_app post [bound_var 0, R.Q_Explicit]) frame)) let frame_type_t_pre_post_frame (u:R.universe) (t pre post frame:R.term) = let open R in let f_type = mk_stt_comp u t pre post in mk_arrow (f_type, Q_Explicit) (frame_res u t pre post frame) let frame_type_t_pre_post (u:R.universe) (t pre post:R.term) = let var = 0 in let frame = mk_name var in mk_arrow (vprop_tm, R.Q_Explicit) (RT.close_term (frame_res u t pre post frame) var) let frame_type_t_pre (u:R.universe) (t pre:R.term) = let var = 1 in let post = mk_name var in let post_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre_post u t pre post) var) let frame_type_t (u:R.universe) (t:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre u t pre) var) let frame_type (u:R.universe) = let var = 3 in let t = mk_name var in let t_type = RT.tm_type u in mk_arrow (t_type, R.Q_Implicit) (RT.close_term (frame_type_t u t) var) (** Type of sub_stt **) let stt_vprop_post_equiv_fv = R.pack_fv (mk_pulse_lib_core_lid "vprop_post_equiv")
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u220: FStar.Stubs.Reflection.Types.universe -> t: FStar.Stubs.Reflection.Types.term -> t1: FStar.Stubs.Reflection.Types.term -> t2: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.universe", "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.V2.Derived.mk_app", "Pulse.Soundness.Common.stt_vprop_post_equiv_univ_inst", "Prims.Cons", "FStar.Stubs.Reflection.V2.Data.argv", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Stubs.Reflection.V2.Data.Q_Implicit", "FStar.Stubs.Reflection.V2.Data.Q_Explicit", "Prims.Nil" ]
[]
false
false
false
true
false
let stt_vprop_post_equiv (u: R.universe) (t t1 t2: R.term) =
R.mk_app (stt_vprop_post_equiv_univ_inst u) [(t, R.Q_Implicit); (t1, R.Q_Explicit); (t2, R.Q_Explicit)]
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.frame_type
val frame_type : u210: FStar.Stubs.Reflection.Types.universe -> FStar.Stubs.Reflection.Types.term
let frame_type (u:R.universe) = let var = 3 in let t = mk_name var in let t_type = RT.tm_type u in mk_arrow (t_type, R.Q_Implicit) (RT.close_term (frame_type_t u t) var)
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 49, "end_line": 279, "start_col": 0, "start_line": 274 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ]) let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ]) let bind_type_t1 (u1 u2:R.universe) (t1:R.term) = let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [ RT.ND var 0 ]) let bind_type (u1 u2:R.universe) = let var = 4 in let t1 = mk_name var in let t1_type = RT.tm_type u1 in mk_arrow (t1_type, R.Q_Implicit) (RT.subst_term (bind_type_t1 u1 u2 t1) [ RT.ND var 0 ]) (** Type of frame **) let mk_star (l r:R.term) = let open R in let head = pack_ln (Tv_FVar (pack_fv star_lid)) in R.mk_app head [(l, Q_Explicit); (r, Q_Explicit)] let frame_res (u:R.universe) (t pre post frame:R.term) = mk_stt_comp u t (mk_star pre frame) (mk_abs t R.Q_Explicit (mk_star (R.mk_app post [bound_var 0, R.Q_Explicit]) frame)) let frame_type_t_pre_post_frame (u:R.universe) (t pre post frame:R.term) = let open R in let f_type = mk_stt_comp u t pre post in mk_arrow (f_type, Q_Explicit) (frame_res u t pre post frame) let frame_type_t_pre_post (u:R.universe) (t pre post:R.term) = let var = 0 in let frame = mk_name var in mk_arrow (vprop_tm, R.Q_Explicit) (RT.close_term (frame_res u t pre post frame) var) let frame_type_t_pre (u:R.universe) (t pre:R.term) = let var = 1 in let post = mk_name var in let post_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre_post u t pre post) var) let frame_type_t (u:R.universe) (t:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre u t pre) var)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u210: FStar.Stubs.Reflection.Types.universe -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.universe", "Pulse.Reflection.Util.mk_arrow", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Stubs.Reflection.V2.Data.Q_Implicit", "FStar.Reflection.Typing.close_term", "Pulse.Soundness.Common.frame_type_t", "FStar.Reflection.Typing.tm_type", "Pulse.Reflection.Util.mk_name", "Prims.int" ]
[]
false
false
false
true
false
let frame_type (u: R.universe) =
let var = 3 in let t = mk_name var in let t_type = RT.tm_type u in mk_arrow (t_type, R.Q_Implicit) (RT.close_term (frame_type_t u t) var)
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.stt_vprop_post_equiv_fv
val stt_vprop_post_equiv_fv : FStar.Stubs.Reflection.Types.fv
let stt_vprop_post_equiv_fv = R.pack_fv (mk_pulse_lib_core_lid "vprop_post_equiv")
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 82, "end_line": 284, "start_col": 0, "start_line": 284 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ]) let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ]) let bind_type_t1 (u1 u2:R.universe) (t1:R.term) = let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [ RT.ND var 0 ]) let bind_type (u1 u2:R.universe) = let var = 4 in let t1 = mk_name var in let t1_type = RT.tm_type u1 in mk_arrow (t1_type, R.Q_Implicit) (RT.subst_term (bind_type_t1 u1 u2 t1) [ RT.ND var 0 ]) (** Type of frame **) let mk_star (l r:R.term) = let open R in let head = pack_ln (Tv_FVar (pack_fv star_lid)) in R.mk_app head [(l, Q_Explicit); (r, Q_Explicit)] let frame_res (u:R.universe) (t pre post frame:R.term) = mk_stt_comp u t (mk_star pre frame) (mk_abs t R.Q_Explicit (mk_star (R.mk_app post [bound_var 0, R.Q_Explicit]) frame)) let frame_type_t_pre_post_frame (u:R.universe) (t pre post frame:R.term) = let open R in let f_type = mk_stt_comp u t pre post in mk_arrow (f_type, Q_Explicit) (frame_res u t pre post frame) let frame_type_t_pre_post (u:R.universe) (t pre post:R.term) = let var = 0 in let frame = mk_name var in mk_arrow (vprop_tm, R.Q_Explicit) (RT.close_term (frame_res u t pre post frame) var) let frame_type_t_pre (u:R.universe) (t pre:R.term) = let var = 1 in let post = mk_name var in let post_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre_post u t pre post) var) let frame_type_t (u:R.universe) (t:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre u t pre) var) let frame_type (u:R.universe) = let var = 3 in let t = mk_name var in let t_type = RT.tm_type u in mk_arrow (t_type, R.Q_Implicit) (RT.close_term (frame_type_t u t) var) (** Type of sub_stt **)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Stubs.Reflection.Types.fv
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.V2.Builtins.pack_fv", "Pulse.Reflection.Util.mk_pulse_lib_core_lid" ]
[]
false
false
false
true
false
let stt_vprop_post_equiv_fv =
R.pack_fv (mk_pulse_lib_core_lid "vprop_post_equiv")
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.stt_vprop_post_equiv_univ_inst
val stt_vprop_post_equiv_univ_inst : u212: FStar.Stubs.Reflection.Types.universe -> FStar.Stubs.Reflection.Types.term
let stt_vprop_post_equiv_univ_inst u = R.pack_ln (R.Tv_UInst stt_vprop_post_equiv_fv [u])
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 89, "end_line": 285, "start_col": 0, "start_line": 285 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ]) let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ]) let bind_type_t1 (u1 u2:R.universe) (t1:R.term) = let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [ RT.ND var 0 ]) let bind_type (u1 u2:R.universe) = let var = 4 in let t1 = mk_name var in let t1_type = RT.tm_type u1 in mk_arrow (t1_type, R.Q_Implicit) (RT.subst_term (bind_type_t1 u1 u2 t1) [ RT.ND var 0 ]) (** Type of frame **) let mk_star (l r:R.term) = let open R in let head = pack_ln (Tv_FVar (pack_fv star_lid)) in R.mk_app head [(l, Q_Explicit); (r, Q_Explicit)] let frame_res (u:R.universe) (t pre post frame:R.term) = mk_stt_comp u t (mk_star pre frame) (mk_abs t R.Q_Explicit (mk_star (R.mk_app post [bound_var 0, R.Q_Explicit]) frame)) let frame_type_t_pre_post_frame (u:R.universe) (t pre post frame:R.term) = let open R in let f_type = mk_stt_comp u t pre post in mk_arrow (f_type, Q_Explicit) (frame_res u t pre post frame) let frame_type_t_pre_post (u:R.universe) (t pre post:R.term) = let var = 0 in let frame = mk_name var in mk_arrow (vprop_tm, R.Q_Explicit) (RT.close_term (frame_res u t pre post frame) var) let frame_type_t_pre (u:R.universe) (t pre:R.term) = let var = 1 in let post = mk_name var in let post_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre_post u t pre post) var) let frame_type_t (u:R.universe) (t:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre u t pre) var) let frame_type (u:R.universe) = let var = 3 in let t = mk_name var in let t_type = RT.tm_type u in mk_arrow (t_type, R.Q_Implicit) (RT.close_term (frame_type_t u t) var) (** Type of sub_stt **)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u212: FStar.Stubs.Reflection.Types.universe -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.universe", "FStar.Stubs.Reflection.V2.Builtins.pack_ln", "FStar.Stubs.Reflection.V2.Data.Tv_UInst", "Pulse.Soundness.Common.stt_vprop_post_equiv_fv", "Prims.Cons", "Prims.Nil", "FStar.Stubs.Reflection.Types.term" ]
[]
false
false
false
true
false
let stt_vprop_post_equiv_univ_inst u =
R.pack_ln (R.Tv_UInst stt_vprop_post_equiv_fv [u])
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.sub_stt_equiv_pre
val sub_stt_equiv_pre : u254: FStar.Stubs.Reflection.Types.universe -> t: FStar.Stubs.Reflection.Types.term -> pre1: FStar.Stubs.Reflection.Types.term -> post1: FStar.Stubs.Reflection.Types.term -> pre2: FStar.Stubs.Reflection.Types.term -> post2: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
let sub_stt_equiv_pre u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_equiv pre1 pre2, R.Q_Explicit) (sub_stt_equiv_post u t pre1 pre2 post1 post2)
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 57, "end_line": 298, "start_col": 0, "start_line": 296 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ]) let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ]) let bind_type_t1 (u1 u2:R.universe) (t1:R.term) = let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [ RT.ND var 0 ]) let bind_type (u1 u2:R.universe) = let var = 4 in let t1 = mk_name var in let t1_type = RT.tm_type u1 in mk_arrow (t1_type, R.Q_Implicit) (RT.subst_term (bind_type_t1 u1 u2 t1) [ RT.ND var 0 ]) (** Type of frame **) let mk_star (l r:R.term) = let open R in let head = pack_ln (Tv_FVar (pack_fv star_lid)) in R.mk_app head [(l, Q_Explicit); (r, Q_Explicit)] let frame_res (u:R.universe) (t pre post frame:R.term) = mk_stt_comp u t (mk_star pre frame) (mk_abs t R.Q_Explicit (mk_star (R.mk_app post [bound_var 0, R.Q_Explicit]) frame)) let frame_type_t_pre_post_frame (u:R.universe) (t pre post frame:R.term) = let open R in let f_type = mk_stt_comp u t pre post in mk_arrow (f_type, Q_Explicit) (frame_res u t pre post frame) let frame_type_t_pre_post (u:R.universe) (t pre post:R.term) = let var = 0 in let frame = mk_name var in mk_arrow (vprop_tm, R.Q_Explicit) (RT.close_term (frame_res u t pre post frame) var) let frame_type_t_pre (u:R.universe) (t pre:R.term) = let var = 1 in let post = mk_name var in let post_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre_post u t pre post) var) let frame_type_t (u:R.universe) (t:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre u t pre) var) let frame_type (u:R.universe) = let var = 3 in let t = mk_name var in let t_type = RT.tm_type u in mk_arrow (t_type, R.Q_Implicit) (RT.close_term (frame_type_t u t) var) (** Type of sub_stt **) let stt_vprop_post_equiv_fv = R.pack_fv (mk_pulse_lib_core_lid "vprop_post_equiv") let stt_vprop_post_equiv_univ_inst u = R.pack_ln (R.Tv_UInst stt_vprop_post_equiv_fv [u]) let stt_vprop_post_equiv (u:R.universe) (t t1 t2:R.term) = R.mk_app (stt_vprop_post_equiv_univ_inst u) [(t, R.Q_Implicit); (t1, R.Q_Explicit); (t2, R.Q_Explicit)] let sub_stt_res u t pre post = mk_stt_comp u t pre post let sub_stt_equiv_post u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_post_equiv u t post1 post2, R.Q_Explicit) (sub_stt_res u t pre2 post2)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u254: FStar.Stubs.Reflection.Types.universe -> t: FStar.Stubs.Reflection.Types.term -> pre1: FStar.Stubs.Reflection.Types.term -> post1: FStar.Stubs.Reflection.Types.term -> pre2: FStar.Stubs.Reflection.Types.term -> post2: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.universe", "FStar.Stubs.Reflection.Types.term", "Pulse.Reflection.Util.mk_arrow", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.aqualv", "Pulse.Reflection.Util.stt_vprop_equiv", "FStar.Stubs.Reflection.V2.Data.Q_Explicit", "Pulse.Soundness.Common.sub_stt_equiv_post" ]
[]
false
false
false
true
false
let sub_stt_equiv_pre u t pre1 post1 pre2 post2 =
mk_arrow (stt_vprop_equiv pre1 pre2, R.Q_Explicit) (sub_stt_equiv_post u t pre1 pre2 post1 post2)
false
FStar.UInt32.fsti
FStar.UInt32.eq_mask
val eq_mask (a b: t) : Pure t (requires True) (ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\ (v a <> v b ==> v c = 0)))
val eq_mask (a b: t) : Pure t (requires True) (ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\ (v a <> v b ==> v c = 0)))
let eq_mask (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\ (v a <> v b ==> v c = 0))) = let x = logxor a b in let minus_x = minus x in let x_or_minus_x = logor x minus_x in let xnx = shift_right x_or_minus_x n_minus_one in let c = sub_mod xnx (uint_to_t 1) in if a = b then begin logxor_self (v a); lognot_lemma_1 #n; logor_lemma_1 (v x); assert (v x = 0 /\ v minus_x = 0 /\ v x_or_minus_x = 0 /\ v xnx = 0); assert (v c = ones n) end else begin logxor_neq_nonzero (v a) (v b); lemma_msb_pow2 #n (v (lognot x)); lemma_msb_pow2 #n (v minus_x); lemma_minus_zero #n (v x); assert (v c = FStar.UInt.zero n) end; c
{ "file_name": "ulib/FStar.UInt32.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 5, "end_line": 283, "start_col": 0, "start_line": 256 }
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt32 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) unfold let n = 32 /// For FStar.UIntN.fstp: anything that you fix/update here should be /// reflected in [FStar.IntN.fstp], which is mostly a copy-paste of /// this module. /// /// Except, as compared to [FStar.IntN.fstp], here: /// - every occurrence of [int_t] has been replaced with [uint_t] /// - every occurrence of [@%] has been replaced with [%]. /// - some functions (e.g., add_underspec, etc.) are only defined here, not on signed integers /// This module provides an abstract type for machine integers of a /// given signedness and width. The interface is designed to be safe /// with respect to arithmetic underflow and overflow. /// Note, we have attempted several times to re-design this module to /// make it more amenable to normalization and to impose less overhead /// on the SMT solver when reasoning about machine integer /// arithmetic. The following github issue reports on the current /// status of that work. /// /// https://github.com/FStarLang/FStar/issues/1757 open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" (** Abstract type of machine integers, with an underlying representation using a bounded mathematical integer *) new val t : eqtype (** A coercion that projects a bounded mathematical integer from a machine integer *) val v (x:t) : Tot (uint_t n) (** A coercion that injects a bounded mathematical integers into a machine integer *) val uint_to_t (x:uint_t n) : Pure t (requires True) (ensures (fun y -> v y = x)) (** Injection/projection inverse *) val uv_inv (x : t) : Lemma (ensures (uint_to_t (v x) == x)) [SMTPat (v x)] (** Projection/injection inverse *) val vu_inv (x : uint_t n) : Lemma (ensures (v (uint_to_t x) == x)) [SMTPat (uint_to_t x)] (** An alternate form of the injectivity of the [v] projection *) val v_inj (x1 x2: t): Lemma (requires (v x1 == v x2)) (ensures (x1 == x2)) (** Constants 0 and 1 *) val zero : x:t{v x = 0} val one : x:t{v x = 1} (**** Addition primitives *) (** Bounds-respecting addition The precondition enforces that the sum does not overflow, expressing the bound as an addition on mathematical integers *) val add (a:t) (b:t) : Pure t (requires (size (v a + v b) n)) (ensures (fun c -> v a + v b = v c)) (** Underspecified, possibly overflowing addition: The postcondition only enures that the result is the sum of the arguments in case there is no overflow *) val add_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a + v b) n ==> v a + v b = v c)) (** Addition modulo [2^n] Machine integers can always be added, but the postcondition is now in terms of addition modulo [2^n] on mathematical integers *) val add_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c)) (**** Subtraction primitives *) (** Bounds-respecting subtraction The precondition enforces that the difference does not underflow, expressing the bound as a difference on mathematical integers *) val sub (a:t) (b:t) : Pure t (requires (size (v a - v b) n)) (ensures (fun c -> v a - v b = v c)) (** Underspecified, possibly overflowing subtraction: The postcondition only enures that the result is the difference of the arguments in case there is no underflow *) val sub_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a - v b) n ==> v a - v b = v c)) (** Subtraction modulo [2^n] Machine integers can always be subtractd, but the postcondition is now in terms of subtraction modulo [2^n] on mathematical integers *) val sub_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c)) (**** Multiplication primitives *) (** Bounds-respecting multiplication The precondition enforces that the product does not overflow, expressing the bound as a product on mathematical integers *) val mul (a:t) (b:t) : Pure t (requires (size (v a * v b) n)) (ensures (fun c -> v a * v b = v c)) (** Underspecified, possibly overflowing product The postcondition only enures that the result is the product of the arguments in case there is no overflow *) val mul_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a * v b) n ==> v a * v b = v c)) (** Multiplication modulo [2^n] Machine integers can always be multiplied, but the postcondition is now in terms of product modulo [2^n] on mathematical integers *) val mul_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c)) (**** Division primitives *) (** Euclidean division of [a] and [b], with [b] non-zero *) val div (a:t) (b:t{v b <> 0}) : Pure t (requires (True)) (ensures (fun c -> v a / v b = v c)) (**** Modulo primitives *) (** Euclidean remainder The result is the modulus of [a] with respect to a non-zero [b] *) val rem (a:t) (b:t{v b <> 0}) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c)) (**** Bitwise operators *) /// Also see FStar.BV (** Bitwise logical conjunction *) val logand (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logand` v y = v z)) (** Bitwise logical exclusive-or *) val logxor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logxor` v y == v z)) (** Bitwise logical disjunction *) val logor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logor` v y == v z)) (** Bitwise logical negation *) val lognot (x:t) : Pure t (requires True) (ensures (fun z -> lognot (v x) == v z)) (**** Shift operators *) (** Shift right with zero fill, shifting at most the integer width *) val shift_right (a:t) (s:t) : Pure t (requires (v s < n)) (ensures (fun c -> FStar.UInt.shift_right (v a) (v s) = v c)) (** Shift left with zero fill, shifting at most the integer width *) val shift_left (a:t) (s:t) : Pure t (requires (v s < n)) (ensures (fun c -> FStar.UInt.shift_left (v a) (v s) = v c)) (**** Comparison operators *) (** Equality Note, it is safe to also use the polymorphic decidable equality operator [=] *) let eq (a:t) (b:t) : Tot bool = eq #n (v a) (v b) (** Greater than *) let gt (a:t) (b:t) : Tot bool = gt #n (v a) (v b) (** Greater than or equal *) let gte (a:t) (b:t) : Tot bool = gte #n (v a) (v b) (** Less than *) let lt (a:t) (b:t) : Tot bool = lt #n (v a) (v b) (** Less than or equal *) let lte (a:t) (b:t) : Tot bool = lte #n (v a) (v b) (** Unary negation *) inline_for_extraction let minus (a:t) = add_mod (lognot a) (uint_to_t 1) (** The maximum shift value for this type, i.e. its width minus one, as an *) inline_for_extraction let n_minus_one = uint_to_t (n - 1) #set-options "--z3rlimit 80 --initial_fuel 1 --max_fuel 1" (** A constant-time way to compute the equality of two machine integers. With inspiration from https://git.zx2c4.com/WireGuard/commit/src/crypto/curve25519-hacl64.h?id=2e60bb395c1f589a398ec606d611132ef9ef764b Note, the branching on [a=b] is just for proof-purposes. *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt32.fsti" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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": 1, "initial_ifuel": 1, "max_fuel": 1, "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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 80, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: FStar.UInt32.t -> b: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t
Prims.Pure
[]
[]
[ "FStar.UInt32.t", "Prims.unit", "Prims.op_Equality", "Prims._assert", "Prims.b2t", "FStar.UInt.uint_t", "FStar.UInt32.n", "FStar.UInt32.v", "FStar.UInt.ones", "Prims.l_and", "Prims.int", "FStar.UInt.logor_lemma_1", "FStar.UInt.lognot_lemma_1", "FStar.UInt.logxor_self", "Prims.bool", "FStar.UInt.zero", "FStar.UInt.lemma_minus_zero", "FStar.UInt.lemma_msb_pow2", "FStar.UInt32.lognot", "FStar.UInt.logxor_neq_nonzero", "FStar.UInt32.sub_mod", "FStar.UInt32.uint_to_t", "FStar.UInt32.shift_right", "FStar.UInt32.n_minus_one", "FStar.UInt32.logor", "FStar.UInt32.minus", "FStar.UInt32.logxor", "Prims.l_True", "Prims.l_imp", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_disEquality" ]
[]
false
false
false
false
false
let eq_mask (a b: t) : Pure t (requires True) (ensures (fun c -> (v a = v b ==> v c = pow2 n - 1) /\ (v a <> v b ==> v c = 0))) =
let x = logxor a b in let minus_x = minus x in let x_or_minus_x = logor x minus_x in let xnx = shift_right x_or_minus_x n_minus_one in let c = sub_mod xnx (uint_to_t 1) in if a = b then (logxor_self (v a); lognot_lemma_1 #n; logor_lemma_1 (v x); assert (v x = 0 /\ v minus_x = 0 /\ v x_or_minus_x = 0 /\ v xnx = 0); assert (v c = ones n)) else (logxor_neq_nonzero (v a) (v b); lemma_msb_pow2 #n (v (lognot x)); lemma_msb_pow2 #n (v minus_x); lemma_minus_zero #n (v x); assert (v c = FStar.UInt.zero n)); c
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.sub_stt_equiv_post
val sub_stt_equiv_post : u243: FStar.Stubs.Reflection.Types.universe -> t: FStar.Stubs.Reflection.Types.term -> pre1: _ -> post1: FStar.Stubs.Reflection.Types.term -> pre2: FStar.Stubs.Reflection.Types.term -> post2: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
let sub_stt_equiv_post u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_post_equiv u t post1 post2, R.Q_Explicit) (sub_stt_res u t pre2 post2)
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 39, "end_line": 294, "start_col": 0, "start_line": 292 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ]) let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ]) let bind_type_t1 (u1 u2:R.universe) (t1:R.term) = let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [ RT.ND var 0 ]) let bind_type (u1 u2:R.universe) = let var = 4 in let t1 = mk_name var in let t1_type = RT.tm_type u1 in mk_arrow (t1_type, R.Q_Implicit) (RT.subst_term (bind_type_t1 u1 u2 t1) [ RT.ND var 0 ]) (** Type of frame **) let mk_star (l r:R.term) = let open R in let head = pack_ln (Tv_FVar (pack_fv star_lid)) in R.mk_app head [(l, Q_Explicit); (r, Q_Explicit)] let frame_res (u:R.universe) (t pre post frame:R.term) = mk_stt_comp u t (mk_star pre frame) (mk_abs t R.Q_Explicit (mk_star (R.mk_app post [bound_var 0, R.Q_Explicit]) frame)) let frame_type_t_pre_post_frame (u:R.universe) (t pre post frame:R.term) = let open R in let f_type = mk_stt_comp u t pre post in mk_arrow (f_type, Q_Explicit) (frame_res u t pre post frame) let frame_type_t_pre_post (u:R.universe) (t pre post:R.term) = let var = 0 in let frame = mk_name var in mk_arrow (vprop_tm, R.Q_Explicit) (RT.close_term (frame_res u t pre post frame) var) let frame_type_t_pre (u:R.universe) (t pre:R.term) = let var = 1 in let post = mk_name var in let post_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre_post u t pre post) var) let frame_type_t (u:R.universe) (t:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre u t pre) var) let frame_type (u:R.universe) = let var = 3 in let t = mk_name var in let t_type = RT.tm_type u in mk_arrow (t_type, R.Q_Implicit) (RT.close_term (frame_type_t u t) var) (** Type of sub_stt **) let stt_vprop_post_equiv_fv = R.pack_fv (mk_pulse_lib_core_lid "vprop_post_equiv") let stt_vprop_post_equiv_univ_inst u = R.pack_ln (R.Tv_UInst stt_vprop_post_equiv_fv [u]) let stt_vprop_post_equiv (u:R.universe) (t t1 t2:R.term) = R.mk_app (stt_vprop_post_equiv_univ_inst u) [(t, R.Q_Implicit); (t1, R.Q_Explicit); (t2, R.Q_Explicit)] let sub_stt_res u t pre post = mk_stt_comp u t pre post
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u243: FStar.Stubs.Reflection.Types.universe -> t: FStar.Stubs.Reflection.Types.term -> pre1: _ -> post1: FStar.Stubs.Reflection.Types.term -> pre2: FStar.Stubs.Reflection.Types.term -> post2: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.universe", "FStar.Stubs.Reflection.Types.term", "Pulse.Reflection.Util.mk_arrow", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.aqualv", "Pulse.Soundness.Common.stt_vprop_post_equiv", "FStar.Stubs.Reflection.V2.Data.Q_Explicit", "Pulse.Soundness.Common.sub_stt_res" ]
[]
false
false
false
true
false
let sub_stt_equiv_post u t pre1 post1 pre2 post2 =
mk_arrow (stt_vprop_post_equiv u t post1 post2, R.Q_Explicit) (sub_stt_res u t pre2 post2)
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.sub_stt_post2
val sub_stt_post2 : u264: FStar.Stubs.Reflection.Types.universe -> t: FStar.Stubs.Reflection.Types.term -> pre1: FStar.Stubs.Reflection.Types.term -> post1: FStar.Stubs.Reflection.Types.term -> pre2: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
let sub_stt_post2 u t pre1 post1 pre2 = let var = 0 in let post2 = mk_name var in let post2_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post2_type, R.Q_Explicit) (RT.close_term (sub_stt_equiv_pre u t pre1 pre2 post1 post2) var)
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 76, "end_line": 305, "start_col": 0, "start_line": 300 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ]) let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ]) let bind_type_t1 (u1 u2:R.universe) (t1:R.term) = let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [ RT.ND var 0 ]) let bind_type (u1 u2:R.universe) = let var = 4 in let t1 = mk_name var in let t1_type = RT.tm_type u1 in mk_arrow (t1_type, R.Q_Implicit) (RT.subst_term (bind_type_t1 u1 u2 t1) [ RT.ND var 0 ]) (** Type of frame **) let mk_star (l r:R.term) = let open R in let head = pack_ln (Tv_FVar (pack_fv star_lid)) in R.mk_app head [(l, Q_Explicit); (r, Q_Explicit)] let frame_res (u:R.universe) (t pre post frame:R.term) = mk_stt_comp u t (mk_star pre frame) (mk_abs t R.Q_Explicit (mk_star (R.mk_app post [bound_var 0, R.Q_Explicit]) frame)) let frame_type_t_pre_post_frame (u:R.universe) (t pre post frame:R.term) = let open R in let f_type = mk_stt_comp u t pre post in mk_arrow (f_type, Q_Explicit) (frame_res u t pre post frame) let frame_type_t_pre_post (u:R.universe) (t pre post:R.term) = let var = 0 in let frame = mk_name var in mk_arrow (vprop_tm, R.Q_Explicit) (RT.close_term (frame_res u t pre post frame) var) let frame_type_t_pre (u:R.universe) (t pre:R.term) = let var = 1 in let post = mk_name var in let post_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre_post u t pre post) var) let frame_type_t (u:R.universe) (t:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre u t pre) var) let frame_type (u:R.universe) = let var = 3 in let t = mk_name var in let t_type = RT.tm_type u in mk_arrow (t_type, R.Q_Implicit) (RT.close_term (frame_type_t u t) var) (** Type of sub_stt **) let stt_vprop_post_equiv_fv = R.pack_fv (mk_pulse_lib_core_lid "vprop_post_equiv") let stt_vprop_post_equiv_univ_inst u = R.pack_ln (R.Tv_UInst stt_vprop_post_equiv_fv [u]) let stt_vprop_post_equiv (u:R.universe) (t t1 t2:R.term) = R.mk_app (stt_vprop_post_equiv_univ_inst u) [(t, R.Q_Implicit); (t1, R.Q_Explicit); (t2, R.Q_Explicit)] let sub_stt_res u t pre post = mk_stt_comp u t pre post let sub_stt_equiv_post u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_post_equiv u t post1 post2, R.Q_Explicit) (sub_stt_res u t pre2 post2) let sub_stt_equiv_pre u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_equiv pre1 pre2, R.Q_Explicit) (sub_stt_equiv_post u t pre1 pre2 post1 post2)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u264: FStar.Stubs.Reflection.Types.universe -> t: FStar.Stubs.Reflection.Types.term -> pre1: FStar.Stubs.Reflection.Types.term -> post1: FStar.Stubs.Reflection.Types.term -> pre2: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.universe", "FStar.Stubs.Reflection.Types.term", "Pulse.Reflection.Util.mk_arrow", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Stubs.Reflection.V2.Data.Q_Explicit", "FStar.Reflection.Typing.close_term", "Pulse.Soundness.Common.sub_stt_equiv_pre", "Pulse.Reflection.Util.vprop_tm", "Pulse.Reflection.Util.mk_name", "Prims.int" ]
[]
false
false
false
true
false
let sub_stt_post2 u t pre1 post1 pre2 =
let var = 0 in let post2 = mk_name var in let post2_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post2_type, R.Q_Explicit) (RT.close_term (sub_stt_equiv_pre u t pre1 pre2 post1 post2) var)
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.sub_stt_res
val sub_stt_res : u228: FStar.Stubs.Reflection.Types.universe -> t: FStar.Stubs.Reflection.Types.term -> pre: FStar.Stubs.Reflection.Types.term -> post: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
let sub_stt_res u t pre post = mk_stt_comp u t pre post
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 55, "end_line": 290, "start_col": 0, "start_line": 290 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ]) let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ]) let bind_type_t1 (u1 u2:R.universe) (t1:R.term) = let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [ RT.ND var 0 ]) let bind_type (u1 u2:R.universe) = let var = 4 in let t1 = mk_name var in let t1_type = RT.tm_type u1 in mk_arrow (t1_type, R.Q_Implicit) (RT.subst_term (bind_type_t1 u1 u2 t1) [ RT.ND var 0 ]) (** Type of frame **) let mk_star (l r:R.term) = let open R in let head = pack_ln (Tv_FVar (pack_fv star_lid)) in R.mk_app head [(l, Q_Explicit); (r, Q_Explicit)] let frame_res (u:R.universe) (t pre post frame:R.term) = mk_stt_comp u t (mk_star pre frame) (mk_abs t R.Q_Explicit (mk_star (R.mk_app post [bound_var 0, R.Q_Explicit]) frame)) let frame_type_t_pre_post_frame (u:R.universe) (t pre post frame:R.term) = let open R in let f_type = mk_stt_comp u t pre post in mk_arrow (f_type, Q_Explicit) (frame_res u t pre post frame) let frame_type_t_pre_post (u:R.universe) (t pre post:R.term) = let var = 0 in let frame = mk_name var in mk_arrow (vprop_tm, R.Q_Explicit) (RT.close_term (frame_res u t pre post frame) var) let frame_type_t_pre (u:R.universe) (t pre:R.term) = let var = 1 in let post = mk_name var in let post_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre_post u t pre post) var) let frame_type_t (u:R.universe) (t:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre u t pre) var) let frame_type (u:R.universe) = let var = 3 in let t = mk_name var in let t_type = RT.tm_type u in mk_arrow (t_type, R.Q_Implicit) (RT.close_term (frame_type_t u t) var) (** Type of sub_stt **) let stt_vprop_post_equiv_fv = R.pack_fv (mk_pulse_lib_core_lid "vprop_post_equiv") let stt_vprop_post_equiv_univ_inst u = R.pack_ln (R.Tv_UInst stt_vprop_post_equiv_fv [u]) let stt_vprop_post_equiv (u:R.universe) (t t1 t2:R.term) = R.mk_app (stt_vprop_post_equiv_univ_inst u) [(t, R.Q_Implicit); (t1, R.Q_Explicit); (t2, R.Q_Explicit)]
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u228: FStar.Stubs.Reflection.Types.universe -> t: FStar.Stubs.Reflection.Types.term -> pre: FStar.Stubs.Reflection.Types.term -> post: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.universe", "FStar.Stubs.Reflection.Types.term", "Pulse.Reflection.Util.mk_stt_comp" ]
[]
false
false
false
true
false
let sub_stt_res u t pre post =
mk_stt_comp u t pre post
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.sub_stt_pre2
val sub_stt_pre2 : u272: FStar.Stubs.Reflection.Types.universe -> t: FStar.Stubs.Reflection.Types.term -> pre1: FStar.Stubs.Reflection.Types.term -> post1: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
let sub_stt_pre2 u t pre1 post1 = let var = 1 in let pre2 = mk_name var in let pre2_type = vprop_tm in mk_arrow (pre2_type, R.Q_Explicit) (RT.close_term (sub_stt_post2 u t pre1 post1 pre2) var)
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 66, "end_line": 312, "start_col": 0, "start_line": 307 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ]) let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ]) let bind_type_t1 (u1 u2:R.universe) (t1:R.term) = let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [ RT.ND var 0 ]) let bind_type (u1 u2:R.universe) = let var = 4 in let t1 = mk_name var in let t1_type = RT.tm_type u1 in mk_arrow (t1_type, R.Q_Implicit) (RT.subst_term (bind_type_t1 u1 u2 t1) [ RT.ND var 0 ]) (** Type of frame **) let mk_star (l r:R.term) = let open R in let head = pack_ln (Tv_FVar (pack_fv star_lid)) in R.mk_app head [(l, Q_Explicit); (r, Q_Explicit)] let frame_res (u:R.universe) (t pre post frame:R.term) = mk_stt_comp u t (mk_star pre frame) (mk_abs t R.Q_Explicit (mk_star (R.mk_app post [bound_var 0, R.Q_Explicit]) frame)) let frame_type_t_pre_post_frame (u:R.universe) (t pre post frame:R.term) = let open R in let f_type = mk_stt_comp u t pre post in mk_arrow (f_type, Q_Explicit) (frame_res u t pre post frame) let frame_type_t_pre_post (u:R.universe) (t pre post:R.term) = let var = 0 in let frame = mk_name var in mk_arrow (vprop_tm, R.Q_Explicit) (RT.close_term (frame_res u t pre post frame) var) let frame_type_t_pre (u:R.universe) (t pre:R.term) = let var = 1 in let post = mk_name var in let post_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre_post u t pre post) var) let frame_type_t (u:R.universe) (t:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre u t pre) var) let frame_type (u:R.universe) = let var = 3 in let t = mk_name var in let t_type = RT.tm_type u in mk_arrow (t_type, R.Q_Implicit) (RT.close_term (frame_type_t u t) var) (** Type of sub_stt **) let stt_vprop_post_equiv_fv = R.pack_fv (mk_pulse_lib_core_lid "vprop_post_equiv") let stt_vprop_post_equiv_univ_inst u = R.pack_ln (R.Tv_UInst stt_vprop_post_equiv_fv [u]) let stt_vprop_post_equiv (u:R.universe) (t t1 t2:R.term) = R.mk_app (stt_vprop_post_equiv_univ_inst u) [(t, R.Q_Implicit); (t1, R.Q_Explicit); (t2, R.Q_Explicit)] let sub_stt_res u t pre post = mk_stt_comp u t pre post let sub_stt_equiv_post u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_post_equiv u t post1 post2, R.Q_Explicit) (sub_stt_res u t pre2 post2) let sub_stt_equiv_pre u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_equiv pre1 pre2, R.Q_Explicit) (sub_stt_equiv_post u t pre1 pre2 post1 post2) let sub_stt_post2 u t pre1 post1 pre2 = let var = 0 in let post2 = mk_name var in let post2_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post2_type, R.Q_Explicit) (RT.close_term (sub_stt_equiv_pre u t pre1 pre2 post1 post2) var)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u272: FStar.Stubs.Reflection.Types.universe -> t: FStar.Stubs.Reflection.Types.term -> pre1: FStar.Stubs.Reflection.Types.term -> post1: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.universe", "FStar.Stubs.Reflection.Types.term", "Pulse.Reflection.Util.mk_arrow", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Stubs.Reflection.V2.Data.Q_Explicit", "FStar.Reflection.Typing.close_term", "Pulse.Soundness.Common.sub_stt_post2", "Pulse.Reflection.Util.vprop_tm", "Pulse.Reflection.Util.mk_name", "Prims.int" ]
[]
false
false
false
true
false
let sub_stt_pre2 u t pre1 post1 =
let var = 1 in let pre2 = mk_name var in let pre2_type = vprop_tm in mk_arrow (pre2_type, R.Q_Explicit) (RT.close_term (sub_stt_post2 u t pre1 post1 pre2) var)
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.sub_stt_post1
val sub_stt_post1 : u278: FStar.Stubs.Reflection.Types.universe -> t: FStar.Stubs.Reflection.Types.term -> pre1: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
let sub_stt_post1 u t pre1 = let var = 2 in let post1 = mk_name var in let post1_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post1_type, R.Q_Explicit) (RT.close_term (sub_stt_pre2 u t pre1 post1) var)
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 60, "end_line": 319, "start_col": 0, "start_line": 314 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ]) let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ]) let bind_type_t1 (u1 u2:R.universe) (t1:R.term) = let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [ RT.ND var 0 ]) let bind_type (u1 u2:R.universe) = let var = 4 in let t1 = mk_name var in let t1_type = RT.tm_type u1 in mk_arrow (t1_type, R.Q_Implicit) (RT.subst_term (bind_type_t1 u1 u2 t1) [ RT.ND var 0 ]) (** Type of frame **) let mk_star (l r:R.term) = let open R in let head = pack_ln (Tv_FVar (pack_fv star_lid)) in R.mk_app head [(l, Q_Explicit); (r, Q_Explicit)] let frame_res (u:R.universe) (t pre post frame:R.term) = mk_stt_comp u t (mk_star pre frame) (mk_abs t R.Q_Explicit (mk_star (R.mk_app post [bound_var 0, R.Q_Explicit]) frame)) let frame_type_t_pre_post_frame (u:R.universe) (t pre post frame:R.term) = let open R in let f_type = mk_stt_comp u t pre post in mk_arrow (f_type, Q_Explicit) (frame_res u t pre post frame) let frame_type_t_pre_post (u:R.universe) (t pre post:R.term) = let var = 0 in let frame = mk_name var in mk_arrow (vprop_tm, R.Q_Explicit) (RT.close_term (frame_res u t pre post frame) var) let frame_type_t_pre (u:R.universe) (t pre:R.term) = let var = 1 in let post = mk_name var in let post_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre_post u t pre post) var) let frame_type_t (u:R.universe) (t:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre u t pre) var) let frame_type (u:R.universe) = let var = 3 in let t = mk_name var in let t_type = RT.tm_type u in mk_arrow (t_type, R.Q_Implicit) (RT.close_term (frame_type_t u t) var) (** Type of sub_stt **) let stt_vprop_post_equiv_fv = R.pack_fv (mk_pulse_lib_core_lid "vprop_post_equiv") let stt_vprop_post_equiv_univ_inst u = R.pack_ln (R.Tv_UInst stt_vprop_post_equiv_fv [u]) let stt_vprop_post_equiv (u:R.universe) (t t1 t2:R.term) = R.mk_app (stt_vprop_post_equiv_univ_inst u) [(t, R.Q_Implicit); (t1, R.Q_Explicit); (t2, R.Q_Explicit)] let sub_stt_res u t pre post = mk_stt_comp u t pre post let sub_stt_equiv_post u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_post_equiv u t post1 post2, R.Q_Explicit) (sub_stt_res u t pre2 post2) let sub_stt_equiv_pre u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_equiv pre1 pre2, R.Q_Explicit) (sub_stt_equiv_post u t pre1 pre2 post1 post2) let sub_stt_post2 u t pre1 post1 pre2 = let var = 0 in let post2 = mk_name var in let post2_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post2_type, R.Q_Explicit) (RT.close_term (sub_stt_equiv_pre u t pre1 pre2 post1 post2) var) let sub_stt_pre2 u t pre1 post1 = let var = 1 in let pre2 = mk_name var in let pre2_type = vprop_tm in mk_arrow (pre2_type, R.Q_Explicit) (RT.close_term (sub_stt_post2 u t pre1 post1 pre2) var)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u278: FStar.Stubs.Reflection.Types.universe -> t: FStar.Stubs.Reflection.Types.term -> pre1: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.universe", "FStar.Stubs.Reflection.Types.term", "Pulse.Reflection.Util.mk_arrow", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Stubs.Reflection.V2.Data.Q_Explicit", "FStar.Reflection.Typing.close_term", "Pulse.Soundness.Common.sub_stt_pre2", "Pulse.Reflection.Util.vprop_tm", "Pulse.Reflection.Util.mk_name", "Prims.int" ]
[]
false
false
false
true
false
let sub_stt_post1 u t pre1 =
let var = 2 in let post1 = mk_name var in let post1_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post1_type, R.Q_Explicit) (RT.close_term (sub_stt_pre2 u t pre1 post1) var)
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.sub_stt_type
val sub_stt_type : u284: FStar.Stubs.Reflection.Types.universe -> FStar.Stubs.Reflection.Types.term
let sub_stt_type u = let var = 4 in let t = mk_name var in let ty_typ = RT.tm_type u in mk_arrow (ty_typ, R.Q_Explicit) (RT.close_term (sub_stt_pre1 u t) var)
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 49, "end_line": 333, "start_col": 0, "start_line": 328 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ]) let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ]) let bind_type_t1 (u1 u2:R.universe) (t1:R.term) = let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [ RT.ND var 0 ]) let bind_type (u1 u2:R.universe) = let var = 4 in let t1 = mk_name var in let t1_type = RT.tm_type u1 in mk_arrow (t1_type, R.Q_Implicit) (RT.subst_term (bind_type_t1 u1 u2 t1) [ RT.ND var 0 ]) (** Type of frame **) let mk_star (l r:R.term) = let open R in let head = pack_ln (Tv_FVar (pack_fv star_lid)) in R.mk_app head [(l, Q_Explicit); (r, Q_Explicit)] let frame_res (u:R.universe) (t pre post frame:R.term) = mk_stt_comp u t (mk_star pre frame) (mk_abs t R.Q_Explicit (mk_star (R.mk_app post [bound_var 0, R.Q_Explicit]) frame)) let frame_type_t_pre_post_frame (u:R.universe) (t pre post frame:R.term) = let open R in let f_type = mk_stt_comp u t pre post in mk_arrow (f_type, Q_Explicit) (frame_res u t pre post frame) let frame_type_t_pre_post (u:R.universe) (t pre post:R.term) = let var = 0 in let frame = mk_name var in mk_arrow (vprop_tm, R.Q_Explicit) (RT.close_term (frame_res u t pre post frame) var) let frame_type_t_pre (u:R.universe) (t pre:R.term) = let var = 1 in let post = mk_name var in let post_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre_post u t pre post) var) let frame_type_t (u:R.universe) (t:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre u t pre) var) let frame_type (u:R.universe) = let var = 3 in let t = mk_name var in let t_type = RT.tm_type u in mk_arrow (t_type, R.Q_Implicit) (RT.close_term (frame_type_t u t) var) (** Type of sub_stt **) let stt_vprop_post_equiv_fv = R.pack_fv (mk_pulse_lib_core_lid "vprop_post_equiv") let stt_vprop_post_equiv_univ_inst u = R.pack_ln (R.Tv_UInst stt_vprop_post_equiv_fv [u]) let stt_vprop_post_equiv (u:R.universe) (t t1 t2:R.term) = R.mk_app (stt_vprop_post_equiv_univ_inst u) [(t, R.Q_Implicit); (t1, R.Q_Explicit); (t2, R.Q_Explicit)] let sub_stt_res u t pre post = mk_stt_comp u t pre post let sub_stt_equiv_post u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_post_equiv u t post1 post2, R.Q_Explicit) (sub_stt_res u t pre2 post2) let sub_stt_equiv_pre u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_equiv pre1 pre2, R.Q_Explicit) (sub_stt_equiv_post u t pre1 pre2 post1 post2) let sub_stt_post2 u t pre1 post1 pre2 = let var = 0 in let post2 = mk_name var in let post2_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post2_type, R.Q_Explicit) (RT.close_term (sub_stt_equiv_pre u t pre1 pre2 post1 post2) var) let sub_stt_pre2 u t pre1 post1 = let var = 1 in let pre2 = mk_name var in let pre2_type = vprop_tm in mk_arrow (pre2_type, R.Q_Explicit) (RT.close_term (sub_stt_post2 u t pre1 post1 pre2) var) let sub_stt_post1 u t pre1 = let var = 2 in let post1 = mk_name var in let post1_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post1_type, R.Q_Explicit) (RT.close_term (sub_stt_pre2 u t pre1 post1) var) let sub_stt_pre1 u t = let var = 3 in let pre1 = mk_name var in let pre1_type = vprop_tm in mk_arrow (pre1_type, R.Q_Explicit) (RT.close_term (sub_stt_post1 u t pre1) var)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u284: FStar.Stubs.Reflection.Types.universe -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.universe", "Pulse.Reflection.Util.mk_arrow", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Stubs.Reflection.V2.Data.Q_Explicit", "FStar.Reflection.Typing.close_term", "Pulse.Soundness.Common.sub_stt_pre1", "FStar.Reflection.Typing.tm_type", "Pulse.Reflection.Util.mk_name", "Prims.int" ]
[]
false
false
false
true
false
let sub_stt_type u =
let var = 4 in let t = mk_name var in let ty_typ = RT.tm_type u in mk_arrow (ty_typ, R.Q_Explicit) (RT.close_term (sub_stt_pre1 u t) var)
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.sub_stt_pre1
val sub_stt_pre1 : u282: FStar.Stubs.Reflection.Types.universe -> t: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
let sub_stt_pre1 u t = let var = 3 in let pre1 = mk_name var in let pre1_type = vprop_tm in mk_arrow (pre1_type, R.Q_Explicit) (RT.close_term (sub_stt_post1 u t pre1) var)
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 55, "end_line": 326, "start_col": 0, "start_line": 321 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ]) let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ]) let bind_type_t1 (u1 u2:R.universe) (t1:R.term) = let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [ RT.ND var 0 ]) let bind_type (u1 u2:R.universe) = let var = 4 in let t1 = mk_name var in let t1_type = RT.tm_type u1 in mk_arrow (t1_type, R.Q_Implicit) (RT.subst_term (bind_type_t1 u1 u2 t1) [ RT.ND var 0 ]) (** Type of frame **) let mk_star (l r:R.term) = let open R in let head = pack_ln (Tv_FVar (pack_fv star_lid)) in R.mk_app head [(l, Q_Explicit); (r, Q_Explicit)] let frame_res (u:R.universe) (t pre post frame:R.term) = mk_stt_comp u t (mk_star pre frame) (mk_abs t R.Q_Explicit (mk_star (R.mk_app post [bound_var 0, R.Q_Explicit]) frame)) let frame_type_t_pre_post_frame (u:R.universe) (t pre post frame:R.term) = let open R in let f_type = mk_stt_comp u t pre post in mk_arrow (f_type, Q_Explicit) (frame_res u t pre post frame) let frame_type_t_pre_post (u:R.universe) (t pre post:R.term) = let var = 0 in let frame = mk_name var in mk_arrow (vprop_tm, R.Q_Explicit) (RT.close_term (frame_res u t pre post frame) var) let frame_type_t_pre (u:R.universe) (t pre:R.term) = let var = 1 in let post = mk_name var in let post_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre_post u t pre post) var) let frame_type_t (u:R.universe) (t:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre u t pre) var) let frame_type (u:R.universe) = let var = 3 in let t = mk_name var in let t_type = RT.tm_type u in mk_arrow (t_type, R.Q_Implicit) (RT.close_term (frame_type_t u t) var) (** Type of sub_stt **) let stt_vprop_post_equiv_fv = R.pack_fv (mk_pulse_lib_core_lid "vprop_post_equiv") let stt_vprop_post_equiv_univ_inst u = R.pack_ln (R.Tv_UInst stt_vprop_post_equiv_fv [u]) let stt_vprop_post_equiv (u:R.universe) (t t1 t2:R.term) = R.mk_app (stt_vprop_post_equiv_univ_inst u) [(t, R.Q_Implicit); (t1, R.Q_Explicit); (t2, R.Q_Explicit)] let sub_stt_res u t pre post = mk_stt_comp u t pre post let sub_stt_equiv_post u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_post_equiv u t post1 post2, R.Q_Explicit) (sub_stt_res u t pre2 post2) let sub_stt_equiv_pre u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_equiv pre1 pre2, R.Q_Explicit) (sub_stt_equiv_post u t pre1 pre2 post1 post2) let sub_stt_post2 u t pre1 post1 pre2 = let var = 0 in let post2 = mk_name var in let post2_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post2_type, R.Q_Explicit) (RT.close_term (sub_stt_equiv_pre u t pre1 pre2 post1 post2) var) let sub_stt_pre2 u t pre1 post1 = let var = 1 in let pre2 = mk_name var in let pre2_type = vprop_tm in mk_arrow (pre2_type, R.Q_Explicit) (RT.close_term (sub_stt_post2 u t pre1 post1 pre2) var) let sub_stt_post1 u t pre1 = let var = 2 in let post1 = mk_name var in let post1_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post1_type, R.Q_Explicit) (RT.close_term (sub_stt_pre2 u t pre1 post1) var)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
u282: FStar.Stubs.Reflection.Types.universe -> t: FStar.Stubs.Reflection.Types.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.universe", "FStar.Stubs.Reflection.Types.term", "Pulse.Reflection.Util.mk_arrow", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Stubs.Reflection.V2.Data.Q_Explicit", "FStar.Reflection.Typing.close_term", "Pulse.Soundness.Common.sub_stt_post1", "Pulse.Reflection.Util.vprop_tm", "Pulse.Reflection.Util.mk_name", "Prims.int" ]
[]
false
false
false
true
false
let sub_stt_pre1 u t =
let var = 3 in let pre1 = mk_name var in let pre1_type = vprop_tm in mk_arrow (pre1_type, R.Q_Explicit) (RT.close_term (sub_stt_post1 u t pre1) var)
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.elab_comp_open_commute
val elab_comp_open_commute (c: comp) (x: term) : Lemma (ensures elab_comp (open_comp_with c x) == RT.open_with (elab_comp c) (elab_term x)) [SMTPat (elab_comp (open_comp_with c x))]
val elab_comp_open_commute (c: comp) (x: term) : Lemma (ensures elab_comp (open_comp_with c x) == RT.open_with (elab_comp c) (elab_term x)) [SMTPat (elab_comp (open_comp_with c x))]
let elab_comp_open_commute (c:comp) (x:term) : Lemma (ensures elab_comp (open_comp_with c x) == RT.open_with (elab_comp c) (elab_term x)) [SMTPat (elab_comp (open_comp_with c x))] = elab_comp_open_commute c x
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 28, "end_line": 412, "start_col": 0, "start_line": 408 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ]) let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ]) let bind_type_t1 (u1 u2:R.universe) (t1:R.term) = let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [ RT.ND var 0 ]) let bind_type (u1 u2:R.universe) = let var = 4 in let t1 = mk_name var in let t1_type = RT.tm_type u1 in mk_arrow (t1_type, R.Q_Implicit) (RT.subst_term (bind_type_t1 u1 u2 t1) [ RT.ND var 0 ]) (** Type of frame **) let mk_star (l r:R.term) = let open R in let head = pack_ln (Tv_FVar (pack_fv star_lid)) in R.mk_app head [(l, Q_Explicit); (r, Q_Explicit)] let frame_res (u:R.universe) (t pre post frame:R.term) = mk_stt_comp u t (mk_star pre frame) (mk_abs t R.Q_Explicit (mk_star (R.mk_app post [bound_var 0, R.Q_Explicit]) frame)) let frame_type_t_pre_post_frame (u:R.universe) (t pre post frame:R.term) = let open R in let f_type = mk_stt_comp u t pre post in mk_arrow (f_type, Q_Explicit) (frame_res u t pre post frame) let frame_type_t_pre_post (u:R.universe) (t pre post:R.term) = let var = 0 in let frame = mk_name var in mk_arrow (vprop_tm, R.Q_Explicit) (RT.close_term (frame_res u t pre post frame) var) let frame_type_t_pre (u:R.universe) (t pre:R.term) = let var = 1 in let post = mk_name var in let post_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre_post u t pre post) var) let frame_type_t (u:R.universe) (t:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre u t pre) var) let frame_type (u:R.universe) = let var = 3 in let t = mk_name var in let t_type = RT.tm_type u in mk_arrow (t_type, R.Q_Implicit) (RT.close_term (frame_type_t u t) var) (** Type of sub_stt **) let stt_vprop_post_equiv_fv = R.pack_fv (mk_pulse_lib_core_lid "vprop_post_equiv") let stt_vprop_post_equiv_univ_inst u = R.pack_ln (R.Tv_UInst stt_vprop_post_equiv_fv [u]) let stt_vprop_post_equiv (u:R.universe) (t t1 t2:R.term) = R.mk_app (stt_vprop_post_equiv_univ_inst u) [(t, R.Q_Implicit); (t1, R.Q_Explicit); (t2, R.Q_Explicit)] let sub_stt_res u t pre post = mk_stt_comp u t pre post let sub_stt_equiv_post u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_post_equiv u t post1 post2, R.Q_Explicit) (sub_stt_res u t pre2 post2) let sub_stt_equiv_pre u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_equiv pre1 pre2, R.Q_Explicit) (sub_stt_equiv_post u t pre1 pre2 post1 post2) let sub_stt_post2 u t pre1 post1 pre2 = let var = 0 in let post2 = mk_name var in let post2_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post2_type, R.Q_Explicit) (RT.close_term (sub_stt_equiv_pre u t pre1 pre2 post1 post2) var) let sub_stt_pre2 u t pre1 post1 = let var = 1 in let pre2 = mk_name var in let pre2_type = vprop_tm in mk_arrow (pre2_type, R.Q_Explicit) (RT.close_term (sub_stt_post2 u t pre1 post1 pre2) var) let sub_stt_post1 u t pre1 = let var = 2 in let post1 = mk_name var in let post1_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post1_type, R.Q_Explicit) (RT.close_term (sub_stt_pre2 u t pre1 post1) var) let sub_stt_pre1 u t = let var = 3 in let pre1 = mk_name var in let pre1_type = vprop_tm in mk_arrow (pre1_type, R.Q_Explicit) (RT.close_term (sub_stt_post1 u t pre1) var) let sub_stt_type u = let var = 4 in let t = mk_name var in let ty_typ = RT.tm_type u in mk_arrow (ty_typ, R.Q_Explicit) (RT.close_term (sub_stt_pre1 u t) var) (** Properties of environments suitable for elaboration **) let has_stt_bindings (f:RT.fstar_top_env) = RT.lookup_fvar f RT.bool_fv == Some (RT.tm_type RT.u_zero) /\ RT.lookup_fvar f vprop_fv == Some (RT.tm_type u2) /\ True //(forall (u1 u2:R.universe). RT.lookup_fvar_uinst f bind_fv [u1; u2] == Some (bind_type u1 u2)) /\ //(forall (u:R.universe). RT.lookup_fvar_uinst f frame_fv [u] == Some (frame_type u)) /\ //(forall (u:R.universe). RT.lookup_fvar_uinst f subsumption_fv [u] == Some (sub_stt_type u)) let stt_env = e:env { has_stt_bindings (fstar_env e) } let check_top_level_environment (f:RT.fstar_top_env) : option stt_env = admit(); Some (mk_env f) //we should implement this as a runtime check let elab_comp_post (c:comp_st) : R.term = let t = elab_term (comp_res c) in let post = elab_term (comp_post c) in mk_abs t R.Q_Explicit post let comp_post_type (c:comp_st) : R.term = let t = elab_term (comp_res c) in mk_arrow (t, R.Q_Explicit) vprop_tm assume val inversion_of_stt_typing (g:env) (c:comp_st) (#u:R.universe) // _ |- stt u#u t pre (fun (x:t) -> post) : Type _ (_:RT.tot_typing (elab_env g) (elab_comp c) (RT.tm_type u)) : GTot (x:( // _ |- t : Type u#u RT.tot_typing (elab_env g) (elab_term (comp_res c)) (RT.tm_type (comp_u c)) & // _ |- pre : vprop RT.tot_typing (elab_env g) (elab_term (comp_pre c)) (elab_term (tm_vprop)) & // _ |- (fun (x:t) -> post) : t -> vprop RT.tot_typing (elab_env g) (elab_comp_post c) (elab_term (tm_arrow (null_binder (comp_res c)) None (C_Tot tm_vprop)))){ u == universe_of_comp c }) let soundness_t (d:'a) = g:stt_env -> t:st_term -> c:comp -> d':st_typing g t c{d' << d} -> GTot (RT.tot_typing (elab_env g) (elab_st_typing d') (elab_comp c)) let elab_open_commute' (e:term) (v:term) (n:index) : Lemma (ensures RT.subst_term (elab_term e) [ RT.DT n (elab_term v)] == elab_term (open_term' e v n)) [SMTPat (elab_term (open_term' e v n))] = elab_open_commute' e v n let elab_close_commute' (e:term) (v:var) (n:index) : Lemma (RT.subst_term (elab_term e) [ RT.ND v n ] == elab_term (close_term' e v n)) [SMTPat (elab_term (close_term' e v n))] = elab_close_commute' e v n let elab_comp_close_commute (c:comp) (x:var) : Lemma (ensures elab_comp (close_comp c x) == RT.close_term (elab_comp c) x) [SMTPat (elab_comp (close_comp c x))] = elab_comp_close_commute c x
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: Pulse.Syntax.Base.comp -> x: Pulse.Syntax.Base.term -> FStar.Pervasives.Lemma (ensures Pulse.Elaborate.Pure.elab_comp (Pulse.Syntax.Naming.open_comp_with c x) == FStar.Reflection.Typing.open_with (Pulse.Elaborate.Pure.elab_comp c) (Pulse.Elaborate.Pure.elab_term x)) [SMTPat (Pulse.Elaborate.Pure.elab_comp (Pulse.Syntax.Naming.open_comp_with c x))]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Pulse.Syntax.Base.comp", "Pulse.Syntax.Base.term", "Pulse.Elaborate.elab_comp_open_commute", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.Stubs.Reflection.Types.term", "Pulse.Elaborate.Pure.elab_comp", "Pulse.Syntax.Naming.open_comp_with", "FStar.Reflection.Typing.open_with", "Pulse.Elaborate.Pure.elab_term", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
true
false
true
false
false
let elab_comp_open_commute (c: comp) (x: term) : Lemma (ensures elab_comp (open_comp_with c x) == RT.open_with (elab_comp c) (elab_term x)) [SMTPat (elab_comp (open_comp_with c x))] =
elab_comp_open_commute c x
false
Hacl.Impl.Curve25519.AddAndDouble.fst
Hacl.Impl.Curve25519.AddAndDouble.point_add_and_double0
val point_add_and_double0: #s:field_spec -> nq_p1:point s -> ab:lbuffer (limb s) (2ul *! nlimb s) -> dc:lbuffer (limb s) (2ul *! nlimb s) -> tmp2:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 nq_p1 /\ live h0 ab /\ live h0 dc /\ live h0 tmp2 /\ disjoint nq_p1 ab /\ disjoint nq_p1 dc /\ disjoint nq_p1 tmp2 /\ disjoint ab dc /\ disjoint ab tmp2 /\ disjoint dc tmp2 /\ state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1) /\ point_post_add_t h0 (gsub ab 0ul (nlimb s)) /\ point_post_sub_t h0 (gsub ab (nlimb s) (nlimb s))) (ensures fun h0 _ h1 -> modifies (loc nq_p1 |+| loc dc |+| loc tmp2) h0 h1 /\ point_post_add_t h1 (get_x nq_p1) /\ point_post_sub_t h1 (get_z nq_p1) /\ fget_xz h1 nq_p1 == S.add_and_double1_0 (fget_x h0 ab) (fget_z h0 ab) (fget_xz h0 nq_p1))
val point_add_and_double0: #s:field_spec -> nq_p1:point s -> ab:lbuffer (limb s) (2ul *! nlimb s) -> dc:lbuffer (limb s) (2ul *! nlimb s) -> tmp2:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 nq_p1 /\ live h0 ab /\ live h0 dc /\ live h0 tmp2 /\ disjoint nq_p1 ab /\ disjoint nq_p1 dc /\ disjoint nq_p1 tmp2 /\ disjoint ab dc /\ disjoint ab tmp2 /\ disjoint dc tmp2 /\ state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1) /\ point_post_add_t h0 (gsub ab 0ul (nlimb s)) /\ point_post_sub_t h0 (gsub ab (nlimb s) (nlimb s))) (ensures fun h0 _ h1 -> modifies (loc nq_p1 |+| loc dc |+| loc tmp2) h0 h1 /\ point_post_add_t h1 (get_x nq_p1) /\ point_post_sub_t h1 (get_z nq_p1) /\ fget_xz h1 nq_p1 == S.add_and_double1_0 (fget_x h0 ab) (fget_z h0 ab) (fget_xz h0 nq_p1))
let point_add_and_double0 #s nq_p1 ab dc tmp2 = let x3 = sub nq_p1 0ul (nlimb s) in let z3 = sub nq_p1 (nlimb s) (nlimb s) in let a : felem s = sub ab 0ul (nlimb s) in let b : felem s = sub ab (nlimb s) (nlimb s) in let d : felem s = sub dc 0ul (nlimb s) in let c : felem s = sub dc (nlimb s) (nlimb s) in fadd c x3 z3; // c = x3 + z3 fsub d x3 z3; // d = x3 - z3 (* CAN RUN IN PARALLEL *) //fmul d d a; // d = da = d * a //fmul c c b; // c = cb = c * b fmul2 dc dc ab tmp2; // d|c = d*a|c*b fadd x3 d c; // x3 = da + cb fsub z3 d c
{ "file_name": "code/curve25519/Hacl.Impl.Curve25519.AddAndDouble.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 13, "end_line": 87, "start_col": 0, "start_line": 71 }
module Hacl.Impl.Curve25519.AddAndDouble open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Impl.Curve25519.Fields module ST = FStar.HyperStack.ST module F51 = Hacl.Impl.Curve25519.Field51 module F64 = Hacl.Impl.Curve25519.Field64 module P = Spec.Curve25519 module S = Hacl.Spec.Curve25519.AddAndDouble #reset-options "--z3rlimit 300 --fuel 0 --ifuel 1 --using_facts_from '* -FStar.Seq' --record_options" inline_for_extraction noextract let point (s:field_spec) = lbuffer (limb s) (nlimb s +! nlimb s) (* NEEDED ONLY FOR WRAPPERS *) inline_for_extraction noextract let point51 = lbuffer uint64 10ul inline_for_extraction noextract let point64 = lbuffer uint64 8ul (* NEEDED ONLY FOR WRAPPERS *) let get_x #s (p:point s) = gsub p 0ul (nlimb s) let get_z #s (p:point s) = gsub p (nlimb s) (nlimb s) let fget_x (#s:field_spec) (h:mem) (p:point s) = feval h (gsub p 0ul (nlimb s)) let fget_z (#s:field_spec) (h:mem) (p:point s) = feval h (gsub p (nlimb s) (nlimb s)) let fget_xz (#s:field_spec) (h:mem) (p:point s) = fget_x h p, fget_z h p val point_post_sub_t:#s:field_spec -> h:mem -> f:felem s -> Type0 let point_post_sub_t #s h f = match s with | M51 -> F51.felem_fits h f (9, 10, 9, 9, 9) | M64 -> True val point_post_add_t:#s:field_spec -> h:mem -> f:felem s -> Type0 let point_post_add_t #s h f = match s with | M51 -> F51.felem_fits h f (2, 4, 2, 2, 2) | M64 -> True val point_add_and_double0: #s:field_spec -> nq_p1:point s -> ab:lbuffer (limb s) (2ul *! nlimb s) -> dc:lbuffer (limb s) (2ul *! nlimb s) -> tmp2:felem_wide2 s -> Stack unit (requires fun h0 -> live h0 nq_p1 /\ live h0 ab /\ live h0 dc /\ live h0 tmp2 /\ disjoint nq_p1 ab /\ disjoint nq_p1 dc /\ disjoint nq_p1 tmp2 /\ disjoint ab dc /\ disjoint ab tmp2 /\ disjoint dc tmp2 /\ state_inv_t h0 (get_x nq_p1) /\ state_inv_t h0 (get_z nq_p1) /\ point_post_add_t h0 (gsub ab 0ul (nlimb s)) /\ point_post_sub_t h0 (gsub ab (nlimb s) (nlimb s))) (ensures fun h0 _ h1 -> modifies (loc nq_p1 |+| loc dc |+| loc tmp2) h0 h1 /\ point_post_add_t h1 (get_x nq_p1) /\ point_post_sub_t h1 (get_z nq_p1) /\ fget_xz h1 nq_p1 == S.add_and_double1_0 (fget_x h0 ab) (fget_z h0 ab) (fget_xz h0 nq_p1))
{ "checked_file": "/", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Meta.Attribute.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Curve25519.AddAndDouble.fst.checked", "Hacl.Impl.Curve25519.Fields.fst.checked", "Hacl.Impl.Curve25519.Field64.fst.checked", "Hacl.Impl.Curve25519.Field51.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Curve25519.AddAndDouble.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Curve25519.AddAndDouble", "short_module": "S" }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Impl.Curve25519.Field64", "short_module": "F64" }, { "abbrev": true, "full_module": "Hacl.Impl.Curve25519.Field51", "short_module": "F51" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519.Fields", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 300, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
nq_p1: Hacl.Impl.Curve25519.AddAndDouble.point s -> ab: Lib.Buffer.lbuffer (Hacl.Impl.Curve25519.Fields.Core.limb s) (2ul *! Hacl.Impl.Curve25519.Fields.Core.nlimb s) -> dc: Lib.Buffer.lbuffer (Hacl.Impl.Curve25519.Fields.Core.limb s) (2ul *! Hacl.Impl.Curve25519.Fields.Core.nlimb s) -> tmp2: Hacl.Impl.Curve25519.Fields.Core.felem_wide2 s -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.Curve25519.Fields.Core.field_spec", "Hacl.Impl.Curve25519.AddAndDouble.point", "Lib.Buffer.lbuffer", "Hacl.Impl.Curve25519.Fields.Core.limb", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Curve25519.Fields.Core.nlimb", "Hacl.Impl.Curve25519.Fields.Core.felem_wide2", "Hacl.Impl.Curve25519.Fields.Core.fsub", "Prims.unit", "Hacl.Impl.Curve25519.Fields.Core.fadd", "Hacl.Impl.Curve25519.Fields.Core.fmul2", "Hacl.Impl.Curve25519.Fields.Core.felem", "Lib.Buffer.sub", "Lib.Buffer.MUT", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.IntTypes.op_Plus_Bang" ]
[]
false
true
false
false
false
let point_add_and_double0 #s nq_p1 ab dc tmp2 =
let x3 = sub nq_p1 0ul (nlimb s) in let z3 = sub nq_p1 (nlimb s) (nlimb s) in let a:felem s = sub ab 0ul (nlimb s) in let b:felem s = sub ab (nlimb s) (nlimb s) in let d:felem s = sub dc 0ul (nlimb s) in let c:felem s = sub dc (nlimb s) (nlimb s) in fadd c x3 z3; fsub d x3 z3; fmul2 dc dc ab tmp2; fadd x3 d c; fsub z3 d c
false
Hacl.Impl.SHA3.fst
Hacl.Impl.SHA3.rotl
val rotl : a: Lib.IntTypes.uint64 -> b: Lib.IntTypes.size_t{0 < Lib.IntTypes.uint_v b /\ Lib.IntTypes.uint_v b < 64} -> Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.SEC
let rotl (a:uint64) (b:size_t{0 < uint_v b /\ uint_v b < 64}) = rotate_left a b
{ "file_name": "code/sha3/Hacl.Impl.SHA3.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 17, "end_line": 69, "start_col": 0, "start_line": 68 }
module Hacl.Impl.SHA3 open FStar.HyperStack.All open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open LowStar.BufferOps open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Spec.SHA3.Constants module ST = FStar.HyperStack.ST module B = LowStar.Buffer module LSeq = Lib.Sequence module LB = Lib.ByteSequence module Loop = Lib.LoopCombinators module S = Spec.SHA3 module Equiv = Spec.SHA3.Equivalence private let keccak_rotc :x:glbuffer rotc_t 24ul{witnessed x keccak_rotc /\ recallable x} = createL_global rotc_list private let keccak_piln :x:glbuffer piln_t 24ul{witnessed x keccak_piln /\ recallable x} = createL_global piln_list private let keccak_rndc :x:glbuffer pub_uint64 24ul{witnessed x keccak_rndc /\ recallable x} = createL_global rndc_list #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq'" inline_for_extraction noextract let state = lbuffer uint64 25ul inline_for_extraction noextract let index = n:size_t{v n < 5} inline_for_extraction noextract val get: s:state -> x:index -> y:index -> Stack uint64 (requires fun h -> live h s) (ensures fun h0 r h1 -> modifies loc_none h0 h1 /\ r == S.get (as_seq h0 s) (v x) (v y)) let get s x y = s.(x +! 5ul *! y) inline_for_extraction noextract val set: s:state -> x:index -> y:index -> v:uint64 -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.set (as_seq h0 s) (size_v x) (size_v y) v) let set s x y v = s.(x +! 5ul *! y) <- v
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.Equivalence.fst.checked", "Spec.SHA3.Constants.fst.checked", "Spec.SHA3.fst.checked", "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA3.fst" }
[ { "abbrev": true, "full_module": "Spec.SHA3.Equivalence", "short_module": "Equiv" }, { "abbrev": true, "full_module": "Spec.SHA3", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loop" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "LB" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Spec.SHA3.Constants", "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": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "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
a: Lib.IntTypes.uint64 -> b: Lib.IntTypes.size_t{0 < Lib.IntTypes.uint_v b /\ Lib.IntTypes.uint_v b < 64} -> Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.SEC
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.uint64", "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.uint_v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.IntTypes.rotate_left", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.int_t" ]
[]
false
false
false
false
false
let rotl (a: uint64) (b: size_t{0 < uint_v b /\ uint_v b < 64}) =
rotate_left a b
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.elab_close_commute'
val elab_close_commute' (e: term) (v: var) (n: index) : Lemma (RT.subst_term (elab_term e) [RT.ND v n] == elab_term (close_term' e v n)) [SMTPat (elab_term (close_term' e v n))]
val elab_close_commute' (e: term) (v: var) (n: index) : Lemma (RT.subst_term (elab_term e) [RT.ND v n] == elab_term (close_term' e v n)) [SMTPat (elab_term (close_term' e v n))]
let elab_close_commute' (e:term) (v:var) (n:index) : Lemma (RT.subst_term (elab_term e) [ RT.ND v n ] == elab_term (close_term' e v n)) [SMTPat (elab_term (close_term' e v n))] = elab_close_commute' e v n
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 27, "end_line": 400, "start_col": 0, "start_line": 395 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ]) let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ]) let bind_type_t1 (u1 u2:R.universe) (t1:R.term) = let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [ RT.ND var 0 ]) let bind_type (u1 u2:R.universe) = let var = 4 in let t1 = mk_name var in let t1_type = RT.tm_type u1 in mk_arrow (t1_type, R.Q_Implicit) (RT.subst_term (bind_type_t1 u1 u2 t1) [ RT.ND var 0 ]) (** Type of frame **) let mk_star (l r:R.term) = let open R in let head = pack_ln (Tv_FVar (pack_fv star_lid)) in R.mk_app head [(l, Q_Explicit); (r, Q_Explicit)] let frame_res (u:R.universe) (t pre post frame:R.term) = mk_stt_comp u t (mk_star pre frame) (mk_abs t R.Q_Explicit (mk_star (R.mk_app post [bound_var 0, R.Q_Explicit]) frame)) let frame_type_t_pre_post_frame (u:R.universe) (t pre post frame:R.term) = let open R in let f_type = mk_stt_comp u t pre post in mk_arrow (f_type, Q_Explicit) (frame_res u t pre post frame) let frame_type_t_pre_post (u:R.universe) (t pre post:R.term) = let var = 0 in let frame = mk_name var in mk_arrow (vprop_tm, R.Q_Explicit) (RT.close_term (frame_res u t pre post frame) var) let frame_type_t_pre (u:R.universe) (t pre:R.term) = let var = 1 in let post = mk_name var in let post_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre_post u t pre post) var) let frame_type_t (u:R.universe) (t:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre u t pre) var) let frame_type (u:R.universe) = let var = 3 in let t = mk_name var in let t_type = RT.tm_type u in mk_arrow (t_type, R.Q_Implicit) (RT.close_term (frame_type_t u t) var) (** Type of sub_stt **) let stt_vprop_post_equiv_fv = R.pack_fv (mk_pulse_lib_core_lid "vprop_post_equiv") let stt_vprop_post_equiv_univ_inst u = R.pack_ln (R.Tv_UInst stt_vprop_post_equiv_fv [u]) let stt_vprop_post_equiv (u:R.universe) (t t1 t2:R.term) = R.mk_app (stt_vprop_post_equiv_univ_inst u) [(t, R.Q_Implicit); (t1, R.Q_Explicit); (t2, R.Q_Explicit)] let sub_stt_res u t pre post = mk_stt_comp u t pre post let sub_stt_equiv_post u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_post_equiv u t post1 post2, R.Q_Explicit) (sub_stt_res u t pre2 post2) let sub_stt_equiv_pre u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_equiv pre1 pre2, R.Q_Explicit) (sub_stt_equiv_post u t pre1 pre2 post1 post2) let sub_stt_post2 u t pre1 post1 pre2 = let var = 0 in let post2 = mk_name var in let post2_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post2_type, R.Q_Explicit) (RT.close_term (sub_stt_equiv_pre u t pre1 pre2 post1 post2) var) let sub_stt_pre2 u t pre1 post1 = let var = 1 in let pre2 = mk_name var in let pre2_type = vprop_tm in mk_arrow (pre2_type, R.Q_Explicit) (RT.close_term (sub_stt_post2 u t pre1 post1 pre2) var) let sub_stt_post1 u t pre1 = let var = 2 in let post1 = mk_name var in let post1_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post1_type, R.Q_Explicit) (RT.close_term (sub_stt_pre2 u t pre1 post1) var) let sub_stt_pre1 u t = let var = 3 in let pre1 = mk_name var in let pre1_type = vprop_tm in mk_arrow (pre1_type, R.Q_Explicit) (RT.close_term (sub_stt_post1 u t pre1) var) let sub_stt_type u = let var = 4 in let t = mk_name var in let ty_typ = RT.tm_type u in mk_arrow (ty_typ, R.Q_Explicit) (RT.close_term (sub_stt_pre1 u t) var) (** Properties of environments suitable for elaboration **) let has_stt_bindings (f:RT.fstar_top_env) = RT.lookup_fvar f RT.bool_fv == Some (RT.tm_type RT.u_zero) /\ RT.lookup_fvar f vprop_fv == Some (RT.tm_type u2) /\ True //(forall (u1 u2:R.universe). RT.lookup_fvar_uinst f bind_fv [u1; u2] == Some (bind_type u1 u2)) /\ //(forall (u:R.universe). RT.lookup_fvar_uinst f frame_fv [u] == Some (frame_type u)) /\ //(forall (u:R.universe). RT.lookup_fvar_uinst f subsumption_fv [u] == Some (sub_stt_type u)) let stt_env = e:env { has_stt_bindings (fstar_env e) } let check_top_level_environment (f:RT.fstar_top_env) : option stt_env = admit(); Some (mk_env f) //we should implement this as a runtime check let elab_comp_post (c:comp_st) : R.term = let t = elab_term (comp_res c) in let post = elab_term (comp_post c) in mk_abs t R.Q_Explicit post let comp_post_type (c:comp_st) : R.term = let t = elab_term (comp_res c) in mk_arrow (t, R.Q_Explicit) vprop_tm assume val inversion_of_stt_typing (g:env) (c:comp_st) (#u:R.universe) // _ |- stt u#u t pre (fun (x:t) -> post) : Type _ (_:RT.tot_typing (elab_env g) (elab_comp c) (RT.tm_type u)) : GTot (x:( // _ |- t : Type u#u RT.tot_typing (elab_env g) (elab_term (comp_res c)) (RT.tm_type (comp_u c)) & // _ |- pre : vprop RT.tot_typing (elab_env g) (elab_term (comp_pre c)) (elab_term (tm_vprop)) & // _ |- (fun (x:t) -> post) : t -> vprop RT.tot_typing (elab_env g) (elab_comp_post c) (elab_term (tm_arrow (null_binder (comp_res c)) None (C_Tot tm_vprop)))){ u == universe_of_comp c }) let soundness_t (d:'a) = g:stt_env -> t:st_term -> c:comp -> d':st_typing g t c{d' << d} -> GTot (RT.tot_typing (elab_env g) (elab_st_typing d') (elab_comp c)) let elab_open_commute' (e:term) (v:term) (n:index) : Lemma (ensures RT.subst_term (elab_term e) [ RT.DT n (elab_term v)] == elab_term (open_term' e v n)) [SMTPat (elab_term (open_term' e v n))] = elab_open_commute' e v n
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e: Pulse.Syntax.Base.term -> v: Pulse.Syntax.Base.var -> n: Pulse.Syntax.Base.index -> FStar.Pervasives.Lemma (ensures FStar.Reflection.Typing.subst_term (Pulse.Elaborate.Pure.elab_term e) [FStar.Reflection.Typing.ND v n] == Pulse.Elaborate.Pure.elab_term (Pulse.Syntax.Naming.close_term' e v n)) [SMTPat (Pulse.Elaborate.Pure.elab_term (Pulse.Syntax.Naming.close_term' e v n))]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.var", "Pulse.Syntax.Base.index", "Pulse.Elaborate.elab_close_commute'", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.Typing.subst_term", "Pulse.Elaborate.Pure.elab_term", "Prims.Cons", "FStar.Reflection.Typing.subst_elt", "FStar.Reflection.Typing.ND", "Prims.Nil", "Pulse.Syntax.Naming.close_term'", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat" ]
[]
true
false
true
false
false
let elab_close_commute' (e: term) (v: var) (n: index) : Lemma (RT.subst_term (elab_term e) [RT.ND v n] == elab_term (close_term' e v n)) [SMTPat (elab_term (close_term' e v n))] =
elab_close_commute' e v n
false
Hacl.Impl.SHA3.fst
Hacl.Impl.SHA3.state
val state : Type0
let state = lbuffer uint64 25ul
{ "file_name": "code/sha3/Hacl.Impl.SHA3.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 31, "end_line": 37, "start_col": 0, "start_line": 37 }
module Hacl.Impl.SHA3 open FStar.HyperStack.All open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open LowStar.BufferOps open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Spec.SHA3.Constants module ST = FStar.HyperStack.ST module B = LowStar.Buffer module LSeq = Lib.Sequence module LB = Lib.ByteSequence module Loop = Lib.LoopCombinators module S = Spec.SHA3 module Equiv = Spec.SHA3.Equivalence private let keccak_rotc :x:glbuffer rotc_t 24ul{witnessed x keccak_rotc /\ recallable x} = createL_global rotc_list private let keccak_piln :x:glbuffer piln_t 24ul{witnessed x keccak_piln /\ recallable x} = createL_global piln_list private let keccak_rndc :x:glbuffer pub_uint64 24ul{witnessed x keccak_rndc /\ recallable x} = createL_global rndc_list #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq'"
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.Equivalence.fst.checked", "Spec.SHA3.Constants.fst.checked", "Spec.SHA3.fst.checked", "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA3.fst" }
[ { "abbrev": true, "full_module": "Spec.SHA3.Equivalence", "short_module": "Equiv" }, { "abbrev": true, "full_module": "Spec.SHA3", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loop" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "LB" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Spec.SHA3.Constants", "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": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "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
Type0
Prims.Tot
[ "total" ]
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t" ]
[]
false
false
false
true
true
let state =
lbuffer uint64 25ul
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.comp_post_type
val comp_post_type (c: comp_st) : R.term
val comp_post_type (c: comp_st) : R.term
let comp_post_type (c:comp_st) : R.term = let t = elab_term (comp_res c) in mk_arrow (t, R.Q_Explicit) vprop_tm
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 37, "end_line": 357, "start_col": 0, "start_line": 355 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ]) let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ]) let bind_type_t1 (u1 u2:R.universe) (t1:R.term) = let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [ RT.ND var 0 ]) let bind_type (u1 u2:R.universe) = let var = 4 in let t1 = mk_name var in let t1_type = RT.tm_type u1 in mk_arrow (t1_type, R.Q_Implicit) (RT.subst_term (bind_type_t1 u1 u2 t1) [ RT.ND var 0 ]) (** Type of frame **) let mk_star (l r:R.term) = let open R in let head = pack_ln (Tv_FVar (pack_fv star_lid)) in R.mk_app head [(l, Q_Explicit); (r, Q_Explicit)] let frame_res (u:R.universe) (t pre post frame:R.term) = mk_stt_comp u t (mk_star pre frame) (mk_abs t R.Q_Explicit (mk_star (R.mk_app post [bound_var 0, R.Q_Explicit]) frame)) let frame_type_t_pre_post_frame (u:R.universe) (t pre post frame:R.term) = let open R in let f_type = mk_stt_comp u t pre post in mk_arrow (f_type, Q_Explicit) (frame_res u t pre post frame) let frame_type_t_pre_post (u:R.universe) (t pre post:R.term) = let var = 0 in let frame = mk_name var in mk_arrow (vprop_tm, R.Q_Explicit) (RT.close_term (frame_res u t pre post frame) var) let frame_type_t_pre (u:R.universe) (t pre:R.term) = let var = 1 in let post = mk_name var in let post_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre_post u t pre post) var) let frame_type_t (u:R.universe) (t:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre u t pre) var) let frame_type (u:R.universe) = let var = 3 in let t = mk_name var in let t_type = RT.tm_type u in mk_arrow (t_type, R.Q_Implicit) (RT.close_term (frame_type_t u t) var) (** Type of sub_stt **) let stt_vprop_post_equiv_fv = R.pack_fv (mk_pulse_lib_core_lid "vprop_post_equiv") let stt_vprop_post_equiv_univ_inst u = R.pack_ln (R.Tv_UInst stt_vprop_post_equiv_fv [u]) let stt_vprop_post_equiv (u:R.universe) (t t1 t2:R.term) = R.mk_app (stt_vprop_post_equiv_univ_inst u) [(t, R.Q_Implicit); (t1, R.Q_Explicit); (t2, R.Q_Explicit)] let sub_stt_res u t pre post = mk_stt_comp u t pre post let sub_stt_equiv_post u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_post_equiv u t post1 post2, R.Q_Explicit) (sub_stt_res u t pre2 post2) let sub_stt_equiv_pre u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_equiv pre1 pre2, R.Q_Explicit) (sub_stt_equiv_post u t pre1 pre2 post1 post2) let sub_stt_post2 u t pre1 post1 pre2 = let var = 0 in let post2 = mk_name var in let post2_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post2_type, R.Q_Explicit) (RT.close_term (sub_stt_equiv_pre u t pre1 pre2 post1 post2) var) let sub_stt_pre2 u t pre1 post1 = let var = 1 in let pre2 = mk_name var in let pre2_type = vprop_tm in mk_arrow (pre2_type, R.Q_Explicit) (RT.close_term (sub_stt_post2 u t pre1 post1 pre2) var) let sub_stt_post1 u t pre1 = let var = 2 in let post1 = mk_name var in let post1_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post1_type, R.Q_Explicit) (RT.close_term (sub_stt_pre2 u t pre1 post1) var) let sub_stt_pre1 u t = let var = 3 in let pre1 = mk_name var in let pre1_type = vprop_tm in mk_arrow (pre1_type, R.Q_Explicit) (RT.close_term (sub_stt_post1 u t pre1) var) let sub_stt_type u = let var = 4 in let t = mk_name var in let ty_typ = RT.tm_type u in mk_arrow (ty_typ, R.Q_Explicit) (RT.close_term (sub_stt_pre1 u t) var) (** Properties of environments suitable for elaboration **) let has_stt_bindings (f:RT.fstar_top_env) = RT.lookup_fvar f RT.bool_fv == Some (RT.tm_type RT.u_zero) /\ RT.lookup_fvar f vprop_fv == Some (RT.tm_type u2) /\ True //(forall (u1 u2:R.universe). RT.lookup_fvar_uinst f bind_fv [u1; u2] == Some (bind_type u1 u2)) /\ //(forall (u:R.universe). RT.lookup_fvar_uinst f frame_fv [u] == Some (frame_type u)) /\ //(forall (u:R.universe). RT.lookup_fvar_uinst f subsumption_fv [u] == Some (sub_stt_type u)) let stt_env = e:env { has_stt_bindings (fstar_env e) } let check_top_level_environment (f:RT.fstar_top_env) : option stt_env = admit(); Some (mk_env f) //we should implement this as a runtime check let elab_comp_post (c:comp_st) : R.term = let t = elab_term (comp_res c) in let post = elab_term (comp_post c) in mk_abs t R.Q_Explicit post
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: Pulse.Syntax.Base.comp_st -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.comp_st", "Pulse.Reflection.Util.mk_arrow", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Stubs.Reflection.V2.Data.Q_Explicit", "Pulse.Reflection.Util.vprop_tm", "Pulse.Elaborate.Pure.elab_term", "Pulse.Syntax.Base.comp_res" ]
[]
false
false
false
true
false
let comp_post_type (c: comp_st) : R.term =
let t = elab_term (comp_res c) in mk_arrow (t, R.Q_Explicit) vprop_tm
false
Hacl.Impl.SHA3.fst
Hacl.Impl.SHA3.index
val index : Type0
let index = n:size_t{v n < 5}
{ "file_name": "code/sha3/Hacl.Impl.SHA3.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 29, "end_line": 40, "start_col": 0, "start_line": 40 }
module Hacl.Impl.SHA3 open FStar.HyperStack.All open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open LowStar.BufferOps open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Spec.SHA3.Constants module ST = FStar.HyperStack.ST module B = LowStar.Buffer module LSeq = Lib.Sequence module LB = Lib.ByteSequence module Loop = Lib.LoopCombinators module S = Spec.SHA3 module Equiv = Spec.SHA3.Equivalence private let keccak_rotc :x:glbuffer rotc_t 24ul{witnessed x keccak_rotc /\ recallable x} = createL_global rotc_list private let keccak_piln :x:glbuffer piln_t 24ul{witnessed x keccak_piln /\ recallable x} = createL_global piln_list private let keccak_rndc :x:glbuffer pub_uint64 24ul{witnessed x keccak_rndc /\ recallable x} = createL_global rndc_list #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq'" inline_for_extraction noextract let state = lbuffer uint64 25ul
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.Equivalence.fst.checked", "Spec.SHA3.Constants.fst.checked", "Spec.SHA3.fst.checked", "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA3.fst" }
[ { "abbrev": true, "full_module": "Spec.SHA3.Equivalence", "short_module": "Equiv" }, { "abbrev": true, "full_module": "Spec.SHA3", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loop" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "LB" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Spec.SHA3.Constants", "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": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "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
Type0
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB" ]
[]
false
false
false
true
true
let index =
n: size_t{v n < 5}
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.has_stt_bindings
val has_stt_bindings : f: FStar.Reflection.Typing.fstar_top_env -> Prims.logical
let has_stt_bindings (f:RT.fstar_top_env) = RT.lookup_fvar f RT.bool_fv == Some (RT.tm_type RT.u_zero) /\ RT.lookup_fvar f vprop_fv == Some (RT.tm_type u2) /\ True
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 61, "end_line": 339, "start_col": 0, "start_line": 337 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ]) let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ]) let bind_type_t1 (u1 u2:R.universe) (t1:R.term) = let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [ RT.ND var 0 ]) let bind_type (u1 u2:R.universe) = let var = 4 in let t1 = mk_name var in let t1_type = RT.tm_type u1 in mk_arrow (t1_type, R.Q_Implicit) (RT.subst_term (bind_type_t1 u1 u2 t1) [ RT.ND var 0 ]) (** Type of frame **) let mk_star (l r:R.term) = let open R in let head = pack_ln (Tv_FVar (pack_fv star_lid)) in R.mk_app head [(l, Q_Explicit); (r, Q_Explicit)] let frame_res (u:R.universe) (t pre post frame:R.term) = mk_stt_comp u t (mk_star pre frame) (mk_abs t R.Q_Explicit (mk_star (R.mk_app post [bound_var 0, R.Q_Explicit]) frame)) let frame_type_t_pre_post_frame (u:R.universe) (t pre post frame:R.term) = let open R in let f_type = mk_stt_comp u t pre post in mk_arrow (f_type, Q_Explicit) (frame_res u t pre post frame) let frame_type_t_pre_post (u:R.universe) (t pre post:R.term) = let var = 0 in let frame = mk_name var in mk_arrow (vprop_tm, R.Q_Explicit) (RT.close_term (frame_res u t pre post frame) var) let frame_type_t_pre (u:R.universe) (t pre:R.term) = let var = 1 in let post = mk_name var in let post_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre_post u t pre post) var) let frame_type_t (u:R.universe) (t:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre u t pre) var) let frame_type (u:R.universe) = let var = 3 in let t = mk_name var in let t_type = RT.tm_type u in mk_arrow (t_type, R.Q_Implicit) (RT.close_term (frame_type_t u t) var) (** Type of sub_stt **) let stt_vprop_post_equiv_fv = R.pack_fv (mk_pulse_lib_core_lid "vprop_post_equiv") let stt_vprop_post_equiv_univ_inst u = R.pack_ln (R.Tv_UInst stt_vprop_post_equiv_fv [u]) let stt_vprop_post_equiv (u:R.universe) (t t1 t2:R.term) = R.mk_app (stt_vprop_post_equiv_univ_inst u) [(t, R.Q_Implicit); (t1, R.Q_Explicit); (t2, R.Q_Explicit)] let sub_stt_res u t pre post = mk_stt_comp u t pre post let sub_stt_equiv_post u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_post_equiv u t post1 post2, R.Q_Explicit) (sub_stt_res u t pre2 post2) let sub_stt_equiv_pre u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_equiv pre1 pre2, R.Q_Explicit) (sub_stt_equiv_post u t pre1 pre2 post1 post2) let sub_stt_post2 u t pre1 post1 pre2 = let var = 0 in let post2 = mk_name var in let post2_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post2_type, R.Q_Explicit) (RT.close_term (sub_stt_equiv_pre u t pre1 pre2 post1 post2) var) let sub_stt_pre2 u t pre1 post1 = let var = 1 in let pre2 = mk_name var in let pre2_type = vprop_tm in mk_arrow (pre2_type, R.Q_Explicit) (RT.close_term (sub_stt_post2 u t pre1 post1 pre2) var) let sub_stt_post1 u t pre1 = let var = 2 in let post1 = mk_name var in let post1_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post1_type, R.Q_Explicit) (RT.close_term (sub_stt_pre2 u t pre1 post1) var) let sub_stt_pre1 u t = let var = 3 in let pre1 = mk_name var in let pre1_type = vprop_tm in mk_arrow (pre1_type, R.Q_Explicit) (RT.close_term (sub_stt_post1 u t pre1) var) let sub_stt_type u = let var = 4 in let t = mk_name var in let ty_typ = RT.tm_type u in mk_arrow (ty_typ, R.Q_Explicit) (RT.close_term (sub_stt_pre1 u t) var) (** Properties of environments suitable for elaboration **)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: FStar.Reflection.Typing.fstar_top_env -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "FStar.Reflection.Typing.fstar_top_env", "Prims.l_and", "Prims.eq2", "FStar.Pervasives.Native.option", "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.Typing.lookup_fvar", "FStar.Reflection.Typing.bool_fv", "FStar.Pervasives.Native.Some", "FStar.Reflection.Typing.tm_type", "FStar.Reflection.Typing.u_zero", "Pulse.Reflection.Util.vprop_fv", "Pulse.Syntax.Pure.u2", "Prims.l_True", "Prims.logical" ]
[]
false
false
false
true
true
let has_stt_bindings (f: RT.fstar_top_env) =
RT.lookup_fvar f RT.bool_fv == Some (RT.tm_type RT.u_zero) /\ RT.lookup_fvar f vprop_fv == Some (RT.tm_type u2) /\ True
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.stt_env
val stt_env : Type0
let stt_env = e:env { has_stt_bindings (fstar_env e) }
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 54, "end_line": 344, "start_col": 0, "start_line": 344 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ]) let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ]) let bind_type_t1 (u1 u2:R.universe) (t1:R.term) = let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [ RT.ND var 0 ]) let bind_type (u1 u2:R.universe) = let var = 4 in let t1 = mk_name var in let t1_type = RT.tm_type u1 in mk_arrow (t1_type, R.Q_Implicit) (RT.subst_term (bind_type_t1 u1 u2 t1) [ RT.ND var 0 ]) (** Type of frame **) let mk_star (l r:R.term) = let open R in let head = pack_ln (Tv_FVar (pack_fv star_lid)) in R.mk_app head [(l, Q_Explicit); (r, Q_Explicit)] let frame_res (u:R.universe) (t pre post frame:R.term) = mk_stt_comp u t (mk_star pre frame) (mk_abs t R.Q_Explicit (mk_star (R.mk_app post [bound_var 0, R.Q_Explicit]) frame)) let frame_type_t_pre_post_frame (u:R.universe) (t pre post frame:R.term) = let open R in let f_type = mk_stt_comp u t pre post in mk_arrow (f_type, Q_Explicit) (frame_res u t pre post frame) let frame_type_t_pre_post (u:R.universe) (t pre post:R.term) = let var = 0 in let frame = mk_name var in mk_arrow (vprop_tm, R.Q_Explicit) (RT.close_term (frame_res u t pre post frame) var) let frame_type_t_pre (u:R.universe) (t pre:R.term) = let var = 1 in let post = mk_name var in let post_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre_post u t pre post) var) let frame_type_t (u:R.universe) (t:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre u t pre) var) let frame_type (u:R.universe) = let var = 3 in let t = mk_name var in let t_type = RT.tm_type u in mk_arrow (t_type, R.Q_Implicit) (RT.close_term (frame_type_t u t) var) (** Type of sub_stt **) let stt_vprop_post_equiv_fv = R.pack_fv (mk_pulse_lib_core_lid "vprop_post_equiv") let stt_vprop_post_equiv_univ_inst u = R.pack_ln (R.Tv_UInst stt_vprop_post_equiv_fv [u]) let stt_vprop_post_equiv (u:R.universe) (t t1 t2:R.term) = R.mk_app (stt_vprop_post_equiv_univ_inst u) [(t, R.Q_Implicit); (t1, R.Q_Explicit); (t2, R.Q_Explicit)] let sub_stt_res u t pre post = mk_stt_comp u t pre post let sub_stt_equiv_post u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_post_equiv u t post1 post2, R.Q_Explicit) (sub_stt_res u t pre2 post2) let sub_stt_equiv_pre u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_equiv pre1 pre2, R.Q_Explicit) (sub_stt_equiv_post u t pre1 pre2 post1 post2) let sub_stt_post2 u t pre1 post1 pre2 = let var = 0 in let post2 = mk_name var in let post2_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post2_type, R.Q_Explicit) (RT.close_term (sub_stt_equiv_pre u t pre1 pre2 post1 post2) var) let sub_stt_pre2 u t pre1 post1 = let var = 1 in let pre2 = mk_name var in let pre2_type = vprop_tm in mk_arrow (pre2_type, R.Q_Explicit) (RT.close_term (sub_stt_post2 u t pre1 post1 pre2) var) let sub_stt_post1 u t pre1 = let var = 2 in let post1 = mk_name var in let post1_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post1_type, R.Q_Explicit) (RT.close_term (sub_stt_pre2 u t pre1 post1) var) let sub_stt_pre1 u t = let var = 3 in let pre1 = mk_name var in let pre1_type = vprop_tm in mk_arrow (pre1_type, R.Q_Explicit) (RT.close_term (sub_stt_post1 u t pre1) var) let sub_stt_type u = let var = 4 in let t = mk_name var in let ty_typ = RT.tm_type u in mk_arrow (ty_typ, R.Q_Explicit) (RT.close_term (sub_stt_pre1 u t) var) (** Properties of environments suitable for elaboration **) let has_stt_bindings (f:RT.fstar_top_env) = RT.lookup_fvar f RT.bool_fv == Some (RT.tm_type RT.u_zero) /\ RT.lookup_fvar f vprop_fv == Some (RT.tm_type u2) /\ True //(forall (u1 u2:R.universe). RT.lookup_fvar_uinst f bind_fv [u1; u2] == Some (bind_type u1 u2)) /\ //(forall (u:R.universe). RT.lookup_fvar_uinst f frame_fv [u] == Some (frame_type u)) /\ //(forall (u:R.universe). RT.lookup_fvar_uinst f subsumption_fv [u] == Some (sub_stt_type u))
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Pulse.Typing.Env.env", "Pulse.Soundness.Common.has_stt_bindings", "Pulse.Typing.Env.fstar_env" ]
[]
false
false
false
true
true
let stt_env =
e: env{has_stt_bindings (fstar_env e)}
false
FStar.BitVector.fst
FStar.BitVector.zero_vec
val zero_vec (#n: pos) : Tot (bv_t n)
val zero_vec (#n: pos) : Tot (bv_t n)
let zero_vec (#n: pos) : Tot (bv_t n) = create n false
{ "file_name": "ulib/FStar.BitVector.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 54, "end_line": 36, "start_col": 0, "start_line": 36 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.BitVector /// This module defines a bit vector as a sequence of booleans of a /// given length, and provides various utilities. /// /// NOTE: THE TYPE [bv_t] DEFINED IS UNRELATED TO THE SMT SOLVER'S /// THEORY OF BIT VECTORS. SEE [FStar.BV] FOR THAT. /// /// TODO: We might rename this module to FStar.Seq.Boolean? open FStar.Mul open FStar.Seq (** [bv_t n] is just a sequence of booleans of length [n] *) type bv_t (n: nat) = vec: seq bool {length vec = n} (**** Common constants *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.BitVector.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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
FStar.BitVector.bv_t n
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "FStar.Seq.Base.create", "Prims.bool", "FStar.BitVector.bv_t" ]
[]
false
false
false
false
false
let zero_vec (#n: pos) : Tot (bv_t n) =
create n false
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.soundness_t
val soundness_t : d: 'a -> Type0
let soundness_t (d:'a) = g:stt_env -> t:st_term -> c:comp -> d':st_typing g t c{d' << d} -> GTot (RT.tot_typing (elab_env g) (elab_st_typing d') (elab_comp c))
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 38, "end_line": 384, "start_col": 0, "start_line": 377 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ]) let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ]) let bind_type_t1 (u1 u2:R.universe) (t1:R.term) = let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [ RT.ND var 0 ]) let bind_type (u1 u2:R.universe) = let var = 4 in let t1 = mk_name var in let t1_type = RT.tm_type u1 in mk_arrow (t1_type, R.Q_Implicit) (RT.subst_term (bind_type_t1 u1 u2 t1) [ RT.ND var 0 ]) (** Type of frame **) let mk_star (l r:R.term) = let open R in let head = pack_ln (Tv_FVar (pack_fv star_lid)) in R.mk_app head [(l, Q_Explicit); (r, Q_Explicit)] let frame_res (u:R.universe) (t pre post frame:R.term) = mk_stt_comp u t (mk_star pre frame) (mk_abs t R.Q_Explicit (mk_star (R.mk_app post [bound_var 0, R.Q_Explicit]) frame)) let frame_type_t_pre_post_frame (u:R.universe) (t pre post frame:R.term) = let open R in let f_type = mk_stt_comp u t pre post in mk_arrow (f_type, Q_Explicit) (frame_res u t pre post frame) let frame_type_t_pre_post (u:R.universe) (t pre post:R.term) = let var = 0 in let frame = mk_name var in mk_arrow (vprop_tm, R.Q_Explicit) (RT.close_term (frame_res u t pre post frame) var) let frame_type_t_pre (u:R.universe) (t pre:R.term) = let var = 1 in let post = mk_name var in let post_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre_post u t pre post) var) let frame_type_t (u:R.universe) (t:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre u t pre) var) let frame_type (u:R.universe) = let var = 3 in let t = mk_name var in let t_type = RT.tm_type u in mk_arrow (t_type, R.Q_Implicit) (RT.close_term (frame_type_t u t) var) (** Type of sub_stt **) let stt_vprop_post_equiv_fv = R.pack_fv (mk_pulse_lib_core_lid "vprop_post_equiv") let stt_vprop_post_equiv_univ_inst u = R.pack_ln (R.Tv_UInst stt_vprop_post_equiv_fv [u]) let stt_vprop_post_equiv (u:R.universe) (t t1 t2:R.term) = R.mk_app (stt_vprop_post_equiv_univ_inst u) [(t, R.Q_Implicit); (t1, R.Q_Explicit); (t2, R.Q_Explicit)] let sub_stt_res u t pre post = mk_stt_comp u t pre post let sub_stt_equiv_post u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_post_equiv u t post1 post2, R.Q_Explicit) (sub_stt_res u t pre2 post2) let sub_stt_equiv_pre u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_equiv pre1 pre2, R.Q_Explicit) (sub_stt_equiv_post u t pre1 pre2 post1 post2) let sub_stt_post2 u t pre1 post1 pre2 = let var = 0 in let post2 = mk_name var in let post2_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post2_type, R.Q_Explicit) (RT.close_term (sub_stt_equiv_pre u t pre1 pre2 post1 post2) var) let sub_stt_pre2 u t pre1 post1 = let var = 1 in let pre2 = mk_name var in let pre2_type = vprop_tm in mk_arrow (pre2_type, R.Q_Explicit) (RT.close_term (sub_stt_post2 u t pre1 post1 pre2) var) let sub_stt_post1 u t pre1 = let var = 2 in let post1 = mk_name var in let post1_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post1_type, R.Q_Explicit) (RT.close_term (sub_stt_pre2 u t pre1 post1) var) let sub_stt_pre1 u t = let var = 3 in let pre1 = mk_name var in let pre1_type = vprop_tm in mk_arrow (pre1_type, R.Q_Explicit) (RT.close_term (sub_stt_post1 u t pre1) var) let sub_stt_type u = let var = 4 in let t = mk_name var in let ty_typ = RT.tm_type u in mk_arrow (ty_typ, R.Q_Explicit) (RT.close_term (sub_stt_pre1 u t) var) (** Properties of environments suitable for elaboration **) let has_stt_bindings (f:RT.fstar_top_env) = RT.lookup_fvar f RT.bool_fv == Some (RT.tm_type RT.u_zero) /\ RT.lookup_fvar f vprop_fv == Some (RT.tm_type u2) /\ True //(forall (u1 u2:R.universe). RT.lookup_fvar_uinst f bind_fv [u1; u2] == Some (bind_type u1 u2)) /\ //(forall (u:R.universe). RT.lookup_fvar_uinst f frame_fv [u] == Some (frame_type u)) /\ //(forall (u:R.universe). RT.lookup_fvar_uinst f subsumption_fv [u] == Some (sub_stt_type u)) let stt_env = e:env { has_stt_bindings (fstar_env e) } let check_top_level_environment (f:RT.fstar_top_env) : option stt_env = admit(); Some (mk_env f) //we should implement this as a runtime check let elab_comp_post (c:comp_st) : R.term = let t = elab_term (comp_res c) in let post = elab_term (comp_post c) in mk_abs t R.Q_Explicit post let comp_post_type (c:comp_st) : R.term = let t = elab_term (comp_res c) in mk_arrow (t, R.Q_Explicit) vprop_tm assume val inversion_of_stt_typing (g:env) (c:comp_st) (#u:R.universe) // _ |- stt u#u t pre (fun (x:t) -> post) : Type _ (_:RT.tot_typing (elab_env g) (elab_comp c) (RT.tm_type u)) : GTot (x:( // _ |- t : Type u#u RT.tot_typing (elab_env g) (elab_term (comp_res c)) (RT.tm_type (comp_u c)) & // _ |- pre : vprop RT.tot_typing (elab_env g) (elab_term (comp_pre c)) (elab_term (tm_vprop)) & // _ |- (fun (x:t) -> post) : t -> vprop RT.tot_typing (elab_env g) (elab_comp_post c) (elab_term (tm_arrow (null_binder (comp_res c)) None (C_Tot tm_vprop)))){ u == universe_of_comp c })
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
d: 'a -> Type0
Prims.Tot
[ "total" ]
[]
[ "Pulse.Soundness.Common.stt_env", "Pulse.Syntax.Base.st_term", "Pulse.Syntax.Base.comp", "Pulse.Typing.st_typing", "Prims.precedes", "FStar.Reflection.Typing.tot_typing", "Pulse.Typing.elab_env", "Pulse.Elaborate.Core.elab_st_typing", "Pulse.Elaborate.Pure.elab_comp" ]
[]
false
false
false
true
true
let soundness_t (d: 'a) =
g: stt_env -> t: st_term -> c: comp -> d': st_typing g t c {d' << d} -> GTot (RT.tot_typing (elab_env g) (elab_st_typing d') (elab_comp c))
false
FStar.BitVector.fst
FStar.BitVector.logand_vec
val logand_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n)
val logand_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n)
let rec logand_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 && index b 0) else append (create 1 (index a 0 && index b 0)) (logand_vec #(n - 1) (slice a 1 n) (slice b 1 n))
{ "file_name": "ulib/FStar.BitVector.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 99, "end_line": 48, "start_col": 0, "start_line": 45 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 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.BitVector /// This module defines a bit vector as a sequence of booleans of a /// given length, and provides various utilities. /// /// NOTE: THE TYPE [bv_t] DEFINED IS UNRELATED TO THE SMT SOLVER'S /// THEORY OF BIT VECTORS. SEE [FStar.BV] FOR THAT. /// /// TODO: We might rename this module to FStar.Seq.Boolean? open FStar.Mul open FStar.Seq (** [bv_t n] is just a sequence of booleans of length [n] *) type bv_t (n: nat) = vec: seq bool {length vec = n} (**** Common constants *) (** A length [n] zero vector *) let zero_vec (#n: pos) : Tot (bv_t n) = create n false (** A vector of length [n] whose [i]th bit is set, only *) let elem_vec (#n: pos) (i: nat{i < n}) : Tot (bv_t n) = upd (create n false) i true (** A length [n] vector all of whose bits are set *) let ones_vec (#n: pos) : Tot (bv_t n) = create n true
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.BitVector.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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
a: FStar.BitVector.bv_t n -> b: FStar.BitVector.bv_t n -> FStar.BitVector.bv_t n
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "FStar.BitVector.bv_t", "Prims.op_Equality", "Prims.int", "FStar.Seq.Base.create", "Prims.bool", "Prims.op_AmpAmp", "FStar.Seq.Base.index", "FStar.Seq.Base.append", "FStar.BitVector.logand_vec", "Prims.op_Subtraction", "FStar.Seq.Base.slice" ]
[ "recursion" ]
false
false
false
false
false
let rec logand_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) =
if n = 1 then create 1 (index a 0 && index b 0) else append (create 1 (index a 0 && index b 0)) (logand_vec #(n - 1) (slice a 1 n) (slice b 1 n))
false
FStar.BitVector.fst
FStar.BitVector.elem_vec
val elem_vec (#n: pos) (i: nat{i < n}) : Tot (bv_t n)
val elem_vec (#n: pos) (i: nat{i < n}) : Tot (bv_t n)
let elem_vec (#n: pos) (i: nat{i < n}) : Tot (bv_t n) = upd (create n false) i true
{ "file_name": "ulib/FStar.BitVector.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 83, "end_line": 39, "start_col": 0, "start_line": 39 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.BitVector /// This module defines a bit vector as a sequence of booleans of a /// given length, and provides various utilities. /// /// NOTE: THE TYPE [bv_t] DEFINED IS UNRELATED TO THE SMT SOLVER'S /// THEORY OF BIT VECTORS. SEE [FStar.BV] FOR THAT. /// /// TODO: We might rename this module to FStar.Seq.Boolean? open FStar.Mul open FStar.Seq (** [bv_t n] is just a sequence of booleans of length [n] *) type bv_t (n: nat) = vec: seq bool {length vec = n} (**** Common constants *) (** A length [n] zero vector *) let zero_vec (#n: pos) : Tot (bv_t n) = create n false
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.BitVector.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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
i: Prims.nat{i < n} -> FStar.BitVector.bv_t n
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.upd", "Prims.bool", "FStar.Seq.Base.create", "FStar.BitVector.bv_t" ]
[]
false
false
false
false
false
let elem_vec (#n: pos) (i: nat{i < n}) : Tot (bv_t n) =
upd (create n false) i true
false
FStar.BitVector.fst
FStar.BitVector.ones_vec
val ones_vec (#n: pos) : Tot (bv_t n)
val ones_vec (#n: pos) : Tot (bv_t n)
let ones_vec (#n: pos) : Tot (bv_t n) = create n true
{ "file_name": "ulib/FStar.BitVector.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 53, "end_line": 42, "start_col": 0, "start_line": 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 FStar.BitVector /// This module defines a bit vector as a sequence of booleans of a /// given length, and provides various utilities. /// /// NOTE: THE TYPE [bv_t] DEFINED IS UNRELATED TO THE SMT SOLVER'S /// THEORY OF BIT VECTORS. SEE [FStar.BV] FOR THAT. /// /// TODO: We might rename this module to FStar.Seq.Boolean? open FStar.Mul open FStar.Seq (** [bv_t n] is just a sequence of booleans of length [n] *) type bv_t (n: nat) = vec: seq bool {length vec = n} (**** Common constants *) (** A length [n] zero vector *) let zero_vec (#n: pos) : Tot (bv_t n) = create n false (** A vector of length [n] whose [i]th bit is set, only *) let elem_vec (#n: pos) (i: nat{i < n}) : Tot (bv_t n) = upd (create n false) i true
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.BitVector.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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
FStar.BitVector.bv_t n
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "FStar.Seq.Base.create", "Prims.bool", "FStar.BitVector.bv_t" ]
[]
false
false
false
false
false
let ones_vec (#n: pos) : Tot (bv_t n) =
create n true
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.elab_open_commute'
val elab_open_commute' (e v: term) (n: index) : Lemma (ensures RT.subst_term (elab_term e) [RT.DT n (elab_term v)] == elab_term (open_term' e v n)) [SMTPat (elab_term (open_term' e v n))]
val elab_open_commute' (e v: term) (n: index) : Lemma (ensures RT.subst_term (elab_term e) [RT.DT n (elab_term v)] == elab_term (open_term' e v n)) [SMTPat (elab_term (open_term' e v n))]
let elab_open_commute' (e:term) (v:term) (n:index) : Lemma (ensures RT.subst_term (elab_term e) [ RT.DT n (elab_term v)] == elab_term (open_term' e v n)) [SMTPat (elab_term (open_term' e v n))] = elab_open_commute' e v n
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 26, "end_line": 393, "start_col": 0, "start_line": 386 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ]) let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ]) let bind_type_t1 (u1 u2:R.universe) (t1:R.term) = let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [ RT.ND var 0 ]) let bind_type (u1 u2:R.universe) = let var = 4 in let t1 = mk_name var in let t1_type = RT.tm_type u1 in mk_arrow (t1_type, R.Q_Implicit) (RT.subst_term (bind_type_t1 u1 u2 t1) [ RT.ND var 0 ]) (** Type of frame **) let mk_star (l r:R.term) = let open R in let head = pack_ln (Tv_FVar (pack_fv star_lid)) in R.mk_app head [(l, Q_Explicit); (r, Q_Explicit)] let frame_res (u:R.universe) (t pre post frame:R.term) = mk_stt_comp u t (mk_star pre frame) (mk_abs t R.Q_Explicit (mk_star (R.mk_app post [bound_var 0, R.Q_Explicit]) frame)) let frame_type_t_pre_post_frame (u:R.universe) (t pre post frame:R.term) = let open R in let f_type = mk_stt_comp u t pre post in mk_arrow (f_type, Q_Explicit) (frame_res u t pre post frame) let frame_type_t_pre_post (u:R.universe) (t pre post:R.term) = let var = 0 in let frame = mk_name var in mk_arrow (vprop_tm, R.Q_Explicit) (RT.close_term (frame_res u t pre post frame) var) let frame_type_t_pre (u:R.universe) (t pre:R.term) = let var = 1 in let post = mk_name var in let post_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre_post u t pre post) var) let frame_type_t (u:R.universe) (t:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre u t pre) var) let frame_type (u:R.universe) = let var = 3 in let t = mk_name var in let t_type = RT.tm_type u in mk_arrow (t_type, R.Q_Implicit) (RT.close_term (frame_type_t u t) var) (** Type of sub_stt **) let stt_vprop_post_equiv_fv = R.pack_fv (mk_pulse_lib_core_lid "vprop_post_equiv") let stt_vprop_post_equiv_univ_inst u = R.pack_ln (R.Tv_UInst stt_vprop_post_equiv_fv [u]) let stt_vprop_post_equiv (u:R.universe) (t t1 t2:R.term) = R.mk_app (stt_vprop_post_equiv_univ_inst u) [(t, R.Q_Implicit); (t1, R.Q_Explicit); (t2, R.Q_Explicit)] let sub_stt_res u t pre post = mk_stt_comp u t pre post let sub_stt_equiv_post u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_post_equiv u t post1 post2, R.Q_Explicit) (sub_stt_res u t pre2 post2) let sub_stt_equiv_pre u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_equiv pre1 pre2, R.Q_Explicit) (sub_stt_equiv_post u t pre1 pre2 post1 post2) let sub_stt_post2 u t pre1 post1 pre2 = let var = 0 in let post2 = mk_name var in let post2_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post2_type, R.Q_Explicit) (RT.close_term (sub_stt_equiv_pre u t pre1 pre2 post1 post2) var) let sub_stt_pre2 u t pre1 post1 = let var = 1 in let pre2 = mk_name var in let pre2_type = vprop_tm in mk_arrow (pre2_type, R.Q_Explicit) (RT.close_term (sub_stt_post2 u t pre1 post1 pre2) var) let sub_stt_post1 u t pre1 = let var = 2 in let post1 = mk_name var in let post1_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post1_type, R.Q_Explicit) (RT.close_term (sub_stt_pre2 u t pre1 post1) var) let sub_stt_pre1 u t = let var = 3 in let pre1 = mk_name var in let pre1_type = vprop_tm in mk_arrow (pre1_type, R.Q_Explicit) (RT.close_term (sub_stt_post1 u t pre1) var) let sub_stt_type u = let var = 4 in let t = mk_name var in let ty_typ = RT.tm_type u in mk_arrow (ty_typ, R.Q_Explicit) (RT.close_term (sub_stt_pre1 u t) var) (** Properties of environments suitable for elaboration **) let has_stt_bindings (f:RT.fstar_top_env) = RT.lookup_fvar f RT.bool_fv == Some (RT.tm_type RT.u_zero) /\ RT.lookup_fvar f vprop_fv == Some (RT.tm_type u2) /\ True //(forall (u1 u2:R.universe). RT.lookup_fvar_uinst f bind_fv [u1; u2] == Some (bind_type u1 u2)) /\ //(forall (u:R.universe). RT.lookup_fvar_uinst f frame_fv [u] == Some (frame_type u)) /\ //(forall (u:R.universe). RT.lookup_fvar_uinst f subsumption_fv [u] == Some (sub_stt_type u)) let stt_env = e:env { has_stt_bindings (fstar_env e) } let check_top_level_environment (f:RT.fstar_top_env) : option stt_env = admit(); Some (mk_env f) //we should implement this as a runtime check let elab_comp_post (c:comp_st) : R.term = let t = elab_term (comp_res c) in let post = elab_term (comp_post c) in mk_abs t R.Q_Explicit post let comp_post_type (c:comp_st) : R.term = let t = elab_term (comp_res c) in mk_arrow (t, R.Q_Explicit) vprop_tm assume val inversion_of_stt_typing (g:env) (c:comp_st) (#u:R.universe) // _ |- stt u#u t pre (fun (x:t) -> post) : Type _ (_:RT.tot_typing (elab_env g) (elab_comp c) (RT.tm_type u)) : GTot (x:( // _ |- t : Type u#u RT.tot_typing (elab_env g) (elab_term (comp_res c)) (RT.tm_type (comp_u c)) & // _ |- pre : vprop RT.tot_typing (elab_env g) (elab_term (comp_pre c)) (elab_term (tm_vprop)) & // _ |- (fun (x:t) -> post) : t -> vprop RT.tot_typing (elab_env g) (elab_comp_post c) (elab_term (tm_arrow (null_binder (comp_res c)) None (C_Tot tm_vprop)))){ u == universe_of_comp c }) let soundness_t (d:'a) = g:stt_env -> t:st_term -> c:comp -> d':st_typing g t c{d' << d} -> GTot (RT.tot_typing (elab_env g) (elab_st_typing d') (elab_comp c))
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
e: Pulse.Syntax.Base.term -> v: Pulse.Syntax.Base.term -> n: Pulse.Syntax.Base.index -> FStar.Pervasives.Lemma (ensures FStar.Reflection.Typing.subst_term (Pulse.Elaborate.Pure.elab_term e) [FStar.Reflection.Typing.DT n (Pulse.Elaborate.Pure.elab_term v)] == Pulse.Elaborate.Pure.elab_term (Pulse.Syntax.Naming.open_term' e v n)) [SMTPat (Pulse.Elaborate.Pure.elab_term (Pulse.Syntax.Naming.open_term' e v n))]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.index", "Pulse.Elaborate.elab_open_commute'", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.Typing.subst_term", "Pulse.Elaborate.Pure.elab_term", "Prims.Cons", "FStar.Reflection.Typing.subst_elt", "FStar.Reflection.Typing.DT", "Prims.Nil", "Pulse.Syntax.Naming.open_term'", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat" ]
[]
true
false
true
false
false
let elab_open_commute' (e v: term) (n: index) : Lemma (ensures RT.subst_term (elab_term e) [RT.DT n (elab_term v)] == elab_term (open_term' e v n)) [SMTPat (elab_term (open_term' e v n))] =
elab_open_commute' e v n
false
Spec.SHA3.Equivalence.fst
Spec.SHA3.Equivalence.state_chi_inner
val state_chi_inner (y: index) (s: state) : Tot state
val state_chi_inner (y: index) (s: state) : Tot state
let state_chi_inner (y:index) (s:state) : Tot state = let v0 = get s 0 y ^. ((lognot (get s 1 y)) &. get s 2 y) in let v1 = get s 1 y ^. ((lognot (get s 2 y)) &. get s 3 y) in let v2 = get s 2 y ^. ((lognot (get s 3 y)) &. get s 4 y) in let v3 = get s 3 y ^. ((lognot (get s 4 y)) &. get s 0 y) in let v4 = get s 4 y ^. ((lognot (get s 0 y)) &. get s 1 y) in let s = set s 0 y v0 in let s = set s 1 y v1 in let s = set s 2 y v2 in let s = set s 3 y v3 in let s = set s 4 y v4 in s
{ "file_name": "specs/lemmas/Spec.SHA3.Equivalence.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 25, "start_col": 0, "start_line": 14 }
module Spec.SHA3.Equivalence open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open FStar.Mul open Lib.LoopCombinators open Spec.SHA3.Constants open Spec.SHA3 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.Constants.fst.checked", "Spec.SHA3.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.SHA3.Equivalence.fst" }
[ { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA3.Constants", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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
y: Spec.SHA3.index -> s: Spec.SHA3.state -> Spec.SHA3.state
Prims.Tot
[ "total" ]
[]
[ "Spec.SHA3.index", "Spec.SHA3.state", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Spec.SHA3.set", "Lib.IntTypes.op_Hat_Dot", "Spec.SHA3.get", "Lib.IntTypes.op_Amp_Dot", "Lib.IntTypes.lognot" ]
[]
false
false
false
true
false
let state_chi_inner (y: index) (s: state) : Tot state =
let v0 = get s 0 y ^. ((lognot (get s 1 y)) &. get s 2 y) in let v1 = get s 1 y ^. ((lognot (get s 2 y)) &. get s 3 y) in let v2 = get s 2 y ^. ((lognot (get s 3 y)) &. get s 4 y) in let v3 = get s 3 y ^. ((lognot (get s 4 y)) &. get s 0 y) in let v4 = get s 4 y ^. ((lognot (get s 0 y)) &. get s 1 y) in let s = set s 0 y v0 in let s = set s 1 y v1 in let s = set s 2 y v2 in let s = set s 3 y v3 in let s = set s 4 y v4 in s
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.elab_comp_close_commute
val elab_comp_close_commute (c: comp) (x: var) : Lemma (ensures elab_comp (close_comp c x) == RT.close_term (elab_comp c) x) [SMTPat (elab_comp (close_comp c x))]
val elab_comp_close_commute (c: comp) (x: var) : Lemma (ensures elab_comp (close_comp c x) == RT.close_term (elab_comp c) x) [SMTPat (elab_comp (close_comp c x))]
let elab_comp_close_commute (c:comp) (x:var) : Lemma (ensures elab_comp (close_comp c x) == RT.close_term (elab_comp c) x) [SMTPat (elab_comp (close_comp c x))] = elab_comp_close_commute c x
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 29, "end_line": 406, "start_col": 0, "start_line": 402 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c } let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us let elab_term_opt (b:option term) = match b with | Some b -> Some (elab_term b) | None -> None // let rec extend_env_l_lookup_bvar (g:R.env) (sg:env_bindings) (x:var) // : Lemma // (requires (forall x. RT.lookup_bvar g x == None)) // (ensures (RT.lookup_bvar (extend_env_l g sg) x == elab_term_opt (lookup sg x))) // (decreases sg) // [SMTPat (RT.lookup_bvar (extend_env_l g sg) x)] // = match sg with // | [] -> () // | hd :: tl -> extend_env_l_lookup_bvar g tl x let lookup_elab_env (g:env) (x:var) : Lemma (ensures (RT.lookup_bvar (elab_env g) x == elab_term_opt (lookup g x))) [SMTPat (RT.lookup_bvar (elab_env g) x)] = admit () // TODO: FIX ME!!!! let tot_typing_soundness (#g:env) (#e:term) (#t:term) (d:tot_typing g e t) : GTot (RT.tot_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d let ghost_typing_soundness (#g:env) (#e:term) (#t:term) (d:ghost_typing g e t) : GTot (RT.ghost_typing (elab_env g) (elab_term e) (elab_term t)) = let E d = d in d #push-options "--z3rlimit_factor 4" let mk_t_abs_tot (g:env) (#u:universe) (#q:option qualifier) (#ty:term) (ppname:ppname) (t_typing:tot_typing g ty (tm_type u)) (#body:term) (#body_ty:term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars body) }) (body_typing:tot_typing (push_binding g x ppname ty) (open_term body x) body_ty) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (elab_term body)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x)))) = let c = C_Tot body_ty in let r_ty = elab_term ty in let r_body = elab_term (open_term body x) in let r_c = elab_comp c in let r_t_typing = tot_typing_soundness t_typing in let r_body_typing = tot_typing_soundness body_typing in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; elab_freevars body; assert (~ (x `Set.mem` RT.freevars (elab_term body))); assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; assert (elab_term (tm_type u) == RT.tm_type u); let r_t_typing : RT.tot_typing (elab_env g) r_ty (RT.tm_type u) = coerce_eq () r_t_typing //strange that this coercion is needed in let d : RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_term (open_term body x)) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp (C_Tot body_ty) x))) = RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing in elab_open_commute' body (null_var x) 0; RT.open_term_spec (elab_term body) x; assert (elab_term (open_term body x) == RT.open_term (elab_term body) x); let d : RT.typing _ (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (RT.open_term (elab_term body) x) x)) _ = d in RT.close_open_inverse (elab_term body) x; d let mk_t_abs (g:env) (#u:universe) (#ty:term) (#q:option qualifier) (#t_typing:typing g ty T.E_Total (tm_type u)) (ppname:ppname) (r_t_typing:RT.tot_typing (elab_env g) (elab_term ty) (elab_comp (C_Tot (tm_type u)))) (#body:st_term) (#x:var { None? (lookup g x) /\ ~(x `Set.mem` freevars_st body) }) (#c:comp) (#body_typing:st_typing (push_binding g x ppname ty) (open_st_term body x) c) (r_body_typing:RT.tot_typing (elab_env (push_binding g x ppname ty)) (elab_st_typing body_typing) (elab_comp c)) : GTot (RT.tot_typing (elab_env g) (mk_abs_with_name ppname.name (elab_term ty) (elab_qual q) (RT.close_term (elab_st_typing body_typing) x)) (elab_term (tm_arrow (mk_binder_ppname ty ppname) q (close_comp c x)))) = let r_ty = elab_term ty in let r_body = elab_st_typing body_typing in let r_c = elab_comp c in RT.well_typed_terms_are_ln _ _ _ r_body_typing; RT.open_close_inverse r_body x; elab_comp_close_commute c x; assume (~ (x `Set.mem` RT.freevars (RT.close_term r_body x))); RT.close_term_spec (elab_comp c) x; RT.T_Abs (elab_env g) x r_ty (RT.close_term r_body x) (T.E_Total, r_c) u ppname.name (elab_qual q) _ r_t_typing r_body_typing (*** Typing of combinators used in the elaboration **) (** Type of bind **) let bind_res (u2:R.universe) (t2 pre post2:R.term) = mk_stt_comp u2 t2 pre post2 let g_type_bind (u2:R.universe) (t1 t2 post1 post2:R.term) = mk_arrow (t1, R.Q_Explicit) (bind_res u2 t2 (R.mk_app post1 [bound_var 0 (* x *), R.Q_Explicit]) post2) let bind_type_t1_t2_pre_post1_post2_f (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = mk_arrow (g_type_bind u2 t1 t2 post1 post2, R.Q_Explicit) (bind_res u2 t2 pre post2) let bind_type_t1_t2_pre_post1_post2 (u1 u2:R.universe) (t1 t2 pre post1 post2:R.term) = let f_type = mk_stt_comp u1 t1 pre post1 in mk_arrow (f_type, R.Q_Explicit) (bind_type_t1_t2_pre_post1_post2_f u1 u2 t1 t2 pre post1 post2) let post2_type_bind t2 = mk_arrow (t2, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre_post1 (u1 u2:R.universe) (t1 t2 pre post1:R.term) = let var = 0 in let post2 = mk_name var in mk_arrow (post2_type_bind t2, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1_post2 u1 u2 t1 t2 pre post1 post2) [ RT.ND var 0 ]) let post1_type_bind t1 = mk_arrow (t1, R.Q_Explicit) vprop_tm let bind_type_t1_t2_pre (u1 u2:R.universe) (t1 t2 pre:R.term) = let var = 1 in let post1 = mk_name var in mk_arrow (post1_type_bind t1, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre_post1 u1 u2 t1 t2 pre post1) [ RT.ND var 0 ]) let bind_type_t1_t2 (u1 u2:R.universe) (t1 t2:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2_pre u1 u2 t1 t2 pre) [ RT.ND var 0 ]) let bind_type_t1 (u1 u2:R.universe) (t1:R.term) = let var = 3 in let t2 = mk_name var in let t2_type = RT.tm_type u2 in mk_arrow (t2_type, R.Q_Implicit) (RT.subst_term (bind_type_t1_t2 u1 u2 t1 t2) [ RT.ND var 0 ]) let bind_type (u1 u2:R.universe) = let var = 4 in let t1 = mk_name var in let t1_type = RT.tm_type u1 in mk_arrow (t1_type, R.Q_Implicit) (RT.subst_term (bind_type_t1 u1 u2 t1) [ RT.ND var 0 ]) (** Type of frame **) let mk_star (l r:R.term) = let open R in let head = pack_ln (Tv_FVar (pack_fv star_lid)) in R.mk_app head [(l, Q_Explicit); (r, Q_Explicit)] let frame_res (u:R.universe) (t pre post frame:R.term) = mk_stt_comp u t (mk_star pre frame) (mk_abs t R.Q_Explicit (mk_star (R.mk_app post [bound_var 0, R.Q_Explicit]) frame)) let frame_type_t_pre_post_frame (u:R.universe) (t pre post frame:R.term) = let open R in let f_type = mk_stt_comp u t pre post in mk_arrow (f_type, Q_Explicit) (frame_res u t pre post frame) let frame_type_t_pre_post (u:R.universe) (t pre post:R.term) = let var = 0 in let frame = mk_name var in mk_arrow (vprop_tm, R.Q_Explicit) (RT.close_term (frame_res u t pre post frame) var) let frame_type_t_pre (u:R.universe) (t pre:R.term) = let var = 1 in let post = mk_name var in let post_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre_post u t pre post) var) let frame_type_t (u:R.universe) (t:R.term) = let var = 2 in let pre = mk_name var in let pre_type = vprop_tm in mk_arrow (pre_type, R.Q_Implicit) (RT.close_term (frame_type_t_pre u t pre) var) let frame_type (u:R.universe) = let var = 3 in let t = mk_name var in let t_type = RT.tm_type u in mk_arrow (t_type, R.Q_Implicit) (RT.close_term (frame_type_t u t) var) (** Type of sub_stt **) let stt_vprop_post_equiv_fv = R.pack_fv (mk_pulse_lib_core_lid "vprop_post_equiv") let stt_vprop_post_equiv_univ_inst u = R.pack_ln (R.Tv_UInst stt_vprop_post_equiv_fv [u]) let stt_vprop_post_equiv (u:R.universe) (t t1 t2:R.term) = R.mk_app (stt_vprop_post_equiv_univ_inst u) [(t, R.Q_Implicit); (t1, R.Q_Explicit); (t2, R.Q_Explicit)] let sub_stt_res u t pre post = mk_stt_comp u t pre post let sub_stt_equiv_post u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_post_equiv u t post1 post2, R.Q_Explicit) (sub_stt_res u t pre2 post2) let sub_stt_equiv_pre u t pre1 post1 pre2 post2 = mk_arrow (stt_vprop_equiv pre1 pre2, R.Q_Explicit) (sub_stt_equiv_post u t pre1 pre2 post1 post2) let sub_stt_post2 u t pre1 post1 pre2 = let var = 0 in let post2 = mk_name var in let post2_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post2_type, R.Q_Explicit) (RT.close_term (sub_stt_equiv_pre u t pre1 pre2 post1 post2) var) let sub_stt_pre2 u t pre1 post1 = let var = 1 in let pre2 = mk_name var in let pre2_type = vprop_tm in mk_arrow (pre2_type, R.Q_Explicit) (RT.close_term (sub_stt_post2 u t pre1 post1 pre2) var) let sub_stt_post1 u t pre1 = let var = 2 in let post1 = mk_name var in let post1_type = mk_arrow (t, R.Q_Explicit) vprop_tm in mk_arrow (post1_type, R.Q_Explicit) (RT.close_term (sub_stt_pre2 u t pre1 post1) var) let sub_stt_pre1 u t = let var = 3 in let pre1 = mk_name var in let pre1_type = vprop_tm in mk_arrow (pre1_type, R.Q_Explicit) (RT.close_term (sub_stt_post1 u t pre1) var) let sub_stt_type u = let var = 4 in let t = mk_name var in let ty_typ = RT.tm_type u in mk_arrow (ty_typ, R.Q_Explicit) (RT.close_term (sub_stt_pre1 u t) var) (** Properties of environments suitable for elaboration **) let has_stt_bindings (f:RT.fstar_top_env) = RT.lookup_fvar f RT.bool_fv == Some (RT.tm_type RT.u_zero) /\ RT.lookup_fvar f vprop_fv == Some (RT.tm_type u2) /\ True //(forall (u1 u2:R.universe). RT.lookup_fvar_uinst f bind_fv [u1; u2] == Some (bind_type u1 u2)) /\ //(forall (u:R.universe). RT.lookup_fvar_uinst f frame_fv [u] == Some (frame_type u)) /\ //(forall (u:R.universe). RT.lookup_fvar_uinst f subsumption_fv [u] == Some (sub_stt_type u)) let stt_env = e:env { has_stt_bindings (fstar_env e) } let check_top_level_environment (f:RT.fstar_top_env) : option stt_env = admit(); Some (mk_env f) //we should implement this as a runtime check let elab_comp_post (c:comp_st) : R.term = let t = elab_term (comp_res c) in let post = elab_term (comp_post c) in mk_abs t R.Q_Explicit post let comp_post_type (c:comp_st) : R.term = let t = elab_term (comp_res c) in mk_arrow (t, R.Q_Explicit) vprop_tm assume val inversion_of_stt_typing (g:env) (c:comp_st) (#u:R.universe) // _ |- stt u#u t pre (fun (x:t) -> post) : Type _ (_:RT.tot_typing (elab_env g) (elab_comp c) (RT.tm_type u)) : GTot (x:( // _ |- t : Type u#u RT.tot_typing (elab_env g) (elab_term (comp_res c)) (RT.tm_type (comp_u c)) & // _ |- pre : vprop RT.tot_typing (elab_env g) (elab_term (comp_pre c)) (elab_term (tm_vprop)) & // _ |- (fun (x:t) -> post) : t -> vprop RT.tot_typing (elab_env g) (elab_comp_post c) (elab_term (tm_arrow (null_binder (comp_res c)) None (C_Tot tm_vprop)))){ u == universe_of_comp c }) let soundness_t (d:'a) = g:stt_env -> t:st_term -> c:comp -> d':st_typing g t c{d' << d} -> GTot (RT.tot_typing (elab_env g) (elab_st_typing d') (elab_comp c)) let elab_open_commute' (e:term) (v:term) (n:index) : Lemma (ensures RT.subst_term (elab_term e) [ RT.DT n (elab_term v)] == elab_term (open_term' e v n)) [SMTPat (elab_term (open_term' e v n))] = elab_open_commute' e v n let elab_close_commute' (e:term) (v:var) (n:index) : Lemma (RT.subst_term (elab_term e) [ RT.ND v n ] == elab_term (close_term' e v n)) [SMTPat (elab_term (close_term' e v n))] = elab_close_commute' e v n
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: Pulse.Syntax.Base.comp -> x: Pulse.Syntax.Base.var -> FStar.Pervasives.Lemma (ensures Pulse.Elaborate.Pure.elab_comp (Pulse.Syntax.Naming.close_comp c x) == FStar.Reflection.Typing.close_term (Pulse.Elaborate.Pure.elab_comp c) x) [SMTPat (Pulse.Elaborate.Pure.elab_comp (Pulse.Syntax.Naming.close_comp c x))]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Pulse.Syntax.Base.comp", "Pulse.Syntax.Base.var", "Pulse.Elaborate.elab_comp_close_commute", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.Stubs.Reflection.Types.term", "Pulse.Elaborate.Pure.elab_comp", "Pulse.Syntax.Naming.close_comp", "FStar.Reflection.Typing.close_term", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
true
false
true
false
false
let elab_comp_close_commute (c: comp) (x: var) : Lemma (ensures elab_comp (close_comp c x) == RT.close_term (elab_comp c) x) [SMTPat (elab_comp (close_comp c x))] =
elab_comp_close_commute c x
false
FStar.BitVector.fst
FStar.BitVector.lognot_vec
val lognot_vec (#n: pos) (a: bv_t n) : Tot (bv_t n)
val lognot_vec (#n: pos) (a: bv_t n) : Tot (bv_t n)
let rec lognot_vec (#n: pos) (a: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (not (index a 0)) else append (create 1 (not (index a 0))) (lognot_vec #(n - 1) (slice a 1 n))
{ "file_name": "ulib/FStar.BitVector.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 78, "end_line": 84, "start_col": 0, "start_line": 81 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 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.BitVector /// This module defines a bit vector as a sequence of booleans of a /// given length, and provides various utilities. /// /// NOTE: THE TYPE [bv_t] DEFINED IS UNRELATED TO THE SMT SOLVER'S /// THEORY OF BIT VECTORS. SEE [FStar.BV] FOR THAT. /// /// TODO: We might rename this module to FStar.Seq.Boolean? open FStar.Mul open FStar.Seq (** [bv_t n] is just a sequence of booleans of length [n] *) type bv_t (n: nat) = vec: seq bool {length vec = n} (**** Common constants *) (** A length [n] zero vector *) let zero_vec (#n: pos) : Tot (bv_t n) = create n false (** A vector of length [n] whose [i]th bit is set, only *) let elem_vec (#n: pos) (i: nat{i < n}) : Tot (bv_t n) = upd (create n false) i true (** A length [n] vector all of whose bits are set *) let ones_vec (#n: pos) : Tot (bv_t n) = create n true (** Bitwise logical and *) let rec logand_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 && index b 0) else append (create 1 (index a 0 && index b 0)) (logand_vec #(n - 1) (slice a 1 n) (slice b 1 n)) (** [logand] defined in terms of its indexing behavior *) let rec logand_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logand_vec #n a b) i = (index a i && index b i)) [SMTPat (index (logand_vec #n a b) i)] = if i = 0 then () else logand_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1) (** Bitwise logical exclusive or *) let rec logxor_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 <> index b 0) else append (create 1 (index a 0 <> index b 0)) (logxor_vec #(n - 1) (slice a 1 n) (slice b 1 n)) (** [logxor] defined in terms of its indexing behavior *) let rec logxor_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logxor_vec #n a b) i = (index a i <> index b i)) [SMTPat (index (logxor_vec #n a b) i)] = if i = 0 then () else logxor_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1) (** Bitwise logical or *) let rec logor_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 || index b 0) else append (create 1 (index a 0 || index b 0)) (logor_vec #(n - 1) (slice a 1 n) (slice b 1 n)) (** [logor] defined in terms of its indexing behavior *) let rec logor_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logor_vec #n a b) i = (index a i || index b i)) [SMTPat (index (logor_vec #n a b) i)] = if i = 0 then () else logor_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.BitVector.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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
a: FStar.BitVector.bv_t n -> FStar.BitVector.bv_t n
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "FStar.BitVector.bv_t", "Prims.op_Equality", "Prims.int", "FStar.Seq.Base.create", "Prims.bool", "Prims.op_Negation", "FStar.Seq.Base.index", "FStar.Seq.Base.append", "FStar.BitVector.lognot_vec", "Prims.op_Subtraction", "FStar.Seq.Base.slice" ]
[ "recursion" ]
false
false
false
false
false
let rec lognot_vec (#n: pos) (a: bv_t n) : Tot (bv_t n) =
if n = 1 then create 1 (not (index a 0)) else append (create 1 (not (index a 0))) (lognot_vec #(n - 1) (slice a 1 n))
false
FStar.BitVector.fst
FStar.BitVector.lognot_vec_definition
val lognot_vec_definition (#n: pos) (a: bv_t n) (i: nat{i < n}) : Lemma (ensures index (lognot_vec #n a) i = not (index a i)) [SMTPat (index (lognot_vec #n a) i)]
val lognot_vec_definition (#n: pos) (a: bv_t n) (i: nat{i < n}) : Lemma (ensures index (lognot_vec #n a) i = not (index a i)) [SMTPat (index (lognot_vec #n a) i)]
let rec lognot_vec_definition (#n: pos) (a: bv_t n) (i: nat{i < n}) : Lemma (ensures index (lognot_vec #n a) i = not (index a i)) [SMTPat (index (lognot_vec #n a) i)] = if i = 0 then () else lognot_vec_definition #(n - 1) (slice a 1 n) (i - 1)
{ "file_name": "ulib/FStar.BitVector.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 76, "end_line": 90, "start_col": 0, "start_line": 87 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 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.BitVector /// This module defines a bit vector as a sequence of booleans of a /// given length, and provides various utilities. /// /// NOTE: THE TYPE [bv_t] DEFINED IS UNRELATED TO THE SMT SOLVER'S /// THEORY OF BIT VECTORS. SEE [FStar.BV] FOR THAT. /// /// TODO: We might rename this module to FStar.Seq.Boolean? open FStar.Mul open FStar.Seq (** [bv_t n] is just a sequence of booleans of length [n] *) type bv_t (n: nat) = vec: seq bool {length vec = n} (**** Common constants *) (** A length [n] zero vector *) let zero_vec (#n: pos) : Tot (bv_t n) = create n false (** A vector of length [n] whose [i]th bit is set, only *) let elem_vec (#n: pos) (i: nat{i < n}) : Tot (bv_t n) = upd (create n false) i true (** A length [n] vector all of whose bits are set *) let ones_vec (#n: pos) : Tot (bv_t n) = create n true (** Bitwise logical and *) let rec logand_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 && index b 0) else append (create 1 (index a 0 && index b 0)) (logand_vec #(n - 1) (slice a 1 n) (slice b 1 n)) (** [logand] defined in terms of its indexing behavior *) let rec logand_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logand_vec #n a b) i = (index a i && index b i)) [SMTPat (index (logand_vec #n a b) i)] = if i = 0 then () else logand_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1) (** Bitwise logical exclusive or *) let rec logxor_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 <> index b 0) else append (create 1 (index a 0 <> index b 0)) (logxor_vec #(n - 1) (slice a 1 n) (slice b 1 n)) (** [logxor] defined in terms of its indexing behavior *) let rec logxor_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logxor_vec #n a b) i = (index a i <> index b i)) [SMTPat (index (logxor_vec #n a b) i)] = if i = 0 then () else logxor_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1) (** Bitwise logical or *) let rec logor_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 || index b 0) else append (create 1 (index a 0 || index b 0)) (logor_vec #(n - 1) (slice a 1 n) (slice b 1 n)) (** [logor] defined in terms of its indexing behavior *) let rec logor_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logor_vec #n a b) i = (index a i || index b i)) [SMTPat (index (logor_vec #n a b) i)] = if i = 0 then () else logor_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1) (** Bitwise negation *) let rec lognot_vec (#n: pos) (a: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (not (index a 0)) else append (create 1 (not (index a 0))) (lognot_vec #(n - 1) (slice a 1 n))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.BitVector.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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
a: FStar.BitVector.bv_t n -> i: Prims.nat{i < n} -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.index (FStar.BitVector.lognot_vec a) i = Prims.op_Negation (FStar.Seq.Base.index a i)) [SMTPat (FStar.Seq.Base.index (FStar.BitVector.lognot_vec a) i)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "FStar.BitVector.bv_t", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Equality", "Prims.int", "Prims.bool", "FStar.BitVector.lognot_vec_definition", "Prims.op_Subtraction", "FStar.Seq.Base.slice", "Prims.unit", "Prims.l_True", "Prims.squash", "FStar.Seq.Base.index", "FStar.BitVector.lognot_vec", "Prims.op_Negation", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[ "recursion" ]
false
false
true
false
false
let rec lognot_vec_definition (#n: pos) (a: bv_t n) (i: nat{i < n}) : Lemma (ensures index (lognot_vec #n a) i = not (index a i)) [SMTPat (index (lognot_vec #n a) i)] =
if i = 0 then () else lognot_vec_definition #(n - 1) (slice a 1 n) (i - 1)
false
FStar.BitVector.fst
FStar.BitVector.logxor_vec_definition
val logxor_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logxor_vec #n a b) i = (index a i <> index b i)) [SMTPat (index (logxor_vec #n a b) i)]
val logxor_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logxor_vec #n a b) i = (index a i <> index b i)) [SMTPat (index (logxor_vec #n a b) i)]
let rec logxor_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logxor_vec #n a b) i = (index a i <> index b i)) [SMTPat (index (logxor_vec #n a b) i)] = if i = 0 then () else logxor_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1)
{ "file_name": "ulib/FStar.BitVector.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 90, "end_line": 66, "start_col": 0, "start_line": 63 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 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.BitVector /// This module defines a bit vector as a sequence of booleans of a /// given length, and provides various utilities. /// /// NOTE: THE TYPE [bv_t] DEFINED IS UNRELATED TO THE SMT SOLVER'S /// THEORY OF BIT VECTORS. SEE [FStar.BV] FOR THAT. /// /// TODO: We might rename this module to FStar.Seq.Boolean? open FStar.Mul open FStar.Seq (** [bv_t n] is just a sequence of booleans of length [n] *) type bv_t (n: nat) = vec: seq bool {length vec = n} (**** Common constants *) (** A length [n] zero vector *) let zero_vec (#n: pos) : Tot (bv_t n) = create n false (** A vector of length [n] whose [i]th bit is set, only *) let elem_vec (#n: pos) (i: nat{i < n}) : Tot (bv_t n) = upd (create n false) i true (** A length [n] vector all of whose bits are set *) let ones_vec (#n: pos) : Tot (bv_t n) = create n true (** Bitwise logical and *) let rec logand_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 && index b 0) else append (create 1 (index a 0 && index b 0)) (logand_vec #(n - 1) (slice a 1 n) (slice b 1 n)) (** [logand] defined in terms of its indexing behavior *) let rec logand_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logand_vec #n a b) i = (index a i && index b i)) [SMTPat (index (logand_vec #n a b) i)] = if i = 0 then () else logand_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1) (** Bitwise logical exclusive or *) let rec logxor_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 <> index b 0) else append (create 1 (index a 0 <> index b 0)) (logxor_vec #(n - 1) (slice a 1 n) (slice b 1 n))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.BitVector.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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
a: FStar.BitVector.bv_t n -> b: FStar.BitVector.bv_t n -> i: Prims.nat{i < n} -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.index (FStar.BitVector.logxor_vec a b) i = (FStar.Seq.Base.index a i <> FStar.Seq.Base.index b i)) [SMTPat (FStar.Seq.Base.index (FStar.BitVector.logxor_vec a b) i)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "FStar.BitVector.bv_t", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Equality", "Prims.int", "Prims.bool", "FStar.BitVector.logxor_vec_definition", "Prims.op_Subtraction", "FStar.Seq.Base.slice", "Prims.unit", "Prims.l_True", "Prims.squash", "FStar.Seq.Base.index", "FStar.BitVector.logxor_vec", "Prims.op_disEquality", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[ "recursion" ]
false
false
true
false
false
let rec logxor_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logxor_vec #n a b) i = (index a i <> index b i)) [SMTPat (index (logxor_vec #n a b) i)] =
if i = 0 then () else logxor_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1)
false
FStar.BitVector.fst
FStar.BitVector.is_subset_vec
val is_subset_vec : a: FStar.BitVector.bv_t n -> b: FStar.BitVector.bv_t n -> Prims.logical
let is_subset_vec (#n: pos) (a b: bv_t n) = forall (i: nat). i < n ==> index b i = false ==> index a i = false
{ "file_name": "ulib/FStar.BitVector.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 68, "end_line": 108, "start_col": 0, "start_line": 107 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.BitVector /// This module defines a bit vector as a sequence of booleans of a /// given length, and provides various utilities. /// /// NOTE: THE TYPE [bv_t] DEFINED IS UNRELATED TO THE SMT SOLVER'S /// THEORY OF BIT VECTORS. SEE [FStar.BV] FOR THAT. /// /// TODO: We might rename this module to FStar.Seq.Boolean? open FStar.Mul open FStar.Seq (** [bv_t n] is just a sequence of booleans of length [n] *) type bv_t (n: nat) = vec: seq bool {length vec = n} (**** Common constants *) (** A length [n] zero vector *) let zero_vec (#n: pos) : Tot (bv_t n) = create n false (** A vector of length [n] whose [i]th bit is set, only *) let elem_vec (#n: pos) (i: nat{i < n}) : Tot (bv_t n) = upd (create n false) i true (** A length [n] vector all of whose bits are set *) let ones_vec (#n: pos) : Tot (bv_t n) = create n true (** Bitwise logical and *) let rec logand_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 && index b 0) else append (create 1 (index a 0 && index b 0)) (logand_vec #(n - 1) (slice a 1 n) (slice b 1 n)) (** [logand] defined in terms of its indexing behavior *) let rec logand_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logand_vec #n a b) i = (index a i && index b i)) [SMTPat (index (logand_vec #n a b) i)] = if i = 0 then () else logand_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1) (** Bitwise logical exclusive or *) let rec logxor_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 <> index b 0) else append (create 1 (index a 0 <> index b 0)) (logxor_vec #(n - 1) (slice a 1 n) (slice b 1 n)) (** [logxor] defined in terms of its indexing behavior *) let rec logxor_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logxor_vec #n a b) i = (index a i <> index b i)) [SMTPat (index (logxor_vec #n a b) i)] = if i = 0 then () else logxor_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1) (** Bitwise logical or *) let rec logor_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 || index b 0) else append (create 1 (index a 0 || index b 0)) (logor_vec #(n - 1) (slice a 1 n) (slice b 1 n)) (** [logor] defined in terms of its indexing behavior *) let rec logor_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logor_vec #n a b) i = (index a i || index b i)) [SMTPat (index (logor_vec #n a b) i)] = if i = 0 then () else logor_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1) (** Bitwise negation *) let rec lognot_vec (#n: pos) (a: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (not (index a 0)) else append (create 1 (not (index a 0))) (lognot_vec #(n - 1) (slice a 1 n)) (** [lognot] defined in terms of its indexing behavior *) let rec lognot_vec_definition (#n: pos) (a: bv_t n) (i: nat{i < n}) : Lemma (ensures index (lognot_vec #n a) i = not (index a i)) [SMTPat (index (lognot_vec #n a) i)] = if i = 0 then () else lognot_vec_definition #(n - 1) (slice a 1 n) (i - 1) (* Bitwise lemmas *) (** If both [x] and [y] are false at a given index [i], then so is they logical xor at [i] *) let lemma_xor_bounded (m: pos) (n: nat) (x y: bv_t m) : Lemma (requires (forall (i: nat). (i < m /\ i >= n) ==> (Seq.index x (m - 1 - i) = false /\ Seq.index y (m - 1 - i) = false))) (ensures (forall (i: nat). (i < m /\ i >= n) ==> (Seq.index (logxor_vec x y) (m - 1 - i) = false))) = () (** The property that the zero bits of b are also zero in a.
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.BitVector.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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
a: FStar.BitVector.bv_t n -> b: FStar.BitVector.bv_t n -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "FStar.BitVector.bv_t", "Prims.l_Forall", "Prims.nat", "Prims.l_imp", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Equality", "Prims.bool", "FStar.Seq.Base.index", "Prims.logical" ]
[]
false
false
false
false
true
let is_subset_vec (#n: pos) (a b: bv_t n) =
forall (i: nat). i < n ==> index b i = false ==> index a i = false
false
FStar.BitVector.fst
FStar.BitVector.logor_vec_definition
val logor_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logor_vec #n a b) i = (index a i || index b i)) [SMTPat (index (logor_vec #n a b) i)]
val logor_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logor_vec #n a b) i = (index a i || index b i)) [SMTPat (index (logor_vec #n a b) i)]
let rec logor_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logor_vec #n a b) i = (index a i || index b i)) [SMTPat (index (logor_vec #n a b) i)] = if i = 0 then () else logor_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1)
{ "file_name": "ulib/FStar.BitVector.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 89, "end_line": 78, "start_col": 0, "start_line": 75 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.BitVector /// This module defines a bit vector as a sequence of booleans of a /// given length, and provides various utilities. /// /// NOTE: THE TYPE [bv_t] DEFINED IS UNRELATED TO THE SMT SOLVER'S /// THEORY OF BIT VECTORS. SEE [FStar.BV] FOR THAT. /// /// TODO: We might rename this module to FStar.Seq.Boolean? open FStar.Mul open FStar.Seq (** [bv_t n] is just a sequence of booleans of length [n] *) type bv_t (n: nat) = vec: seq bool {length vec = n} (**** Common constants *) (** A length [n] zero vector *) let zero_vec (#n: pos) : Tot (bv_t n) = create n false (** A vector of length [n] whose [i]th bit is set, only *) let elem_vec (#n: pos) (i: nat{i < n}) : Tot (bv_t n) = upd (create n false) i true (** A length [n] vector all of whose bits are set *) let ones_vec (#n: pos) : Tot (bv_t n) = create n true (** Bitwise logical and *) let rec logand_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 && index b 0) else append (create 1 (index a 0 && index b 0)) (logand_vec #(n - 1) (slice a 1 n) (slice b 1 n)) (** [logand] defined in terms of its indexing behavior *) let rec logand_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logand_vec #n a b) i = (index a i && index b i)) [SMTPat (index (logand_vec #n a b) i)] = if i = 0 then () else logand_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1) (** Bitwise logical exclusive or *) let rec logxor_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 <> index b 0) else append (create 1 (index a 0 <> index b 0)) (logxor_vec #(n - 1) (slice a 1 n) (slice b 1 n)) (** [logxor] defined in terms of its indexing behavior *) let rec logxor_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logxor_vec #n a b) i = (index a i <> index b i)) [SMTPat (index (logxor_vec #n a b) i)] = if i = 0 then () else logxor_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1) (** Bitwise logical or *) let rec logor_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 || index b 0) else append (create 1 (index a 0 || index b 0)) (logor_vec #(n - 1) (slice a 1 n) (slice b 1 n))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.BitVector.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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
a: FStar.BitVector.bv_t n -> b: FStar.BitVector.bv_t n -> i: Prims.nat{i < n} -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.index (FStar.BitVector.logor_vec a b) i = (FStar.Seq.Base.index a i || FStar.Seq.Base.index b i)) [SMTPat (FStar.Seq.Base.index (FStar.BitVector.logor_vec a b) i)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "FStar.BitVector.bv_t", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Equality", "Prims.int", "Prims.bool", "FStar.BitVector.logor_vec_definition", "Prims.op_Subtraction", "FStar.Seq.Base.slice", "Prims.unit", "Prims.l_True", "Prims.squash", "FStar.Seq.Base.index", "FStar.BitVector.logor_vec", "Prims.op_BarBar", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[ "recursion" ]
false
false
true
false
false
let rec logor_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logor_vec #n a b) i = (index a i || index b i)) [SMTPat (index (logor_vec #n a b) i)] =
if i = 0 then () else logor_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1)
false
FStar.BitVector.fst
FStar.BitVector.logxor_vec
val logxor_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n)
val logxor_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n)
let rec logxor_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 <> index b 0) else append (create 1 (index a 0 <> index b 0)) (logxor_vec #(n - 1) (slice a 1 n) (slice b 1 n))
{ "file_name": "ulib/FStar.BitVector.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 99, "end_line": 60, "start_col": 0, "start_line": 57 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 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.BitVector /// This module defines a bit vector as a sequence of booleans of a /// given length, and provides various utilities. /// /// NOTE: THE TYPE [bv_t] DEFINED IS UNRELATED TO THE SMT SOLVER'S /// THEORY OF BIT VECTORS. SEE [FStar.BV] FOR THAT. /// /// TODO: We might rename this module to FStar.Seq.Boolean? open FStar.Mul open FStar.Seq (** [bv_t n] is just a sequence of booleans of length [n] *) type bv_t (n: nat) = vec: seq bool {length vec = n} (**** Common constants *) (** A length [n] zero vector *) let zero_vec (#n: pos) : Tot (bv_t n) = create n false (** A vector of length [n] whose [i]th bit is set, only *) let elem_vec (#n: pos) (i: nat{i < n}) : Tot (bv_t n) = upd (create n false) i true (** A length [n] vector all of whose bits are set *) let ones_vec (#n: pos) : Tot (bv_t n) = create n true (** Bitwise logical and *) let rec logand_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 && index b 0) else append (create 1 (index a 0 && index b 0)) (logand_vec #(n - 1) (slice a 1 n) (slice b 1 n)) (** [logand] defined in terms of its indexing behavior *) let rec logand_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logand_vec #n a b) i = (index a i && index b i)) [SMTPat (index (logand_vec #n a b) i)] = if i = 0 then () else logand_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.BitVector.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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
a: FStar.BitVector.bv_t n -> b: FStar.BitVector.bv_t n -> FStar.BitVector.bv_t n
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "FStar.BitVector.bv_t", "Prims.op_Equality", "Prims.int", "FStar.Seq.Base.create", "Prims.bool", "Prims.op_disEquality", "FStar.Seq.Base.index", "FStar.Seq.Base.append", "FStar.BitVector.logxor_vec", "Prims.op_Subtraction", "FStar.Seq.Base.slice" ]
[ "recursion" ]
false
false
false
false
false
let rec logxor_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) =
if n = 1 then create 1 (index a 0 <> index b 0) else append (create 1 (index a 0 <> index b 0)) (logxor_vec #(n - 1) (slice a 1 n) (slice b 1 n))
false
FStar.BitVector.fst
FStar.BitVector.logand_vec_definition
val logand_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logand_vec #n a b) i = (index a i && index b i)) [SMTPat (index (logand_vec #n a b) i)]
val logand_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logand_vec #n a b) i = (index a i && index b i)) [SMTPat (index (logand_vec #n a b) i)]
let rec logand_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logand_vec #n a b) i = (index a i && index b i)) [SMTPat (index (logand_vec #n a b) i)] = if i = 0 then () else logand_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1)
{ "file_name": "ulib/FStar.BitVector.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 90, "end_line": 54, "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 FStar.BitVector /// This module defines a bit vector as a sequence of booleans of a /// given length, and provides various utilities. /// /// NOTE: THE TYPE [bv_t] DEFINED IS UNRELATED TO THE SMT SOLVER'S /// THEORY OF BIT VECTORS. SEE [FStar.BV] FOR THAT. /// /// TODO: We might rename this module to FStar.Seq.Boolean? open FStar.Mul open FStar.Seq (** [bv_t n] is just a sequence of booleans of length [n] *) type bv_t (n: nat) = vec: seq bool {length vec = n} (**** Common constants *) (** A length [n] zero vector *) let zero_vec (#n: pos) : Tot (bv_t n) = create n false (** A vector of length [n] whose [i]th bit is set, only *) let elem_vec (#n: pos) (i: nat{i < n}) : Tot (bv_t n) = upd (create n false) i true (** A length [n] vector all of whose bits are set *) let ones_vec (#n: pos) : Tot (bv_t n) = create n true (** Bitwise logical and *) let rec logand_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 && index b 0) else append (create 1 (index a 0 && index b 0)) (logand_vec #(n - 1) (slice a 1 n) (slice b 1 n))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.BitVector.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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
a: FStar.BitVector.bv_t n -> b: FStar.BitVector.bv_t n -> i: Prims.nat{i < n} -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.index (FStar.BitVector.logand_vec a b) i = (FStar.Seq.Base.index a i && FStar.Seq.Base.index b i)) [SMTPat (FStar.Seq.Base.index (FStar.BitVector.logand_vec a b) i)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "FStar.BitVector.bv_t", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Equality", "Prims.int", "Prims.bool", "FStar.BitVector.logand_vec_definition", "Prims.op_Subtraction", "FStar.Seq.Base.slice", "Prims.unit", "Prims.l_True", "Prims.squash", "FStar.Seq.Base.index", "FStar.BitVector.logand_vec", "Prims.op_AmpAmp", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[ "recursion" ]
false
false
true
false
false
let rec logand_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logand_vec #n a b) i = (index a i && index b i)) [SMTPat (index (logand_vec #n a b) i)] =
if i = 0 then () else logand_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1)
false
FStar.BitVector.fst
FStar.BitVector.is_superset_vec
val is_superset_vec : a: FStar.BitVector.bv_t n -> b: FStar.BitVector.bv_t n -> Prims.logical
let is_superset_vec (#n: pos) (a b: bv_t n) = forall (i: nat). i < n ==> index b i = true ==> index a i = true
{ "file_name": "ulib/FStar.BitVector.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 66, "end_line": 113, "start_col": 0, "start_line": 112 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.BitVector /// This module defines a bit vector as a sequence of booleans of a /// given length, and provides various utilities. /// /// NOTE: THE TYPE [bv_t] DEFINED IS UNRELATED TO THE SMT SOLVER'S /// THEORY OF BIT VECTORS. SEE [FStar.BV] FOR THAT. /// /// TODO: We might rename this module to FStar.Seq.Boolean? open FStar.Mul open FStar.Seq (** [bv_t n] is just a sequence of booleans of length [n] *) type bv_t (n: nat) = vec: seq bool {length vec = n} (**** Common constants *) (** A length [n] zero vector *) let zero_vec (#n: pos) : Tot (bv_t n) = create n false (** A vector of length [n] whose [i]th bit is set, only *) let elem_vec (#n: pos) (i: nat{i < n}) : Tot (bv_t n) = upd (create n false) i true (** A length [n] vector all of whose bits are set *) let ones_vec (#n: pos) : Tot (bv_t n) = create n true (** Bitwise logical and *) let rec logand_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 && index b 0) else append (create 1 (index a 0 && index b 0)) (logand_vec #(n - 1) (slice a 1 n) (slice b 1 n)) (** [logand] defined in terms of its indexing behavior *) let rec logand_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logand_vec #n a b) i = (index a i && index b i)) [SMTPat (index (logand_vec #n a b) i)] = if i = 0 then () else logand_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1) (** Bitwise logical exclusive or *) let rec logxor_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 <> index b 0) else append (create 1 (index a 0 <> index b 0)) (logxor_vec #(n - 1) (slice a 1 n) (slice b 1 n)) (** [logxor] defined in terms of its indexing behavior *) let rec logxor_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logxor_vec #n a b) i = (index a i <> index b i)) [SMTPat (index (logxor_vec #n a b) i)] = if i = 0 then () else logxor_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1) (** Bitwise logical or *) let rec logor_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 || index b 0) else append (create 1 (index a 0 || index b 0)) (logor_vec #(n - 1) (slice a 1 n) (slice b 1 n)) (** [logor] defined in terms of its indexing behavior *) let rec logor_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logor_vec #n a b) i = (index a i || index b i)) [SMTPat (index (logor_vec #n a b) i)] = if i = 0 then () else logor_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1) (** Bitwise negation *) let rec lognot_vec (#n: pos) (a: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (not (index a 0)) else append (create 1 (not (index a 0))) (lognot_vec #(n - 1) (slice a 1 n)) (** [lognot] defined in terms of its indexing behavior *) let rec lognot_vec_definition (#n: pos) (a: bv_t n) (i: nat{i < n}) : Lemma (ensures index (lognot_vec #n a) i = not (index a i)) [SMTPat (index (lognot_vec #n a) i)] = if i = 0 then () else lognot_vec_definition #(n - 1) (slice a 1 n) (i - 1) (* Bitwise lemmas *) (** If both [x] and [y] are false at a given index [i], then so is they logical xor at [i] *) let lemma_xor_bounded (m: pos) (n: nat) (x y: bv_t m) : Lemma (requires (forall (i: nat). (i < m /\ i >= n) ==> (Seq.index x (m - 1 - i) = false /\ Seq.index y (m - 1 - i) = false))) (ensures (forall (i: nat). (i < m /\ i >= n) ==> (Seq.index (logxor_vec x y) (m - 1 - i) = false))) = () (** The property that the zero bits of b are also zero in a. I.e. that a is a subset of b. *) let is_subset_vec (#n: pos) (a b: bv_t n) = forall (i: nat). i < n ==> index b i = false ==> index a i = false (** The property that the non-zero bits of b are also non-zero in a.
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.BitVector.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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
a: FStar.BitVector.bv_t n -> b: FStar.BitVector.bv_t n -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "FStar.BitVector.bv_t", "Prims.l_Forall", "Prims.nat", "Prims.l_imp", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Equality", "Prims.bool", "FStar.Seq.Base.index", "Prims.logical" ]
[]
false
false
false
false
true
let is_superset_vec (#n: pos) (a b: bv_t n) =
forall (i: nat). i < n ==> index b i = true ==> index a i = true
false
FStar.BitVector.fst
FStar.BitVector.logor_vec
val logor_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n)
val logor_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n)
let rec logor_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 || index b 0) else append (create 1 (index a 0 || index b 0)) (logor_vec #(n - 1) (slice a 1 n) (slice b 1 n))
{ "file_name": "ulib/FStar.BitVector.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 98, "end_line": 72, "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.BitVector /// This module defines a bit vector as a sequence of booleans of a /// given length, and provides various utilities. /// /// NOTE: THE TYPE [bv_t] DEFINED IS UNRELATED TO THE SMT SOLVER'S /// THEORY OF BIT VECTORS. SEE [FStar.BV] FOR THAT. /// /// TODO: We might rename this module to FStar.Seq.Boolean? open FStar.Mul open FStar.Seq (** [bv_t n] is just a sequence of booleans of length [n] *) type bv_t (n: nat) = vec: seq bool {length vec = n} (**** Common constants *) (** A length [n] zero vector *) let zero_vec (#n: pos) : Tot (bv_t n) = create n false (** A vector of length [n] whose [i]th bit is set, only *) let elem_vec (#n: pos) (i: nat{i < n}) : Tot (bv_t n) = upd (create n false) i true (** A length [n] vector all of whose bits are set *) let ones_vec (#n: pos) : Tot (bv_t n) = create n true (** Bitwise logical and *) let rec logand_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 && index b 0) else append (create 1 (index a 0 && index b 0)) (logand_vec #(n - 1) (slice a 1 n) (slice b 1 n)) (** [logand] defined in terms of its indexing behavior *) let rec logand_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logand_vec #n a b) i = (index a i && index b i)) [SMTPat (index (logand_vec #n a b) i)] = if i = 0 then () else logand_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1) (** Bitwise logical exclusive or *) let rec logxor_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 <> index b 0) else append (create 1 (index a 0 <> index b 0)) (logxor_vec #(n - 1) (slice a 1 n) (slice b 1 n)) (** [logxor] defined in terms of its indexing behavior *) let rec logxor_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logxor_vec #n a b) i = (index a i <> index b i)) [SMTPat (index (logxor_vec #n a b) i)] = if i = 0 then () else logxor_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.BitVector.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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
a: FStar.BitVector.bv_t n -> b: FStar.BitVector.bv_t n -> FStar.BitVector.bv_t n
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "FStar.BitVector.bv_t", "Prims.op_Equality", "Prims.int", "FStar.Seq.Base.create", "Prims.bool", "Prims.op_BarBar", "FStar.Seq.Base.index", "FStar.Seq.Base.append", "FStar.BitVector.logor_vec", "Prims.op_Subtraction", "FStar.Seq.Base.slice" ]
[ "recursion" ]
false
false
false
false
false
let rec logor_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) =
if n = 1 then create 1 (index a 0 || index b 0) else append (create 1 (index a 0 || index b 0)) (logor_vec #(n - 1) (slice a 1 n) (slice b 1 n))
false
FStar.BitVector.fst
FStar.BitVector.shift_left_vec
val shift_left_vec (#n: pos) (a: bv_t n) (s: nat) : Tot (bv_t n)
val shift_left_vec (#n: pos) (a: bv_t n) (s: nat) : Tot (bv_t n)
let shift_left_vec (#n: pos) (a: bv_t n) (s: nat) : Tot (bv_t n) = if s >= n then zero_vec #n else if s = 0 then a else append (slice a s n) (zero_vec #s)
{ "file_name": "ulib/FStar.BitVector.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 89, "end_line": 138, "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.BitVector /// This module defines a bit vector as a sequence of booleans of a /// given length, and provides various utilities. /// /// NOTE: THE TYPE [bv_t] DEFINED IS UNRELATED TO THE SMT SOLVER'S /// THEORY OF BIT VECTORS. SEE [FStar.BV] FOR THAT. /// /// TODO: We might rename this module to FStar.Seq.Boolean? open FStar.Mul open FStar.Seq (** [bv_t n] is just a sequence of booleans of length [n] *) type bv_t (n: nat) = vec: seq bool {length vec = n} (**** Common constants *) (** A length [n] zero vector *) let zero_vec (#n: pos) : Tot (bv_t n) = create n false (** A vector of length [n] whose [i]th bit is set, only *) let elem_vec (#n: pos) (i: nat{i < n}) : Tot (bv_t n) = upd (create n false) i true (** A length [n] vector all of whose bits are set *) let ones_vec (#n: pos) : Tot (bv_t n) = create n true (** Bitwise logical and *) let rec logand_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 && index b 0) else append (create 1 (index a 0 && index b 0)) (logand_vec #(n - 1) (slice a 1 n) (slice b 1 n)) (** [logand] defined in terms of its indexing behavior *) let rec logand_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logand_vec #n a b) i = (index a i && index b i)) [SMTPat (index (logand_vec #n a b) i)] = if i = 0 then () else logand_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1) (** Bitwise logical exclusive or *) let rec logxor_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 <> index b 0) else append (create 1 (index a 0 <> index b 0)) (logxor_vec #(n - 1) (slice a 1 n) (slice b 1 n)) (** [logxor] defined in terms of its indexing behavior *) let rec logxor_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logxor_vec #n a b) i = (index a i <> index b i)) [SMTPat (index (logxor_vec #n a b) i)] = if i = 0 then () else logxor_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1) (** Bitwise logical or *) let rec logor_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 || index b 0) else append (create 1 (index a 0 || index b 0)) (logor_vec #(n - 1) (slice a 1 n) (slice b 1 n)) (** [logor] defined in terms of its indexing behavior *) let rec logor_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logor_vec #n a b) i = (index a i || index b i)) [SMTPat (index (logor_vec #n a b) i)] = if i = 0 then () else logor_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1) (** Bitwise negation *) let rec lognot_vec (#n: pos) (a: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (not (index a 0)) else append (create 1 (not (index a 0))) (lognot_vec #(n - 1) (slice a 1 n)) (** [lognot] defined in terms of its indexing behavior *) let rec lognot_vec_definition (#n: pos) (a: bv_t n) (i: nat{i < n}) : Lemma (ensures index (lognot_vec #n a) i = not (index a i)) [SMTPat (index (lognot_vec #n a) i)] = if i = 0 then () else lognot_vec_definition #(n - 1) (slice a 1 n) (i - 1) (* Bitwise lemmas *) (** If both [x] and [y] are false at a given index [i], then so is they logical xor at [i] *) let lemma_xor_bounded (m: pos) (n: nat) (x y: bv_t m) : Lemma (requires (forall (i: nat). (i < m /\ i >= n) ==> (Seq.index x (m - 1 - i) = false /\ Seq.index y (m - 1 - i) = false))) (ensures (forall (i: nat). (i < m /\ i >= n) ==> (Seq.index (logxor_vec x y) (m - 1 - i) = false))) = () (** The property that the zero bits of b are also zero in a. I.e. that a is a subset of b. *) let is_subset_vec (#n: pos) (a b: bv_t n) = forall (i: nat). i < n ==> index b i = false ==> index a i = false (** The property that the non-zero bits of b are also non-zero in a. I.e. that a is a superset of b. *) let is_superset_vec (#n: pos) (a b: bv_t n) = forall (i: nat). i < n ==> index b i = true ==> index a i = true (** Proves that the subset property is conserved in subslices. *) let lemma_slice_subset_vec (#n: pos) (a b: bv_t n) (i: nat) (j: nat{i < j && j <= n}) : Lemma (requires is_subset_vec a b) (ensures (match n with | 1 -> True | _ -> is_subset_vec #(j - i) (slice a i j) (slice b i j))) = () (** Proves that the superset property is conserved in subslices. *) let lemma_slice_superset_vec (#n: pos) (a b: bv_t n) (i: nat) (j: nat{i < j && j <= n}) : Lemma (requires is_superset_vec a b) (ensures (match n with | 1 -> True | _ -> is_superset_vec #(j - i) (slice a i j) (slice b i j))) = () (**** Shift operators *) (* Note: the shift amount is extracted as a bitvector NS: Not sure what this remark means. *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.BitVector.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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
a: FStar.BitVector.bv_t n -> s: Prims.nat -> FStar.BitVector.bv_t n
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "FStar.BitVector.bv_t", "Prims.nat", "Prims.op_GreaterThanOrEqual", "FStar.BitVector.zero_vec", "Prims.bool", "Prims.op_Equality", "Prims.int", "FStar.Seq.Base.append", "FStar.Seq.Base.slice" ]
[]
false
false
false
false
false
let shift_left_vec (#n: pos) (a: bv_t n) (s: nat) : Tot (bv_t n) =
if s >= n then zero_vec #n else if s = 0 then a else append (slice a s n) (zero_vec #s)
false
Spec.SHA3.Equivalence.fst
Spec.SHA3.Equivalence.state_chi
val state_chi (s_pi_rho: state) : Tot state
val state_chi (s_pi_rho: state) : Tot state
let state_chi (s_pi_rho:state) : Tot state = repeati 5 state_chi_inner s_pi_rho
{ "file_name": "specs/lemmas/Spec.SHA3.Equivalence.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 36, "end_line": 28, "start_col": 0, "start_line": 27 }
module Spec.SHA3.Equivalence open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open FStar.Mul open Lib.LoopCombinators open Spec.SHA3.Constants open Spec.SHA3 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" let state_chi_inner (y:index) (s:state) : Tot state = let v0 = get s 0 y ^. ((lognot (get s 1 y)) &. get s 2 y) in let v1 = get s 1 y ^. ((lognot (get s 2 y)) &. get s 3 y) in let v2 = get s 2 y ^. ((lognot (get s 3 y)) &. get s 4 y) in let v3 = get s 3 y ^. ((lognot (get s 4 y)) &. get s 0 y) in let v4 = get s 4 y ^. ((lognot (get s 0 y)) &. get s 1 y) in let s = set s 0 y v0 in let s = set s 1 y v1 in let s = set s 2 y v2 in let s = set s 3 y v3 in let s = set s 4 y v4 in s
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.Constants.fst.checked", "Spec.SHA3.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.SHA3.Equivalence.fst" }
[ { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA3.Constants", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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
s_pi_rho: Spec.SHA3.state -> Spec.SHA3.state
Prims.Tot
[ "total" ]
[]
[ "Spec.SHA3.state", "Lib.LoopCombinators.repeati", "Spec.SHA3.Equivalence.state_chi_inner" ]
[]
false
false
false
true
false
let state_chi (s_pi_rho: state) : Tot state =
repeati 5 state_chi_inner s_pi_rho
false
FStar.BitVector.fst
FStar.BitVector.shift_right_vec
val shift_right_vec (#n: pos) (a: bv_t n) (s: nat) : Tot (bv_t n)
val shift_right_vec (#n: pos) (a: bv_t n) (s: nat) : Tot (bv_t n)
let shift_right_vec (#n: pos) (a: bv_t n) (s: nat) : Tot (bv_t n) = if s >= n then zero_vec #n else if s = 0 then a else append (zero_vec #s) (slice a 0 (n - s))
{ "file_name": "ulib/FStar.BitVector.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 95, "end_line": 152, "start_col": 0, "start_line": 151 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 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.BitVector /// This module defines a bit vector as a sequence of booleans of a /// given length, and provides various utilities. /// /// NOTE: THE TYPE [bv_t] DEFINED IS UNRELATED TO THE SMT SOLVER'S /// THEORY OF BIT VECTORS. SEE [FStar.BV] FOR THAT. /// /// TODO: We might rename this module to FStar.Seq.Boolean? open FStar.Mul open FStar.Seq (** [bv_t n] is just a sequence of booleans of length [n] *) type bv_t (n: nat) = vec: seq bool {length vec = n} (**** Common constants *) (** A length [n] zero vector *) let zero_vec (#n: pos) : Tot (bv_t n) = create n false (** A vector of length [n] whose [i]th bit is set, only *) let elem_vec (#n: pos) (i: nat{i < n}) : Tot (bv_t n) = upd (create n false) i true (** A length [n] vector all of whose bits are set *) let ones_vec (#n: pos) : Tot (bv_t n) = create n true (** Bitwise logical and *) let rec logand_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 && index b 0) else append (create 1 (index a 0 && index b 0)) (logand_vec #(n - 1) (slice a 1 n) (slice b 1 n)) (** [logand] defined in terms of its indexing behavior *) let rec logand_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logand_vec #n a b) i = (index a i && index b i)) [SMTPat (index (logand_vec #n a b) i)] = if i = 0 then () else logand_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1) (** Bitwise logical exclusive or *) let rec logxor_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 <> index b 0) else append (create 1 (index a 0 <> index b 0)) (logxor_vec #(n - 1) (slice a 1 n) (slice b 1 n)) (** [logxor] defined in terms of its indexing behavior *) let rec logxor_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logxor_vec #n a b) i = (index a i <> index b i)) [SMTPat (index (logxor_vec #n a b) i)] = if i = 0 then () else logxor_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1) (** Bitwise logical or *) let rec logor_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 || index b 0) else append (create 1 (index a 0 || index b 0)) (logor_vec #(n - 1) (slice a 1 n) (slice b 1 n)) (** [logor] defined in terms of its indexing behavior *) let rec logor_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logor_vec #n a b) i = (index a i || index b i)) [SMTPat (index (logor_vec #n a b) i)] = if i = 0 then () else logor_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1) (** Bitwise negation *) let rec lognot_vec (#n: pos) (a: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (not (index a 0)) else append (create 1 (not (index a 0))) (lognot_vec #(n - 1) (slice a 1 n)) (** [lognot] defined in terms of its indexing behavior *) let rec lognot_vec_definition (#n: pos) (a: bv_t n) (i: nat{i < n}) : Lemma (ensures index (lognot_vec #n a) i = not (index a i)) [SMTPat (index (lognot_vec #n a) i)] = if i = 0 then () else lognot_vec_definition #(n - 1) (slice a 1 n) (i - 1) (* Bitwise lemmas *) (** If both [x] and [y] are false at a given index [i], then so is they logical xor at [i] *) let lemma_xor_bounded (m: pos) (n: nat) (x y: bv_t m) : Lemma (requires (forall (i: nat). (i < m /\ i >= n) ==> (Seq.index x (m - 1 - i) = false /\ Seq.index y (m - 1 - i) = false))) (ensures (forall (i: nat). (i < m /\ i >= n) ==> (Seq.index (logxor_vec x y) (m - 1 - i) = false))) = () (** The property that the zero bits of b are also zero in a. I.e. that a is a subset of b. *) let is_subset_vec (#n: pos) (a b: bv_t n) = forall (i: nat). i < n ==> index b i = false ==> index a i = false (** The property that the non-zero bits of b are also non-zero in a. I.e. that a is a superset of b. *) let is_superset_vec (#n: pos) (a b: bv_t n) = forall (i: nat). i < n ==> index b i = true ==> index a i = true (** Proves that the subset property is conserved in subslices. *) let lemma_slice_subset_vec (#n: pos) (a b: bv_t n) (i: nat) (j: nat{i < j && j <= n}) : Lemma (requires is_subset_vec a b) (ensures (match n with | 1 -> True | _ -> is_subset_vec #(j - i) (slice a i j) (slice b i j))) = () (** Proves that the superset property is conserved in subslices. *) let lemma_slice_superset_vec (#n: pos) (a b: bv_t n) (i: nat) (j: nat{i < j && j <= n}) : Lemma (requires is_superset_vec a b) (ensures (match n with | 1 -> True | _ -> is_superset_vec #(j - i) (slice a i j) (slice b i j))) = () (**** Shift operators *) (* Note: the shift amount is extracted as a bitvector NS: Not sure what this remark means. *) (** Shift [a] left by [s] bits, filling with zeroes *) let shift_left_vec (#n: pos) (a: bv_t n) (s: nat) : Tot (bv_t n) = if s >= n then zero_vec #n else if s = 0 then a else append (slice a s n) (zero_vec #s) (** The fill bits of a shift left are zero *) let shift_left_vec_lemma_1 (#n: pos) (a: bv_t n) (s: nat) (i: nat{i < n && i >= n - s}) : Lemma (ensures index (shift_left_vec #n a s) i = false) [SMTPat (index (shift_left_vec #n a s) i)] = () (** Relating the indexes of the shifted vector to the original *) let shift_left_vec_lemma_2 (#n: pos) (a: bv_t n) (s: nat) (i: nat{i < n && i < n - s}) : Lemma (ensures index (shift_left_vec #n a s) i = index a (i + s)) [SMTPat (index (shift_left_vec #n a s) i)] = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.BitVector.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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
a: FStar.BitVector.bv_t n -> s: Prims.nat -> FStar.BitVector.bv_t n
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "FStar.BitVector.bv_t", "Prims.nat", "Prims.op_GreaterThanOrEqual", "FStar.BitVector.zero_vec", "Prims.bool", "Prims.op_Equality", "Prims.int", "FStar.Seq.Base.append", "FStar.Seq.Base.slice", "Prims.op_Subtraction" ]
[]
false
false
false
false
false
let shift_right_vec (#n: pos) (a: bv_t n) (s: nat) : Tot (bv_t n) =
if s >= n then zero_vec #n else if s = 0 then a else append (zero_vec #s) (slice a 0 (n - s))
false
Spec.SHA3.Equivalence.fst
Spec.SHA3.Equivalence.state_chi_equivalence
val state_chi_equivalence (st_old: state) : Lemma (state_chi st_old == Spec.SHA3.state_chi st_old)
val state_chi_equivalence (st_old: state) : Lemma (state_chi st_old == Spec.SHA3.state_chi st_old)
let state_chi_equivalence (st_old:state) : Lemma (state_chi st_old == Spec.SHA3.state_chi st_old) = Lib.LoopCombinators.eq_repeati0 5 (state_chi_inner1 st_old) st_old; Lib.LoopCombinators.unfold_repeati 5 (state_chi_inner1 st_old) st_old 0; Lib.LoopCombinators.unfold_repeati 5 (state_chi_inner1 st_old) st_old 1; Lib.LoopCombinators.unfold_repeati 5 (state_chi_inner1 st_old) st_old 2; Lib.LoopCombinators.unfold_repeati 5 (state_chi_inner1 st_old) st_old 3; Lib.LoopCombinators.unfold_repeati 5 (state_chi_inner1 st_old) st_old 4; Lib.LoopCombinators.eq_repeati0 5 (state_chi_inner) st_old; Lib.LoopCombinators.unfold_repeati 5 (state_chi_inner) st_old 0; Lib.LoopCombinators.unfold_repeati 5 (state_chi_inner) st_old 1; Lib.LoopCombinators.unfold_repeati 5 (state_chi_inner) st_old 2; Lib.LoopCombinators.unfold_repeati 5 (state_chi_inner) st_old 3; Lib.LoopCombinators.unfold_repeati 5 (state_chi_inner) st_old 4; let st1 = state_chi_inner1 st_old 0 st_old in let st2 = state_chi_inner1 st_old 1 st1 in let st3 = state_chi_inner1 st_old 2 st2 in let st4 = state_chi_inner1 st_old 3 st3 in let st5 = state_chi_inner1 st_old 4 st4 in let st1' = state_chi_inner 0 st_old in let st2' = state_chi_inner 1 st1' in let st3' = state_chi_inner 2 st2' in let st4' = state_chi_inner 3 st3' in let st5' = state_chi_inner 4 st4' in state_chi_inner_equivalence0 st_old 0 st_old; assert(st1 == st1'); state_chi_inner_equivalence1 st_old 0 st1; state_chi_inner_equivalence0 st_old 1 st1; assert(st2 == st2'); state_chi_inner_equivalence1 st1' 1 st2'; state_chi_inner_equivalence0 st_old 2 st2; assert(st3 == st3'); state_chi_inner_equivalence1 st2 2 st3; state_chi_inner_equivalence0 st_old 3 st3; assert(st4 == st4'); state_chi_inner_equivalence1 st3 3 st4; state_chi_inner_equivalence0 st_old 4 st4; assert(st5 == st5'); state_chi_inner_equivalence1 st4 4 st5; ()
{ "file_name": "specs/lemmas/Spec.SHA3.Equivalence.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 11, "end_line": 99, "start_col": 0, "start_line": 60 }
module Spec.SHA3.Equivalence open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open FStar.Mul open Lib.LoopCombinators open Spec.SHA3.Constants open Spec.SHA3 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" let state_chi_inner (y:index) (s:state) : Tot state = let v0 = get s 0 y ^. ((lognot (get s 1 y)) &. get s 2 y) in let v1 = get s 1 y ^. ((lognot (get s 2 y)) &. get s 3 y) in let v2 = get s 2 y ^. ((lognot (get s 3 y)) &. get s 4 y) in let v3 = get s 3 y ^. ((lognot (get s 4 y)) &. get s 0 y) in let v4 = get s 4 y ^. ((lognot (get s 0 y)) &. get s 1 y) in let s = set s 0 y v0 in let s = set s 1 y v1 in let s = set s 2 y v2 in let s = set s 3 y v3 in let s = set s 4 y v4 in s let state_chi (s_pi_rho:state) : Tot state = repeati 5 state_chi_inner s_pi_rho let state_chi_inner_equivalence0 (st_old:state) (y:index) (st:state) : Lemma (requires (forall y'. (y' >= y /\ y' < 5) ==> get st_old 0 y' == get st 0 y' /\ get st_old 1 y' == get st 1 y' /\ get st_old 2 y' == get st 2 y' /\ get st_old 3 y' == get st 3 y' /\ get st_old 4 y' == get st 4 y')) (ensures (let st_new = state_chi_inner1 st_old y st in st_new == state_chi_inner y st)) = Lib.LoopCombinators.eq_repeati0 5 (state_chi_inner0 st_old y) st; Lib.LoopCombinators.unfold_repeati 5 (state_chi_inner0 st_old y) st 0; Lib.LoopCombinators.unfold_repeati 5 (state_chi_inner0 st_old y) st 1; Lib.LoopCombinators.unfold_repeati 5 (state_chi_inner0 st_old y) st 2; Lib.LoopCombinators.unfold_repeati 5 (state_chi_inner0 st_old y) st 3; Lib.LoopCombinators.unfold_repeati 5 (state_chi_inner0 st_old y) st 4; assert (repeati 5 (state_chi_inner0 st_old y) st == state_chi_inner0 st_old y 4 (state_chi_inner0 st_old y 3 (state_chi_inner0 st_old y 2 (state_chi_inner0 st_old y 1 (state_chi_inner0 st_old y 0 st))))); () let state_chi_inner_equivalence1 (st_old:state) (y:index) (st_new:state) : Lemma (requires (st_new == state_chi_inner y st_old)) (ensures ( (forall y'. (y' < 5 /\ y' > y) ==> (get st_new 0 y' == get st_old 0 y' /\ get st_new 1 y' == get st_old 1 y' /\ get st_new 2 y' == get st_old 2 y' /\ get st_new 3 y' == get st_old 3 y' /\ get st_new 4 y' == get st_old 4 y')))) = ()
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.Constants.fst.checked", "Spec.SHA3.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.SHA3.Equivalence.fst" }
[ { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA3.Constants", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": false, "full_module": "Spec.SHA3", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": 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
st_old: Spec.SHA3.state -> FStar.Pervasives.Lemma (ensures Spec.SHA3.Equivalence.state_chi st_old == Spec.SHA3.state_chi st_old)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Spec.SHA3.state", "Prims.unit", "Spec.SHA3.Equivalence.state_chi_inner_equivalence1", "Prims._assert", "Prims.eq2", "Spec.SHA3.Equivalence.state_chi_inner_equivalence0", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Spec.SHA3.Equivalence.state_chi_inner", "Spec.SHA3.state_chi_inner1", "Lib.LoopCombinators.unfold_repeati", "Lib.LoopCombinators.eq_repeati0", "Prims.l_True", "Prims.squash", "Spec.SHA3.Equivalence.state_chi", "Spec.SHA3.state_chi", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let state_chi_equivalence (st_old: state) : Lemma (state_chi st_old == Spec.SHA3.state_chi st_old) =
Lib.LoopCombinators.eq_repeati0 5 (state_chi_inner1 st_old) st_old; Lib.LoopCombinators.unfold_repeati 5 (state_chi_inner1 st_old) st_old 0; Lib.LoopCombinators.unfold_repeati 5 (state_chi_inner1 st_old) st_old 1; Lib.LoopCombinators.unfold_repeati 5 (state_chi_inner1 st_old) st_old 2; Lib.LoopCombinators.unfold_repeati 5 (state_chi_inner1 st_old) st_old 3; Lib.LoopCombinators.unfold_repeati 5 (state_chi_inner1 st_old) st_old 4; Lib.LoopCombinators.eq_repeati0 5 (state_chi_inner) st_old; Lib.LoopCombinators.unfold_repeati 5 (state_chi_inner) st_old 0; Lib.LoopCombinators.unfold_repeati 5 (state_chi_inner) st_old 1; Lib.LoopCombinators.unfold_repeati 5 (state_chi_inner) st_old 2; Lib.LoopCombinators.unfold_repeati 5 (state_chi_inner) st_old 3; Lib.LoopCombinators.unfold_repeati 5 (state_chi_inner) st_old 4; let st1 = state_chi_inner1 st_old 0 st_old in let st2 = state_chi_inner1 st_old 1 st1 in let st3 = state_chi_inner1 st_old 2 st2 in let st4 = state_chi_inner1 st_old 3 st3 in let st5 = state_chi_inner1 st_old 4 st4 in let st1' = state_chi_inner 0 st_old in let st2' = state_chi_inner 1 st1' in let st3' = state_chi_inner 2 st2' in let st4' = state_chi_inner 3 st3' in let st5' = state_chi_inner 4 st4' in state_chi_inner_equivalence0 st_old 0 st_old; assert (st1 == st1'); state_chi_inner_equivalence1 st_old 0 st1; state_chi_inner_equivalence0 st_old 1 st1; assert (st2 == st2'); state_chi_inner_equivalence1 st1' 1 st2'; state_chi_inner_equivalence0 st_old 2 st2; assert (st3 == st3'); state_chi_inner_equivalence1 st2 2 st3; state_chi_inner_equivalence0 st_old 3 st3; assert (st4 == st4'); state_chi_inner_equivalence1 st3 3 st4; state_chi_inner_equivalence0 st_old 4 st4; assert (st5 == st5'); state_chi_inner_equivalence1 st4 4 st5; ()
false
FStar.BitVector.fst
FStar.BitVector.shift_arithmetic_right_vec
val shift_arithmetic_right_vec (#n: pos) (a: bv_t n) (s: nat) : Tot (bv_t n)
val shift_arithmetic_right_vec (#n: pos) (a: bv_t n) (s: nat) : Tot (bv_t n)
let shift_arithmetic_right_vec (#n: pos) (a: bv_t n) (s: nat) : Tot (bv_t n) = if index a 0 then if s >= n then ones_vec #n else if s = 0 then a else append (ones_vec #s) (slice a 0 (n - s)) else shift_right_vec a s
{ "file_name": "ulib/FStar.BitVector.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 26, "end_line": 169, "start_col": 0, "start_line": 166 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 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.BitVector /// This module defines a bit vector as a sequence of booleans of a /// given length, and provides various utilities. /// /// NOTE: THE TYPE [bv_t] DEFINED IS UNRELATED TO THE SMT SOLVER'S /// THEORY OF BIT VECTORS. SEE [FStar.BV] FOR THAT. /// /// TODO: We might rename this module to FStar.Seq.Boolean? open FStar.Mul open FStar.Seq (** [bv_t n] is just a sequence of booleans of length [n] *) type bv_t (n: nat) = vec: seq bool {length vec = n} (**** Common constants *) (** A length [n] zero vector *) let zero_vec (#n: pos) : Tot (bv_t n) = create n false (** A vector of length [n] whose [i]th bit is set, only *) let elem_vec (#n: pos) (i: nat{i < n}) : Tot (bv_t n) = upd (create n false) i true (** A length [n] vector all of whose bits are set *) let ones_vec (#n: pos) : Tot (bv_t n) = create n true (** Bitwise logical and *) let rec logand_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 && index b 0) else append (create 1 (index a 0 && index b 0)) (logand_vec #(n - 1) (slice a 1 n) (slice b 1 n)) (** [logand] defined in terms of its indexing behavior *) let rec logand_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logand_vec #n a b) i = (index a i && index b i)) [SMTPat (index (logand_vec #n a b) i)] = if i = 0 then () else logand_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1) (** Bitwise logical exclusive or *) let rec logxor_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 <> index b 0) else append (create 1 (index a 0 <> index b 0)) (logxor_vec #(n - 1) (slice a 1 n) (slice b 1 n)) (** [logxor] defined in terms of its indexing behavior *) let rec logxor_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logxor_vec #n a b) i = (index a i <> index b i)) [SMTPat (index (logxor_vec #n a b) i)] = if i = 0 then () else logxor_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1) (** Bitwise logical or *) let rec logor_vec (#n: pos) (a b: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (index a 0 || index b 0) else append (create 1 (index a 0 || index b 0)) (logor_vec #(n - 1) (slice a 1 n) (slice b 1 n)) (** [logor] defined in terms of its indexing behavior *) let rec logor_vec_definition (#n: pos) (a b: bv_t n) (i: nat{i < n}) : Lemma (ensures index (logor_vec #n a b) i = (index a i || index b i)) [SMTPat (index (logor_vec #n a b) i)] = if i = 0 then () else logor_vec_definition #(n - 1) (slice a 1 n) (slice b 1 n) (i - 1) (** Bitwise negation *) let rec lognot_vec (#n: pos) (a: bv_t n) : Tot (bv_t n) = if n = 1 then create 1 (not (index a 0)) else append (create 1 (not (index a 0))) (lognot_vec #(n - 1) (slice a 1 n)) (** [lognot] defined in terms of its indexing behavior *) let rec lognot_vec_definition (#n: pos) (a: bv_t n) (i: nat{i < n}) : Lemma (ensures index (lognot_vec #n a) i = not (index a i)) [SMTPat (index (lognot_vec #n a) i)] = if i = 0 then () else lognot_vec_definition #(n - 1) (slice a 1 n) (i - 1) (* Bitwise lemmas *) (** If both [x] and [y] are false at a given index [i], then so is they logical xor at [i] *) let lemma_xor_bounded (m: pos) (n: nat) (x y: bv_t m) : Lemma (requires (forall (i: nat). (i < m /\ i >= n) ==> (Seq.index x (m - 1 - i) = false /\ Seq.index y (m - 1 - i) = false))) (ensures (forall (i: nat). (i < m /\ i >= n) ==> (Seq.index (logxor_vec x y) (m - 1 - i) = false))) = () (** The property that the zero bits of b are also zero in a. I.e. that a is a subset of b. *) let is_subset_vec (#n: pos) (a b: bv_t n) = forall (i: nat). i < n ==> index b i = false ==> index a i = false (** The property that the non-zero bits of b are also non-zero in a. I.e. that a is a superset of b. *) let is_superset_vec (#n: pos) (a b: bv_t n) = forall (i: nat). i < n ==> index b i = true ==> index a i = true (** Proves that the subset property is conserved in subslices. *) let lemma_slice_subset_vec (#n: pos) (a b: bv_t n) (i: nat) (j: nat{i < j && j <= n}) : Lemma (requires is_subset_vec a b) (ensures (match n with | 1 -> True | _ -> is_subset_vec #(j - i) (slice a i j) (slice b i j))) = () (** Proves that the superset property is conserved in subslices. *) let lemma_slice_superset_vec (#n: pos) (a b: bv_t n) (i: nat) (j: nat{i < j && j <= n}) : Lemma (requires is_superset_vec a b) (ensures (match n with | 1 -> True | _ -> is_superset_vec #(j - i) (slice a i j) (slice b i j))) = () (**** Shift operators *) (* Note: the shift amount is extracted as a bitvector NS: Not sure what this remark means. *) (** Shift [a] left by [s] bits, filling with zeroes *) let shift_left_vec (#n: pos) (a: bv_t n) (s: nat) : Tot (bv_t n) = if s >= n then zero_vec #n else if s = 0 then a else append (slice a s n) (zero_vec #s) (** The fill bits of a shift left are zero *) let shift_left_vec_lemma_1 (#n: pos) (a: bv_t n) (s: nat) (i: nat{i < n && i >= n - s}) : Lemma (ensures index (shift_left_vec #n a s) i = false) [SMTPat (index (shift_left_vec #n a s) i)] = () (** Relating the indexes of the shifted vector to the original *) let shift_left_vec_lemma_2 (#n: pos) (a: bv_t n) (s: nat) (i: nat{i < n && i < n - s}) : Lemma (ensures index (shift_left_vec #n a s) i = index a (i + s)) [SMTPat (index (shift_left_vec #n a s) i)] = () (** Shift [a] right by [s] bits, filling with zeroes *) let shift_right_vec (#n: pos) (a: bv_t n) (s: nat) : Tot (bv_t n) = if s >= n then zero_vec #n else if s = 0 then a else append (zero_vec #s) (slice a 0 (n - s)) (** The fill bits of a shift right are zero *) let shift_right_vec_lemma_1 (#n: pos) (a: bv_t n) (s: nat) (i: nat{i < n && i < s}) : Lemma (ensures index (shift_right_vec #n a s) i = false) [SMTPat (index (shift_right_vec #n a s) i)] = () (** Relating the indexes of the shifted vector to the original *) let shift_right_vec_lemma_2 (#n: pos) (a: bv_t n) (s: nat) (i: nat{i < n && i >= s}) : Lemma (ensures index (shift_right_vec #n a s) i = index a (i - s)) [SMTPat (index (shift_right_vec #n a s) i)] = () (** Arithmetic shift right of [a], interpreting position [0] as the
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.BitVector.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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
a: FStar.BitVector.bv_t n -> s: Prims.nat -> FStar.BitVector.bv_t n
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "FStar.BitVector.bv_t", "Prims.nat", "FStar.Seq.Base.index", "Prims.bool", "Prims.op_GreaterThanOrEqual", "FStar.BitVector.ones_vec", "Prims.op_Equality", "Prims.int", "FStar.Seq.Base.append", "FStar.Seq.Base.slice", "Prims.op_Subtraction", "FStar.BitVector.shift_right_vec" ]
[]
false
false
false
false
false
let shift_arithmetic_right_vec (#n: pos) (a: bv_t n) (s: nat) : Tot (bv_t n) =
if index a 0 then if s >= n then ones_vec #n else if s = 0 then a else append (ones_vec #s) (slice a 0 (n - s)) else shift_right_vec a s
false
Pulse.Soundness.Common.fst
Pulse.Soundness.Common.extend_env_l_lookup_fvar
val extend_env_l_lookup_fvar (g: R.env) (sg: env_bindings) (fv: R.fv) (us: R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)]
val extend_env_l_lookup_fvar (g: R.env) (sg: env_bindings) (fv: R.fv) (us: R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)]
let rec extend_env_l_lookup_fvar (g:R.env) (sg:env_bindings) (fv:R.fv) (us:R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] = match sg with | [] -> () | hd::tl -> extend_env_l_lookup_fvar g tl fv us
{ "file_name": "lib/steel/pulse/Pulse.Soundness.Common.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 51, "end_line": 38, "start_col": 0, "start_line": 30 }
(* 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.Soundness.Common module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Typing open Pulse.Elaborate let ln_comp = c:comp_st { ln_c c }
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Pulse.Soundness.Common.fst" }
[ { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: FStar.Stubs.Reflection.Types.env -> sg: Pulse.Typing.Env.env_bindings -> fv: FStar.Stubs.Reflection.Types.fv -> us: FStar.Stubs.Reflection.V2.Data.universes -> FStar.Pervasives.Lemma (ensures FStar.Reflection.Typing.lookup_fvar_uinst (Pulse.Typing.extend_env_l g sg) fv us == FStar.Reflection.Typing.lookup_fvar_uinst g fv us) [SMTPat (FStar.Reflection.Typing.lookup_fvar_uinst (Pulse.Typing.extend_env_l g sg) fv us)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Stubs.Reflection.Types.env", "Pulse.Typing.Env.env_bindings", "FStar.Stubs.Reflection.Types.fv", "FStar.Stubs.Reflection.V2.Data.universes", "Pulse.Typing.Env.binding", "Prims.list", "Pulse.Soundness.Common.extend_env_l_lookup_fvar", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.Pervasives.Native.option", "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.Typing.lookup_fvar_uinst", "Pulse.Typing.extend_env_l", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[ "recursion" ]
false
false
true
false
false
let rec extend_env_l_lookup_fvar (g: R.env) (sg: env_bindings) (fv: R.fv) (us: R.universes) : Lemma (ensures RT.lookup_fvar_uinst (extend_env_l g sg) fv us == RT.lookup_fvar_uinst g fv us) [SMTPat (RT.lookup_fvar_uinst (extend_env_l g sg) fv us)] =
match sg with | [] -> () | hd :: tl -> extend_env_l_lookup_fvar g tl fv us
false
Hacl.Impl.SHA3.fst
Hacl.Impl.SHA3.get
val get: s:state -> x:index -> y:index -> Stack uint64 (requires fun h -> live h s) (ensures fun h0 r h1 -> modifies loc_none h0 h1 /\ r == S.get (as_seq h0 s) (v x) (v y))
val get: s:state -> x:index -> y:index -> Stack uint64 (requires fun h -> live h s) (ensures fun h0 r h1 -> modifies loc_none h0 h1 /\ r == S.get (as_seq h0 s) (v x) (v y))
let get s x y = s.(x +! 5ul *! y)
{ "file_name": "code/sha3/Hacl.Impl.SHA3.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 33, "end_line": 52, "start_col": 0, "start_line": 52 }
module Hacl.Impl.SHA3 open FStar.HyperStack.All open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open LowStar.BufferOps open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Spec.SHA3.Constants module ST = FStar.HyperStack.ST module B = LowStar.Buffer module LSeq = Lib.Sequence module LB = Lib.ByteSequence module Loop = Lib.LoopCombinators module S = Spec.SHA3 module Equiv = Spec.SHA3.Equivalence private let keccak_rotc :x:glbuffer rotc_t 24ul{witnessed x keccak_rotc /\ recallable x} = createL_global rotc_list private let keccak_piln :x:glbuffer piln_t 24ul{witnessed x keccak_piln /\ recallable x} = createL_global piln_list private let keccak_rndc :x:glbuffer pub_uint64 24ul{witnessed x keccak_rndc /\ recallable x} = createL_global rndc_list #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq'" inline_for_extraction noextract let state = lbuffer uint64 25ul inline_for_extraction noextract let index = n:size_t{v n < 5} inline_for_extraction noextract val get: s:state -> x:index -> y:index -> Stack uint64 (requires fun h -> live h s) (ensures fun h0 r h1 -> modifies loc_none h0 h1 /\
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.Equivalence.fst.checked", "Spec.SHA3.Constants.fst.checked", "Spec.SHA3.fst.checked", "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA3.fst" }
[ { "abbrev": true, "full_module": "Spec.SHA3.Equivalence", "short_module": "Equiv" }, { "abbrev": true, "full_module": "Spec.SHA3", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loop" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "LB" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Spec.SHA3.Constants", "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": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "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
s: Hacl.Impl.SHA3.state -> x: Hacl.Impl.SHA3.index -> y: Hacl.Impl.SHA3.index -> FStar.HyperStack.ST.Stack Lib.IntTypes.uint64
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.SHA3.state", "Hacl.Impl.SHA3.index", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.IntTypes.op_Star_Bang" ]
[]
false
true
false
false
false
let get s x y =
s.(x +! 5ul *! y)
false
Hacl.Impl.SHA3.fst
Hacl.Impl.SHA3.state_theta1
val state_theta1: s:state -> _C:lbuffer uint64 5ul -> Stack unit (requires fun h0 -> live h0 s /\ live h0 _C /\ disjoint _C s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_theta1 (as_seq h0 s) (as_seq h0 _C))
val state_theta1: s:state -> _C:lbuffer uint64 5ul -> Stack unit (requires fun h0 -> live h0 s /\ live h0 _C /\ disjoint _C s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_theta1 (as_seq h0 s) (as_seq h0 _C))
let state_theta1 s _C = [@ inline_let] let spec h0 = S.state_theta_inner_s (as_seq h0 _C) in let h0 = ST.get () in loop1 h0 5ul s spec (fun x -> Loop.unfold_repeati 5 (spec h0) (as_seq h0 s) (v x); state_theta_inner_s _C x s )
{ "file_name": "code/sha3/Hacl.Impl.SHA3.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 133, "start_col": 0, "start_line": 125 }
module Hacl.Impl.SHA3 open FStar.HyperStack.All open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open LowStar.BufferOps open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Spec.SHA3.Constants module ST = FStar.HyperStack.ST module B = LowStar.Buffer module LSeq = Lib.Sequence module LB = Lib.ByteSequence module Loop = Lib.LoopCombinators module S = Spec.SHA3 module Equiv = Spec.SHA3.Equivalence private let keccak_rotc :x:glbuffer rotc_t 24ul{witnessed x keccak_rotc /\ recallable x} = createL_global rotc_list private let keccak_piln :x:glbuffer piln_t 24ul{witnessed x keccak_piln /\ recallable x} = createL_global piln_list private let keccak_rndc :x:glbuffer pub_uint64 24ul{witnessed x keccak_rndc /\ recallable x} = createL_global rndc_list #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq'" inline_for_extraction noextract let state = lbuffer uint64 25ul inline_for_extraction noextract let index = n:size_t{v n < 5} inline_for_extraction noextract val get: s:state -> x:index -> y:index -> Stack uint64 (requires fun h -> live h s) (ensures fun h0 r h1 -> modifies loc_none h0 h1 /\ r == S.get (as_seq h0 s) (v x) (v y)) let get s x y = s.(x +! 5ul *! y) inline_for_extraction noextract val set: s:state -> x:index -> y:index -> v:uint64 -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.set (as_seq h0 s) (size_v x) (size_v y) v) let set s x y v = s.(x +! 5ul *! y) <- v inline_for_extraction noextract let rotl (a:uint64) (b:size_t{0 < uint_v b /\ uint_v b < 64}) = rotate_left a b inline_for_extraction noextract val state_theta0: s:state -> _C:lbuffer uint64 5ul -> Stack unit (requires fun h -> live h s /\ live h _C /\ disjoint _C s) (ensures fun h0 _ h1 -> modifies (loc _C) h0 h1 /\ as_seq h1 _C == S.state_theta0 (as_seq h0 s) (as_seq h0 _C)) let state_theta0 s _C = [@ inline_let] let spec h0 = S.state_theta_inner_C (as_seq h0 s) in let h0 = ST.get () in loop1 h0 5ul _C spec (fun x -> Loop.unfold_repeati 5 (spec h0) (as_seq h0 _C) (v x); _C.(x) <- get s x 0ul ^. get s x 1ul ^. get s x 2ul ^. get s x 3ul ^. get s x 4ul ) inline_for_extraction noextract val state_theta_inner_s: _C:lbuffer uint64 5ul -> x:index -> s:state -> Stack unit (requires fun h0 -> live h0 s /\ live h0 _C /\ disjoint _C s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_theta_inner_s (as_seq h0 _C) (v x) (as_seq h0 s)) let state_theta_inner_s _C x s = let _D = _C.((x +. 4ul) %. 5ul) ^. rotl _C.((x +. 1ul) %. 5ul) 1ul in [@ inline_let] let spec h0 = S.state_theta_inner_s_inner (v x) _D in let h0 = ST.get () in loop1 h0 5ul s spec (fun y -> Loop.unfold_repeati 5 (spec h0) (as_seq h0 s) (v y); set s x y (get s x y ^. _D) ) inline_for_extraction noextract val state_theta1: s:state -> _C:lbuffer uint64 5ul -> Stack unit (requires fun h0 -> live h0 s /\ live h0 _C /\ disjoint _C s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.Equivalence.fst.checked", "Spec.SHA3.Constants.fst.checked", "Spec.SHA3.fst.checked", "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA3.fst" }
[ { "abbrev": true, "full_module": "Spec.SHA3.Equivalence", "short_module": "Equiv" }, { "abbrev": true, "full_module": "Spec.SHA3", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loop" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "LB" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Spec.SHA3.Constants", "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": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "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
s: Hacl.Impl.SHA3.state -> _C: Lib.Buffer.lbuffer Lib.IntTypes.uint64 5ul -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.SHA3.state", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Lib.Buffer.loop1", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.SHA3.state_theta_inner_s", "Prims.unit", "Lib.LoopCombinators.unfold_repeati", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Prims.nat", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Spec.SHA3.state_theta_inner_s" ]
[]
false
true
false
false
false
let state_theta1 s _C =
[@@ inline_let ]let spec h0 = S.state_theta_inner_s (as_seq h0 _C) in let h0 = ST.get () in loop1 h0 5ul s spec (fun x -> Loop.unfold_repeati 5 (spec h0) (as_seq h0 s) (v x); state_theta_inner_s _C x s)
false
Hacl.Impl.SHA3.fst
Hacl.Impl.SHA3.state_permute
val state_permute: s:state -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_permute (as_seq h0 s))
val state_permute: s:state -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_permute (as_seq h0 s))
let state_permute s = [@ inline_let] let spec h0 = S.state_permute1 in let h0 = ST.get () in loop1 h0 24ul s spec (fun round -> Loop.unfold_repeati 24 (spec h0) (as_seq h0 s) (v round); state_theta s; state_pi_rho s; state_chi s; state_iota s round)
{ "file_name": "code/sha3/Hacl.Impl.SHA3.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 23, "end_line": 297, "start_col": 0, "start_line": 287 }
module Hacl.Impl.SHA3 open FStar.HyperStack.All open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open LowStar.BufferOps open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Spec.SHA3.Constants module ST = FStar.HyperStack.ST module B = LowStar.Buffer module LSeq = Lib.Sequence module LB = Lib.ByteSequence module Loop = Lib.LoopCombinators module S = Spec.SHA3 module Equiv = Spec.SHA3.Equivalence private let keccak_rotc :x:glbuffer rotc_t 24ul{witnessed x keccak_rotc /\ recallable x} = createL_global rotc_list private let keccak_piln :x:glbuffer piln_t 24ul{witnessed x keccak_piln /\ recallable x} = createL_global piln_list private let keccak_rndc :x:glbuffer pub_uint64 24ul{witnessed x keccak_rndc /\ recallable x} = createL_global rndc_list #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq'" inline_for_extraction noextract let state = lbuffer uint64 25ul inline_for_extraction noextract let index = n:size_t{v n < 5} inline_for_extraction noextract val get: s:state -> x:index -> y:index -> Stack uint64 (requires fun h -> live h s) (ensures fun h0 r h1 -> modifies loc_none h0 h1 /\ r == S.get (as_seq h0 s) (v x) (v y)) let get s x y = s.(x +! 5ul *! y) inline_for_extraction noextract val set: s:state -> x:index -> y:index -> v:uint64 -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.set (as_seq h0 s) (size_v x) (size_v y) v) let set s x y v = s.(x +! 5ul *! y) <- v inline_for_extraction noextract let rotl (a:uint64) (b:size_t{0 < uint_v b /\ uint_v b < 64}) = rotate_left a b inline_for_extraction noextract val state_theta0: s:state -> _C:lbuffer uint64 5ul -> Stack unit (requires fun h -> live h s /\ live h _C /\ disjoint _C s) (ensures fun h0 _ h1 -> modifies (loc _C) h0 h1 /\ as_seq h1 _C == S.state_theta0 (as_seq h0 s) (as_seq h0 _C)) let state_theta0 s _C = [@ inline_let] let spec h0 = S.state_theta_inner_C (as_seq h0 s) in let h0 = ST.get () in loop1 h0 5ul _C spec (fun x -> Loop.unfold_repeati 5 (spec h0) (as_seq h0 _C) (v x); _C.(x) <- get s x 0ul ^. get s x 1ul ^. get s x 2ul ^. get s x 3ul ^. get s x 4ul ) inline_for_extraction noextract val state_theta_inner_s: _C:lbuffer uint64 5ul -> x:index -> s:state -> Stack unit (requires fun h0 -> live h0 s /\ live h0 _C /\ disjoint _C s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_theta_inner_s (as_seq h0 _C) (v x) (as_seq h0 s)) let state_theta_inner_s _C x s = let _D = _C.((x +. 4ul) %. 5ul) ^. rotl _C.((x +. 1ul) %. 5ul) 1ul in [@ inline_let] let spec h0 = S.state_theta_inner_s_inner (v x) _D in let h0 = ST.get () in loop1 h0 5ul s spec (fun y -> Loop.unfold_repeati 5 (spec h0) (as_seq h0 s) (v y); set s x y (get s x y ^. _D) ) inline_for_extraction noextract val state_theta1: s:state -> _C:lbuffer uint64 5ul -> Stack unit (requires fun h0 -> live h0 s /\ live h0 _C /\ disjoint _C s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_theta1 (as_seq h0 s) (as_seq h0 _C)) let state_theta1 s _C = [@ inline_let] let spec h0 = S.state_theta_inner_s (as_seq h0 _C) in let h0 = ST.get () in loop1 h0 5ul s spec (fun x -> Loop.unfold_repeati 5 (spec h0) (as_seq h0 s) (v x); state_theta_inner_s _C x s ) inline_for_extraction noextract val state_theta: s:state -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_theta (as_seq h0 s)) let state_theta s = push_frame (); let h0 = ST.get() in let _C = create 5ul (u64 0) in state_theta0 s _C; state_theta1 s _C; pop_frame() #reset-options "--max_fuel 1 --max_ifuel 1 --z3rlimit 50" private val index_map: #a:Type -> #b:Type -> f:(a -> b) -> l:list a -> i:nat{i < List.Tot.length l} -> Lemma (List.Tot.index (List.Tot.map f l) i == f (List.Tot.index l i)) let rec index_map #a #b f l i = if i = 0 then () else match l with | [] -> () | _ :: l' -> index_map f l' (i - 1) #reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" inline_for_extraction noextract val state_pi_rho_inner: i:size_t{v i < 24} -> current:lbuffer uint64 1ul -> s:state -> Stack unit (requires fun h -> live h s /\ live h current /\ disjoint current s) (ensures fun h0 _ h1 -> modifies (loc_union (loc s) (loc current)) h0 h1 /\ (let c', s' = S.state_pi_rho_inner (v i) (bget h0 current 0, as_seq h0 s) in bget h1 current 0 == c' /\ as_seq h1 s == s')) let state_pi_rho_inner i current s = assert_norm (List.Tot.length piln_list == 24); let h0 = ST.get () in recall_contents keccak_rotc Spec.SHA3.Constants.keccak_rotc; recall_contents keccak_piln Spec.SHA3.Constants.keccak_piln; index_map v piln_list (v i); let _Y = keccak_piln.(i) in let r = keccak_rotc.(i) in let temp = s.(_Y) in s.(_Y) <- rotl current.(0ul) r; current.(0ul) <- temp inline_for_extraction noextract val state_pi_rho: s:state -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_pi_rho (as_seq h0 s)) let state_pi_rho s = push_frame(); let x = get s 1ul 0ul in let h0 = ST.get() in let current = create 1ul x in let h1 = ST.get () in assert (bget h1 current 0 == S.get (as_seq h0 s) 1 0); [@ inline_let] let refl h i : GTot (uint64 & S.state) = bget h current 0, as_seq h s in [@ inline_let] let footprint i = loc_union (loc current) (loc s) in [@ inline_let] let spec h0 = S.state_pi_rho_inner in let h0 = ST.get () in loop h0 24ul S.state_pi_rho_s refl footprint spec (fun i -> Loop.unfold_repeat_gen 24 S.state_pi_rho_s (spec h0) (refl h0 0) (v i); state_pi_rho_inner i current s ); pop_frame() inline_for_extraction noextract val state_chi_inner: st:state -> y:index -> Stack unit (requires fun h0 -> live h0 st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Equiv.state_chi_inner (v y) (as_seq h0 st)) let state_chi_inner st y = let h0 = ST.get() in let v0 = get st 0ul y ^. ((lognot (get st 1ul y)) &. get st 2ul y) in let v1 = get st 1ul y ^. ((lognot (get st 2ul y)) &. get st 3ul y) in let v2 = get st 2ul y ^. ((lognot (get st 3ul y)) &. get st 4ul y) in let v3 = get st 3ul y ^. ((lognot (get st 4ul y)) &. get st 0ul y) in let v4 = get st 4ul y ^. ((lognot (get st 0ul y)) &. get st 1ul y) in set st 0ul y v0; set st 1ul y v1; set st 2ul y v2; set st 3ul y v3; set st 4ul y v4; let h1 = ST.get() in assert (modifies (loc st) h0 h1); assert (as_seq h1 st == Equiv.state_chi_inner (v y) (as_seq h0 st)) inline_for_extraction noextract val state_chi: s:state -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_chi (as_seq h0 s)) let state_chi st = let h0 = ST.get() in [@ inline_let] let spec h0 = Equiv.state_chi_inner in let h0 = ST.get () in loop1 h0 5ul st spec (fun y -> Loop.unfold_repeati 5 (spec h0) (as_seq h0 st) (v y); state_chi_inner st y ); let h1 = ST.get() in assert(as_seq h1 st == Equiv.state_chi (as_seq h0 st)); Equiv.state_chi_equivalence (as_seq h0 st) inline_for_extraction noextract val state_iota: s:state -> round:size_t{v round < 24} -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_iota (as_seq h0 s) (v round)) let state_iota s round = recall_contents keccak_rndc Spec.SHA3.Constants.keccak_rndc; let c = keccak_rndc.(round) in set s 0ul 0ul (get s 0ul 0ul ^. secret c) private val state_permute: s:state -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.Equivalence.fst.checked", "Spec.SHA3.Constants.fst.checked", "Spec.SHA3.fst.checked", "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA3.fst" }
[ { "abbrev": true, "full_module": "Spec.SHA3.Equivalence", "short_module": "Equiv" }, { "abbrev": true, "full_module": "Spec.SHA3", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loop" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "LB" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Spec.SHA3.Constants", "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": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "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
s: Hacl.Impl.SHA3.state -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.SHA3.state", "Lib.Buffer.loop1", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.SHA3.state_iota", "Prims.unit", "Hacl.Impl.SHA3.state_chi", "Hacl.Impl.SHA3.state_pi_rho", "Hacl.Impl.SHA3.state_theta", "Lib.LoopCombinators.unfold_repeati", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Prims.nat", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Spec.SHA3.state_permute1" ]
[]
false
true
false
false
false
let state_permute s =
[@@ inline_let ]let spec h0 = S.state_permute1 in let h0 = ST.get () in loop1 h0 24ul s spec (fun round -> Loop.unfold_repeati 24 (spec h0) (as_seq h0 s) (v round); state_theta s; state_pi_rho s; state_chi s; state_iota s round)
false
Hacl.Impl.SHA3.fst
Hacl.Impl.SHA3.mult_plus_lt
val mult_plus_lt (i a b: nat) : Lemma (requires i < a) (ensures i * b + b <= a * b)
val mult_plus_lt (i a b: nat) : Lemma (requires i < a) (ensures i * b + b <= a * b)
let mult_plus_lt (i a b:nat) : Lemma (requires i < a) (ensures i * b + b <= a * b) = assert (i <= a - 1)
{ "file_name": "code/sha3/Hacl.Impl.SHA3.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 21, "end_line": 479, "start_col": 0, "start_line": 478 }
module Hacl.Impl.SHA3 open FStar.HyperStack.All open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open LowStar.BufferOps open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Spec.SHA3.Constants module ST = FStar.HyperStack.ST module B = LowStar.Buffer module LSeq = Lib.Sequence module LB = Lib.ByteSequence module Loop = Lib.LoopCombinators module S = Spec.SHA3 module Equiv = Spec.SHA3.Equivalence private let keccak_rotc :x:glbuffer rotc_t 24ul{witnessed x keccak_rotc /\ recallable x} = createL_global rotc_list private let keccak_piln :x:glbuffer piln_t 24ul{witnessed x keccak_piln /\ recallable x} = createL_global piln_list private let keccak_rndc :x:glbuffer pub_uint64 24ul{witnessed x keccak_rndc /\ recallable x} = createL_global rndc_list #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq'" inline_for_extraction noextract let state = lbuffer uint64 25ul inline_for_extraction noextract let index = n:size_t{v n < 5} inline_for_extraction noextract val get: s:state -> x:index -> y:index -> Stack uint64 (requires fun h -> live h s) (ensures fun h0 r h1 -> modifies loc_none h0 h1 /\ r == S.get (as_seq h0 s) (v x) (v y)) let get s x y = s.(x +! 5ul *! y) inline_for_extraction noextract val set: s:state -> x:index -> y:index -> v:uint64 -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.set (as_seq h0 s) (size_v x) (size_v y) v) let set s x y v = s.(x +! 5ul *! y) <- v inline_for_extraction noextract let rotl (a:uint64) (b:size_t{0 < uint_v b /\ uint_v b < 64}) = rotate_left a b inline_for_extraction noextract val state_theta0: s:state -> _C:lbuffer uint64 5ul -> Stack unit (requires fun h -> live h s /\ live h _C /\ disjoint _C s) (ensures fun h0 _ h1 -> modifies (loc _C) h0 h1 /\ as_seq h1 _C == S.state_theta0 (as_seq h0 s) (as_seq h0 _C)) let state_theta0 s _C = [@ inline_let] let spec h0 = S.state_theta_inner_C (as_seq h0 s) in let h0 = ST.get () in loop1 h0 5ul _C spec (fun x -> Loop.unfold_repeati 5 (spec h0) (as_seq h0 _C) (v x); _C.(x) <- get s x 0ul ^. get s x 1ul ^. get s x 2ul ^. get s x 3ul ^. get s x 4ul ) inline_for_extraction noextract val state_theta_inner_s: _C:lbuffer uint64 5ul -> x:index -> s:state -> Stack unit (requires fun h0 -> live h0 s /\ live h0 _C /\ disjoint _C s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_theta_inner_s (as_seq h0 _C) (v x) (as_seq h0 s)) let state_theta_inner_s _C x s = let _D = _C.((x +. 4ul) %. 5ul) ^. rotl _C.((x +. 1ul) %. 5ul) 1ul in [@ inline_let] let spec h0 = S.state_theta_inner_s_inner (v x) _D in let h0 = ST.get () in loop1 h0 5ul s spec (fun y -> Loop.unfold_repeati 5 (spec h0) (as_seq h0 s) (v y); set s x y (get s x y ^. _D) ) inline_for_extraction noextract val state_theta1: s:state -> _C:lbuffer uint64 5ul -> Stack unit (requires fun h0 -> live h0 s /\ live h0 _C /\ disjoint _C s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_theta1 (as_seq h0 s) (as_seq h0 _C)) let state_theta1 s _C = [@ inline_let] let spec h0 = S.state_theta_inner_s (as_seq h0 _C) in let h0 = ST.get () in loop1 h0 5ul s spec (fun x -> Loop.unfold_repeati 5 (spec h0) (as_seq h0 s) (v x); state_theta_inner_s _C x s ) inline_for_extraction noextract val state_theta: s:state -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_theta (as_seq h0 s)) let state_theta s = push_frame (); let h0 = ST.get() in let _C = create 5ul (u64 0) in state_theta0 s _C; state_theta1 s _C; pop_frame() #reset-options "--max_fuel 1 --max_ifuel 1 --z3rlimit 50" private val index_map: #a:Type -> #b:Type -> f:(a -> b) -> l:list a -> i:nat{i < List.Tot.length l} -> Lemma (List.Tot.index (List.Tot.map f l) i == f (List.Tot.index l i)) let rec index_map #a #b f l i = if i = 0 then () else match l with | [] -> () | _ :: l' -> index_map f l' (i - 1) #reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" inline_for_extraction noextract val state_pi_rho_inner: i:size_t{v i < 24} -> current:lbuffer uint64 1ul -> s:state -> Stack unit (requires fun h -> live h s /\ live h current /\ disjoint current s) (ensures fun h0 _ h1 -> modifies (loc_union (loc s) (loc current)) h0 h1 /\ (let c', s' = S.state_pi_rho_inner (v i) (bget h0 current 0, as_seq h0 s) in bget h1 current 0 == c' /\ as_seq h1 s == s')) let state_pi_rho_inner i current s = assert_norm (List.Tot.length piln_list == 24); let h0 = ST.get () in recall_contents keccak_rotc Spec.SHA3.Constants.keccak_rotc; recall_contents keccak_piln Spec.SHA3.Constants.keccak_piln; index_map v piln_list (v i); let _Y = keccak_piln.(i) in let r = keccak_rotc.(i) in let temp = s.(_Y) in s.(_Y) <- rotl current.(0ul) r; current.(0ul) <- temp inline_for_extraction noextract val state_pi_rho: s:state -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_pi_rho (as_seq h0 s)) let state_pi_rho s = push_frame(); let x = get s 1ul 0ul in let h0 = ST.get() in let current = create 1ul x in let h1 = ST.get () in assert (bget h1 current 0 == S.get (as_seq h0 s) 1 0); [@ inline_let] let refl h i : GTot (uint64 & S.state) = bget h current 0, as_seq h s in [@ inline_let] let footprint i = loc_union (loc current) (loc s) in [@ inline_let] let spec h0 = S.state_pi_rho_inner in let h0 = ST.get () in loop h0 24ul S.state_pi_rho_s refl footprint spec (fun i -> Loop.unfold_repeat_gen 24 S.state_pi_rho_s (spec h0) (refl h0 0) (v i); state_pi_rho_inner i current s ); pop_frame() inline_for_extraction noextract val state_chi_inner: st:state -> y:index -> Stack unit (requires fun h0 -> live h0 st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Equiv.state_chi_inner (v y) (as_seq h0 st)) let state_chi_inner st y = let h0 = ST.get() in let v0 = get st 0ul y ^. ((lognot (get st 1ul y)) &. get st 2ul y) in let v1 = get st 1ul y ^. ((lognot (get st 2ul y)) &. get st 3ul y) in let v2 = get st 2ul y ^. ((lognot (get st 3ul y)) &. get st 4ul y) in let v3 = get st 3ul y ^. ((lognot (get st 4ul y)) &. get st 0ul y) in let v4 = get st 4ul y ^. ((lognot (get st 0ul y)) &. get st 1ul y) in set st 0ul y v0; set st 1ul y v1; set st 2ul y v2; set st 3ul y v3; set st 4ul y v4; let h1 = ST.get() in assert (modifies (loc st) h0 h1); assert (as_seq h1 st == Equiv.state_chi_inner (v y) (as_seq h0 st)) inline_for_extraction noextract val state_chi: s:state -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_chi (as_seq h0 s)) let state_chi st = let h0 = ST.get() in [@ inline_let] let spec h0 = Equiv.state_chi_inner in let h0 = ST.get () in loop1 h0 5ul st spec (fun y -> Loop.unfold_repeati 5 (spec h0) (as_seq h0 st) (v y); state_chi_inner st y ); let h1 = ST.get() in assert(as_seq h1 st == Equiv.state_chi (as_seq h0 st)); Equiv.state_chi_equivalence (as_seq h0 st) inline_for_extraction noextract val state_iota: s:state -> round:size_t{v round < 24} -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_iota (as_seq h0 s) (v round)) let state_iota s round = recall_contents keccak_rndc Spec.SHA3.Constants.keccak_rndc; let c = keccak_rndc.(round) in set s 0ul 0ul (get s 0ul 0ul ^. secret c) private val state_permute: s:state -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_permute (as_seq h0 s)) let state_permute s = [@ inline_let] let spec h0 = S.state_permute1 in let h0 = ST.get () in loop1 h0 24ul s spec (fun round -> Loop.unfold_repeati 24 (spec h0) (as_seq h0 s) (v round); state_theta s; state_pi_rho s; state_chi s; state_iota s round) private val loadState: rateInBytes:size_t{v rateInBytes <= 200} -> input:lbuffer uint8 rateInBytes -> s:state -> Stack unit (requires fun h -> live h input /\ live h s /\ disjoint input s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.loadState (v rateInBytes) (as_seq h0 input) (as_seq h0 s)) let loadState rateInBytes input s = push_frame(); let h0 = ST.get() in let block = create 200ul (u8 0) in update_sub block 0ul rateInBytes input; [@ inline_let] let spec h0 = S.loadState_inner (as_seq h0 block) in let h0 = ST.get () in loop1 h0 25ul s spec (fun j -> Loop.unfold_repeati 25 (spec h0) (as_seq h0 s) (v j); let h0 = ST.get() in let x = uint_from_bytes_le #U64 (sub block (j *! 8ul) 8ul) in s.(j) <- s.(j) ^. x ); pop_frame() inline_for_extraction noextract val storeState_inner: s:state -> j:size_t{v j < 25} -> block:lbuffer uint8 200ul -> Stack unit (requires fun h0 -> live h0 s /\ live h0 block /\ disjoint s block) (ensures fun h0 _ h1 -> modifies (loc block) h0 h1 /\ as_seq h1 block == S.storeState_inner (as_seq h0 s) (v j) (as_seq h0 block)) let storeState_inner s j block = let sj = s.(j) in let h0 = ST.get () in update_sub_f h0 block (j *! 8ul) 8ul (fun h -> Lib.ByteSequence.uint_to_bytes_le sj) (fun _ -> uint_to_bytes_le #U64 (sub block (j *! 8ul) 8ul) sj) private val storeState: rateInBytes:size_t{v rateInBytes <= 200} -> s:state -> res:lbuffer uint8 rateInBytes -> Stack unit (requires fun h0 -> live h0 s /\ live h0 res) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.storeState (v rateInBytes) (as_seq h0 s)) let storeState rateInBytes s res = push_frame(); let h0 = ST.get() in let block = create 200ul (u8 0) in [@ inline_let] let spec h0 = S.storeState_inner (as_seq h0 s) in let h0 = ST.get () in loop1 h0 25ul block spec (fun j -> Loop.unfold_repeati 25 (spec h0) (as_seq h0 block) (v j); storeState_inner s j block ); copy res (sub block 0ul rateInBytes); pop_frame() #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract val absorb_next: s:state -> rateInBytes:size_t{v rateInBytes > 0 /\ v rateInBytes <= 200} -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.absorb_next (as_seq h0 s) (v rateInBytes)) let absorb_next s rateInBytes = push_frame(); let h0 = ST.get() in let nextBlock_ = create 200ul (u8 0) in let nextBlock = sub nextBlock_ 0ul rateInBytes in let h1 = ST.get () in assert (as_seq h1 nextBlock `Seq.equal` Lib.Sequence.create (v rateInBytes) (u8 0)); nextBlock.(rateInBytes -! 1ul) <- u8 0x80; loadState rateInBytes nextBlock s; state_permute s; pop_frame() inline_for_extraction noextract val absorb_last: delimitedSuffix:byte_t -> rateInBytes:size_t{0 < v rateInBytes /\ v rateInBytes <= 200} -> rem:size_t{v rem < v rateInBytes} -> input:lbuffer uint8 rem -> s:state -> Stack unit (requires fun h -> live h s /\ live h input /\ disjoint s input) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.absorb_last delimitedSuffix (v rateInBytes) (v rem) (as_seq h0 input) (as_seq h0 s)) let absorb_last delimitedSuffix rateInBytes rem input s = push_frame(); let h0 = ST.get() in let lastBlock_ = create 200ul (u8 0) in let lastBlock = sub lastBlock_ 0ul rateInBytes in let h1 = ST.get () in assert (as_seq h1 lastBlock `Seq.equal` Lib.Sequence.create (v rateInBytes) (u8 0)); let open Lib.RawIntTypes in update_sub lastBlock (size 0) rem input; lastBlock.(rem) <- byte_to_uint8 delimitedSuffix; loadState rateInBytes lastBlock s; if not ((delimitedSuffix &. byte 0x80) =. byte 0) && (size_to_UInt32 rem = size_to_UInt32 (rateInBytes -. 1ul)) then state_permute s; absorb_next s rateInBytes; pop_frame() val absorb_inner: rateInBytes:size_t{0 < v rateInBytes /\ v rateInBytes <= 200} -> block:lbuffer uint8 rateInBytes -> s:state -> Stack unit (requires fun h0 -> live h0 s /\ live h0 block /\ disjoint s block) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.absorb_inner (v rateInBytes) (as_seq h0 block) (as_seq h0 s)) let absorb_inner rateInBytes block s = loadState rateInBytes block s; state_permute s #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0" private val absorb: s:state -> rateInBytes:size_t{0 < v rateInBytes /\ v rateInBytes <= 200} -> inputByteLen:size_t -> input:lbuffer uint8 inputByteLen -> delimitedSuffix:byte_t -> Stack unit (requires fun h0 -> live h0 s /\ live h0 input /\ disjoint s input) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.absorb (as_seq h0 s) (v rateInBytes) (v inputByteLen) (as_seq h0 input) delimitedSuffix) let absorb s rateInBytes inputByteLen input delimitedSuffix = let n_blocks = inputByteLen /. rateInBytes in let rem = inputByteLen %. rateInBytes in loop_blocks rateInBytes n_blocks rem input (S.absorb_inner (v rateInBytes)) (S.absorb_last delimitedSuffix (v rateInBytes)) (absorb_inner rateInBytes) (absorb_last delimitedSuffix rateInBytes) s inline_for_extraction noextract val squeeze_inner: rateInBytes:size_t{0 < v rateInBytes /\ v rateInBytes <= 200} -> outputByteLen:size_t -> s:state -> output:lbuffer uint8 rateInBytes -> i:size_t{v i < v (outputByteLen /. rateInBytes)} -> Stack unit (requires fun h0 -> live h0 s /\ live h0 output /\ disjoint s output) (ensures fun h0 _ h1 -> modifies2 s output h0 h1 /\ (as_seq h1 s, as_seq h1 output) == S.squeeze_inner (v rateInBytes) (v outputByteLen) (v i) (as_seq h0 s)) let squeeze_inner rateInBytes outputByteLen s output i = storeState rateInBytes s output; state_permute s
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.Equivalence.fst.checked", "Spec.SHA3.Constants.fst.checked", "Spec.SHA3.fst.checked", "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA3.fst" }
[ { "abbrev": true, "full_module": "Spec.SHA3.Equivalence", "short_module": "Equiv" }, { "abbrev": true, "full_module": "Spec.SHA3", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loop" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "LB" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Spec.SHA3.Constants", "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": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "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
i: Prims.nat -> a: Prims.nat -> b: Prims.nat -> FStar.Pervasives.Lemma (requires i < a) (ensures i * b + b <= a * b)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.nat", "Prims._assert", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.unit", "Prims.op_LessThan", "Prims.squash", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let mult_plus_lt (i a b: nat) : Lemma (requires i < a) (ensures i * b + b <= a * b) =
assert (i <= a - 1)
false
Hacl.Impl.SHA3.fst
Hacl.Impl.SHA3.state_iota
val state_iota: s:state -> round:size_t{v round < 24} -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_iota (as_seq h0 s) (v round))
val state_iota: s:state -> round:size_t{v round < 24} -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_iota (as_seq h0 s) (v round))
let state_iota s round = recall_contents keccak_rndc Spec.SHA3.Constants.keccak_rndc; let c = keccak_rndc.(round) in set s 0ul 0ul (get s 0ul 0ul ^. secret c)
{ "file_name": "code/sha3/Hacl.Impl.SHA3.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 43, "end_line": 278, "start_col": 0, "start_line": 275 }
module Hacl.Impl.SHA3 open FStar.HyperStack.All open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open LowStar.BufferOps open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Spec.SHA3.Constants module ST = FStar.HyperStack.ST module B = LowStar.Buffer module LSeq = Lib.Sequence module LB = Lib.ByteSequence module Loop = Lib.LoopCombinators module S = Spec.SHA3 module Equiv = Spec.SHA3.Equivalence private let keccak_rotc :x:glbuffer rotc_t 24ul{witnessed x keccak_rotc /\ recallable x} = createL_global rotc_list private let keccak_piln :x:glbuffer piln_t 24ul{witnessed x keccak_piln /\ recallable x} = createL_global piln_list private let keccak_rndc :x:glbuffer pub_uint64 24ul{witnessed x keccak_rndc /\ recallable x} = createL_global rndc_list #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq'" inline_for_extraction noextract let state = lbuffer uint64 25ul inline_for_extraction noextract let index = n:size_t{v n < 5} inline_for_extraction noextract val get: s:state -> x:index -> y:index -> Stack uint64 (requires fun h -> live h s) (ensures fun h0 r h1 -> modifies loc_none h0 h1 /\ r == S.get (as_seq h0 s) (v x) (v y)) let get s x y = s.(x +! 5ul *! y) inline_for_extraction noextract val set: s:state -> x:index -> y:index -> v:uint64 -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.set (as_seq h0 s) (size_v x) (size_v y) v) let set s x y v = s.(x +! 5ul *! y) <- v inline_for_extraction noextract let rotl (a:uint64) (b:size_t{0 < uint_v b /\ uint_v b < 64}) = rotate_left a b inline_for_extraction noextract val state_theta0: s:state -> _C:lbuffer uint64 5ul -> Stack unit (requires fun h -> live h s /\ live h _C /\ disjoint _C s) (ensures fun h0 _ h1 -> modifies (loc _C) h0 h1 /\ as_seq h1 _C == S.state_theta0 (as_seq h0 s) (as_seq h0 _C)) let state_theta0 s _C = [@ inline_let] let spec h0 = S.state_theta_inner_C (as_seq h0 s) in let h0 = ST.get () in loop1 h0 5ul _C spec (fun x -> Loop.unfold_repeati 5 (spec h0) (as_seq h0 _C) (v x); _C.(x) <- get s x 0ul ^. get s x 1ul ^. get s x 2ul ^. get s x 3ul ^. get s x 4ul ) inline_for_extraction noextract val state_theta_inner_s: _C:lbuffer uint64 5ul -> x:index -> s:state -> Stack unit (requires fun h0 -> live h0 s /\ live h0 _C /\ disjoint _C s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_theta_inner_s (as_seq h0 _C) (v x) (as_seq h0 s)) let state_theta_inner_s _C x s = let _D = _C.((x +. 4ul) %. 5ul) ^. rotl _C.((x +. 1ul) %. 5ul) 1ul in [@ inline_let] let spec h0 = S.state_theta_inner_s_inner (v x) _D in let h0 = ST.get () in loop1 h0 5ul s spec (fun y -> Loop.unfold_repeati 5 (spec h0) (as_seq h0 s) (v y); set s x y (get s x y ^. _D) ) inline_for_extraction noextract val state_theta1: s:state -> _C:lbuffer uint64 5ul -> Stack unit (requires fun h0 -> live h0 s /\ live h0 _C /\ disjoint _C s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_theta1 (as_seq h0 s) (as_seq h0 _C)) let state_theta1 s _C = [@ inline_let] let spec h0 = S.state_theta_inner_s (as_seq h0 _C) in let h0 = ST.get () in loop1 h0 5ul s spec (fun x -> Loop.unfold_repeati 5 (spec h0) (as_seq h0 s) (v x); state_theta_inner_s _C x s ) inline_for_extraction noextract val state_theta: s:state -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_theta (as_seq h0 s)) let state_theta s = push_frame (); let h0 = ST.get() in let _C = create 5ul (u64 0) in state_theta0 s _C; state_theta1 s _C; pop_frame() #reset-options "--max_fuel 1 --max_ifuel 1 --z3rlimit 50" private val index_map: #a:Type -> #b:Type -> f:(a -> b) -> l:list a -> i:nat{i < List.Tot.length l} -> Lemma (List.Tot.index (List.Tot.map f l) i == f (List.Tot.index l i)) let rec index_map #a #b f l i = if i = 0 then () else match l with | [] -> () | _ :: l' -> index_map f l' (i - 1) #reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" inline_for_extraction noextract val state_pi_rho_inner: i:size_t{v i < 24} -> current:lbuffer uint64 1ul -> s:state -> Stack unit (requires fun h -> live h s /\ live h current /\ disjoint current s) (ensures fun h0 _ h1 -> modifies (loc_union (loc s) (loc current)) h0 h1 /\ (let c', s' = S.state_pi_rho_inner (v i) (bget h0 current 0, as_seq h0 s) in bget h1 current 0 == c' /\ as_seq h1 s == s')) let state_pi_rho_inner i current s = assert_norm (List.Tot.length piln_list == 24); let h0 = ST.get () in recall_contents keccak_rotc Spec.SHA3.Constants.keccak_rotc; recall_contents keccak_piln Spec.SHA3.Constants.keccak_piln; index_map v piln_list (v i); let _Y = keccak_piln.(i) in let r = keccak_rotc.(i) in let temp = s.(_Y) in s.(_Y) <- rotl current.(0ul) r; current.(0ul) <- temp inline_for_extraction noextract val state_pi_rho: s:state -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_pi_rho (as_seq h0 s)) let state_pi_rho s = push_frame(); let x = get s 1ul 0ul in let h0 = ST.get() in let current = create 1ul x in let h1 = ST.get () in assert (bget h1 current 0 == S.get (as_seq h0 s) 1 0); [@ inline_let] let refl h i : GTot (uint64 & S.state) = bget h current 0, as_seq h s in [@ inline_let] let footprint i = loc_union (loc current) (loc s) in [@ inline_let] let spec h0 = S.state_pi_rho_inner in let h0 = ST.get () in loop h0 24ul S.state_pi_rho_s refl footprint spec (fun i -> Loop.unfold_repeat_gen 24 S.state_pi_rho_s (spec h0) (refl h0 0) (v i); state_pi_rho_inner i current s ); pop_frame() inline_for_extraction noextract val state_chi_inner: st:state -> y:index -> Stack unit (requires fun h0 -> live h0 st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Equiv.state_chi_inner (v y) (as_seq h0 st)) let state_chi_inner st y = let h0 = ST.get() in let v0 = get st 0ul y ^. ((lognot (get st 1ul y)) &. get st 2ul y) in let v1 = get st 1ul y ^. ((lognot (get st 2ul y)) &. get st 3ul y) in let v2 = get st 2ul y ^. ((lognot (get st 3ul y)) &. get st 4ul y) in let v3 = get st 3ul y ^. ((lognot (get st 4ul y)) &. get st 0ul y) in let v4 = get st 4ul y ^. ((lognot (get st 0ul y)) &. get st 1ul y) in set st 0ul y v0; set st 1ul y v1; set st 2ul y v2; set st 3ul y v3; set st 4ul y v4; let h1 = ST.get() in assert (modifies (loc st) h0 h1); assert (as_seq h1 st == Equiv.state_chi_inner (v y) (as_seq h0 st)) inline_for_extraction noextract val state_chi: s:state -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_chi (as_seq h0 s)) let state_chi st = let h0 = ST.get() in [@ inline_let] let spec h0 = Equiv.state_chi_inner in let h0 = ST.get () in loop1 h0 5ul st spec (fun y -> Loop.unfold_repeati 5 (spec h0) (as_seq h0 st) (v y); state_chi_inner st y ); let h1 = ST.get() in assert(as_seq h1 st == Equiv.state_chi (as_seq h0 st)); Equiv.state_chi_equivalence (as_seq h0 st) inline_for_extraction noextract val state_iota: s:state -> round:size_t{v round < 24} -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.Equivalence.fst.checked", "Spec.SHA3.Constants.fst.checked", "Spec.SHA3.fst.checked", "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA3.fst" }
[ { "abbrev": true, "full_module": "Spec.SHA3.Equivalence", "short_module": "Equiv" }, { "abbrev": true, "full_module": "Spec.SHA3", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loop" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "LB" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Spec.SHA3.Constants", "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": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "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
s: Hacl.Impl.SHA3.state -> round: Lib.IntTypes.size_t{Lib.IntTypes.v round < 24} -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.SHA3.state", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.SHA3.set", "FStar.UInt32.__uint_to_t", "Prims.unit", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Hat_Dot", "Lib.IntTypes.secret", "Hacl.Impl.SHA3.get", "Lib.IntTypes.uint64", "Lib.Buffer.op_Array_Access", "Lib.Buffer.CONST", "FStar.UInt32.uint_to_t", "Hacl.Impl.SHA3.keccak_rndc", "Lib.Buffer.recall_contents", "Spec.SHA3.Constants.keccak_rndc" ]
[]
false
true
false
false
false
let state_iota s round =
recall_contents keccak_rndc Spec.SHA3.Constants.keccak_rndc; let c = keccak_rndc.(round) in set s 0ul 0ul (get s 0ul 0ul ^. secret c)
false
Hacl.Impl.SHA3.fst
Hacl.Impl.SHA3.absorb_inner
val absorb_inner: rateInBytes:size_t{0 < v rateInBytes /\ v rateInBytes <= 200} -> block:lbuffer uint8 rateInBytes -> s:state -> Stack unit (requires fun h0 -> live h0 s /\ live h0 block /\ disjoint s block) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.absorb_inner (v rateInBytes) (as_seq h0 block) (as_seq h0 s))
val absorb_inner: rateInBytes:size_t{0 < v rateInBytes /\ v rateInBytes <= 200} -> block:lbuffer uint8 rateInBytes -> s:state -> Stack unit (requires fun h0 -> live h0 s /\ live h0 block /\ disjoint s block) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.absorb_inner (v rateInBytes) (as_seq h0 block) (as_seq h0 s))
let absorb_inner rateInBytes block s = loadState rateInBytes block s; state_permute s
{ "file_name": "code/sha3/Hacl.Impl.SHA3.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 17, "end_line": 433, "start_col": 0, "start_line": 431 }
module Hacl.Impl.SHA3 open FStar.HyperStack.All open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open LowStar.BufferOps open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Spec.SHA3.Constants module ST = FStar.HyperStack.ST module B = LowStar.Buffer module LSeq = Lib.Sequence module LB = Lib.ByteSequence module Loop = Lib.LoopCombinators module S = Spec.SHA3 module Equiv = Spec.SHA3.Equivalence private let keccak_rotc :x:glbuffer rotc_t 24ul{witnessed x keccak_rotc /\ recallable x} = createL_global rotc_list private let keccak_piln :x:glbuffer piln_t 24ul{witnessed x keccak_piln /\ recallable x} = createL_global piln_list private let keccak_rndc :x:glbuffer pub_uint64 24ul{witnessed x keccak_rndc /\ recallable x} = createL_global rndc_list #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar.Seq'" inline_for_extraction noextract let state = lbuffer uint64 25ul inline_for_extraction noextract let index = n:size_t{v n < 5} inline_for_extraction noextract val get: s:state -> x:index -> y:index -> Stack uint64 (requires fun h -> live h s) (ensures fun h0 r h1 -> modifies loc_none h0 h1 /\ r == S.get (as_seq h0 s) (v x) (v y)) let get s x y = s.(x +! 5ul *! y) inline_for_extraction noextract val set: s:state -> x:index -> y:index -> v:uint64 -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.set (as_seq h0 s) (size_v x) (size_v y) v) let set s x y v = s.(x +! 5ul *! y) <- v inline_for_extraction noextract let rotl (a:uint64) (b:size_t{0 < uint_v b /\ uint_v b < 64}) = rotate_left a b inline_for_extraction noextract val state_theta0: s:state -> _C:lbuffer uint64 5ul -> Stack unit (requires fun h -> live h s /\ live h _C /\ disjoint _C s) (ensures fun h0 _ h1 -> modifies (loc _C) h0 h1 /\ as_seq h1 _C == S.state_theta0 (as_seq h0 s) (as_seq h0 _C)) let state_theta0 s _C = [@ inline_let] let spec h0 = S.state_theta_inner_C (as_seq h0 s) in let h0 = ST.get () in loop1 h0 5ul _C spec (fun x -> Loop.unfold_repeati 5 (spec h0) (as_seq h0 _C) (v x); _C.(x) <- get s x 0ul ^. get s x 1ul ^. get s x 2ul ^. get s x 3ul ^. get s x 4ul ) inline_for_extraction noextract val state_theta_inner_s: _C:lbuffer uint64 5ul -> x:index -> s:state -> Stack unit (requires fun h0 -> live h0 s /\ live h0 _C /\ disjoint _C s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_theta_inner_s (as_seq h0 _C) (v x) (as_seq h0 s)) let state_theta_inner_s _C x s = let _D = _C.((x +. 4ul) %. 5ul) ^. rotl _C.((x +. 1ul) %. 5ul) 1ul in [@ inline_let] let spec h0 = S.state_theta_inner_s_inner (v x) _D in let h0 = ST.get () in loop1 h0 5ul s spec (fun y -> Loop.unfold_repeati 5 (spec h0) (as_seq h0 s) (v y); set s x y (get s x y ^. _D) ) inline_for_extraction noextract val state_theta1: s:state -> _C:lbuffer uint64 5ul -> Stack unit (requires fun h0 -> live h0 s /\ live h0 _C /\ disjoint _C s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_theta1 (as_seq h0 s) (as_seq h0 _C)) let state_theta1 s _C = [@ inline_let] let spec h0 = S.state_theta_inner_s (as_seq h0 _C) in let h0 = ST.get () in loop1 h0 5ul s spec (fun x -> Loop.unfold_repeati 5 (spec h0) (as_seq h0 s) (v x); state_theta_inner_s _C x s ) inline_for_extraction noextract val state_theta: s:state -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_theta (as_seq h0 s)) let state_theta s = push_frame (); let h0 = ST.get() in let _C = create 5ul (u64 0) in state_theta0 s _C; state_theta1 s _C; pop_frame() #reset-options "--max_fuel 1 --max_ifuel 1 --z3rlimit 50" private val index_map: #a:Type -> #b:Type -> f:(a -> b) -> l:list a -> i:nat{i < List.Tot.length l} -> Lemma (List.Tot.index (List.Tot.map f l) i == f (List.Tot.index l i)) let rec index_map #a #b f l i = if i = 0 then () else match l with | [] -> () | _ :: l' -> index_map f l' (i - 1) #reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100" inline_for_extraction noextract val state_pi_rho_inner: i:size_t{v i < 24} -> current:lbuffer uint64 1ul -> s:state -> Stack unit (requires fun h -> live h s /\ live h current /\ disjoint current s) (ensures fun h0 _ h1 -> modifies (loc_union (loc s) (loc current)) h0 h1 /\ (let c', s' = S.state_pi_rho_inner (v i) (bget h0 current 0, as_seq h0 s) in bget h1 current 0 == c' /\ as_seq h1 s == s')) let state_pi_rho_inner i current s = assert_norm (List.Tot.length piln_list == 24); let h0 = ST.get () in recall_contents keccak_rotc Spec.SHA3.Constants.keccak_rotc; recall_contents keccak_piln Spec.SHA3.Constants.keccak_piln; index_map v piln_list (v i); let _Y = keccak_piln.(i) in let r = keccak_rotc.(i) in let temp = s.(_Y) in s.(_Y) <- rotl current.(0ul) r; current.(0ul) <- temp inline_for_extraction noextract val state_pi_rho: s:state -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_pi_rho (as_seq h0 s)) let state_pi_rho s = push_frame(); let x = get s 1ul 0ul in let h0 = ST.get() in let current = create 1ul x in let h1 = ST.get () in assert (bget h1 current 0 == S.get (as_seq h0 s) 1 0); [@ inline_let] let refl h i : GTot (uint64 & S.state) = bget h current 0, as_seq h s in [@ inline_let] let footprint i = loc_union (loc current) (loc s) in [@ inline_let] let spec h0 = S.state_pi_rho_inner in let h0 = ST.get () in loop h0 24ul S.state_pi_rho_s refl footprint spec (fun i -> Loop.unfold_repeat_gen 24 S.state_pi_rho_s (spec h0) (refl h0 0) (v i); state_pi_rho_inner i current s ); pop_frame() inline_for_extraction noextract val state_chi_inner: st:state -> y:index -> Stack unit (requires fun h0 -> live h0 st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Equiv.state_chi_inner (v y) (as_seq h0 st)) let state_chi_inner st y = let h0 = ST.get() in let v0 = get st 0ul y ^. ((lognot (get st 1ul y)) &. get st 2ul y) in let v1 = get st 1ul y ^. ((lognot (get st 2ul y)) &. get st 3ul y) in let v2 = get st 2ul y ^. ((lognot (get st 3ul y)) &. get st 4ul y) in let v3 = get st 3ul y ^. ((lognot (get st 4ul y)) &. get st 0ul y) in let v4 = get st 4ul y ^. ((lognot (get st 0ul y)) &. get st 1ul y) in set st 0ul y v0; set st 1ul y v1; set st 2ul y v2; set st 3ul y v3; set st 4ul y v4; let h1 = ST.get() in assert (modifies (loc st) h0 h1); assert (as_seq h1 st == Equiv.state_chi_inner (v y) (as_seq h0 st)) inline_for_extraction noextract val state_chi: s:state -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_chi (as_seq h0 s)) let state_chi st = let h0 = ST.get() in [@ inline_let] let spec h0 = Equiv.state_chi_inner in let h0 = ST.get () in loop1 h0 5ul st spec (fun y -> Loop.unfold_repeati 5 (spec h0) (as_seq h0 st) (v y); state_chi_inner st y ); let h1 = ST.get() in assert(as_seq h1 st == Equiv.state_chi (as_seq h0 st)); Equiv.state_chi_equivalence (as_seq h0 st) inline_for_extraction noextract val state_iota: s:state -> round:size_t{v round < 24} -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_iota (as_seq h0 s) (v round)) let state_iota s round = recall_contents keccak_rndc Spec.SHA3.Constants.keccak_rndc; let c = keccak_rndc.(round) in set s 0ul 0ul (get s 0ul 0ul ^. secret c) private val state_permute: s:state -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.state_permute (as_seq h0 s)) let state_permute s = [@ inline_let] let spec h0 = S.state_permute1 in let h0 = ST.get () in loop1 h0 24ul s spec (fun round -> Loop.unfold_repeati 24 (spec h0) (as_seq h0 s) (v round); state_theta s; state_pi_rho s; state_chi s; state_iota s round) private val loadState: rateInBytes:size_t{v rateInBytes <= 200} -> input:lbuffer uint8 rateInBytes -> s:state -> Stack unit (requires fun h -> live h input /\ live h s /\ disjoint input s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.loadState (v rateInBytes) (as_seq h0 input) (as_seq h0 s)) let loadState rateInBytes input s = push_frame(); let h0 = ST.get() in let block = create 200ul (u8 0) in update_sub block 0ul rateInBytes input; [@ inline_let] let spec h0 = S.loadState_inner (as_seq h0 block) in let h0 = ST.get () in loop1 h0 25ul s spec (fun j -> Loop.unfold_repeati 25 (spec h0) (as_seq h0 s) (v j); let h0 = ST.get() in let x = uint_from_bytes_le #U64 (sub block (j *! 8ul) 8ul) in s.(j) <- s.(j) ^. x ); pop_frame() inline_for_extraction noextract val storeState_inner: s:state -> j:size_t{v j < 25} -> block:lbuffer uint8 200ul -> Stack unit (requires fun h0 -> live h0 s /\ live h0 block /\ disjoint s block) (ensures fun h0 _ h1 -> modifies (loc block) h0 h1 /\ as_seq h1 block == S.storeState_inner (as_seq h0 s) (v j) (as_seq h0 block)) let storeState_inner s j block = let sj = s.(j) in let h0 = ST.get () in update_sub_f h0 block (j *! 8ul) 8ul (fun h -> Lib.ByteSequence.uint_to_bytes_le sj) (fun _ -> uint_to_bytes_le #U64 (sub block (j *! 8ul) 8ul) sj) private val storeState: rateInBytes:size_t{v rateInBytes <= 200} -> s:state -> res:lbuffer uint8 rateInBytes -> Stack unit (requires fun h0 -> live h0 s /\ live h0 res) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.storeState (v rateInBytes) (as_seq h0 s)) let storeState rateInBytes s res = push_frame(); let h0 = ST.get() in let block = create 200ul (u8 0) in [@ inline_let] let spec h0 = S.storeState_inner (as_seq h0 s) in let h0 = ST.get () in loop1 h0 25ul block spec (fun j -> Loop.unfold_repeati 25 (spec h0) (as_seq h0 block) (v j); storeState_inner s j block ); copy res (sub block 0ul rateInBytes); pop_frame() #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract val absorb_next: s:state -> rateInBytes:size_t{v rateInBytes > 0 /\ v rateInBytes <= 200} -> Stack unit (requires fun h -> live h s) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.absorb_next (as_seq h0 s) (v rateInBytes)) let absorb_next s rateInBytes = push_frame(); let h0 = ST.get() in let nextBlock_ = create 200ul (u8 0) in let nextBlock = sub nextBlock_ 0ul rateInBytes in let h1 = ST.get () in assert (as_seq h1 nextBlock `Seq.equal` Lib.Sequence.create (v rateInBytes) (u8 0)); nextBlock.(rateInBytes -! 1ul) <- u8 0x80; loadState rateInBytes nextBlock s; state_permute s; pop_frame() inline_for_extraction noextract val absorb_last: delimitedSuffix:byte_t -> rateInBytes:size_t{0 < v rateInBytes /\ v rateInBytes <= 200} -> rem:size_t{v rem < v rateInBytes} -> input:lbuffer uint8 rem -> s:state -> Stack unit (requires fun h -> live h s /\ live h input /\ disjoint s input) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s == S.absorb_last delimitedSuffix (v rateInBytes) (v rem) (as_seq h0 input) (as_seq h0 s)) let absorb_last delimitedSuffix rateInBytes rem input s = push_frame(); let h0 = ST.get() in let lastBlock_ = create 200ul (u8 0) in let lastBlock = sub lastBlock_ 0ul rateInBytes in let h1 = ST.get () in assert (as_seq h1 lastBlock `Seq.equal` Lib.Sequence.create (v rateInBytes) (u8 0)); let open Lib.RawIntTypes in update_sub lastBlock (size 0) rem input; lastBlock.(rem) <- byte_to_uint8 delimitedSuffix; loadState rateInBytes lastBlock s; if not ((delimitedSuffix &. byte 0x80) =. byte 0) && (size_to_UInt32 rem = size_to_UInt32 (rateInBytes -. 1ul)) then state_permute s; absorb_next s rateInBytes; pop_frame() val absorb_inner: rateInBytes:size_t{0 < v rateInBytes /\ v rateInBytes <= 200} -> block:lbuffer uint8 rateInBytes -> s:state -> Stack unit (requires fun h0 -> live h0 s /\ live h0 block /\ disjoint s block) (ensures fun h0 _ h1 -> modifies (loc s) h0 h1 /\ as_seq h1 s ==
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.Equivalence.fst.checked", "Spec.SHA3.Constants.fst.checked", "Spec.SHA3.fst.checked", "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA3.fst" }
[ { "abbrev": true, "full_module": "Spec.SHA3.Equivalence", "short_module": "Equiv" }, { "abbrev": true, "full_module": "Spec.SHA3", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loop" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "LB" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Spec.SHA3.Constants", "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": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "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
rateInBytes: Lib.IntTypes.size_t{0 < Lib.IntTypes.v rateInBytes /\ Lib.IntTypes.v rateInBytes <= 200} -> block: Lib.Buffer.lbuffer Lib.IntTypes.uint8 rateInBytes -> s: Hacl.Impl.SHA3.state -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.op_LessThanOrEqual", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.Impl.SHA3.state", "Hacl.Impl.SHA3.state_permute", "Prims.unit", "Hacl.Impl.SHA3.loadState" ]
[]
false
true
false
false
false
let absorb_inner rateInBytes block s =
loadState rateInBytes block s; state_permute s
false