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
MiniValeSemantics.fst
MiniValeSemantics.t_lemma
val t_lemma : pre: Type0 -> post: Type0 -> Type0
let t_lemma (pre:Type0) (post:Type0) = unit -> Lemma (requires pre) (ensures post)
{ "file_name": "examples/metatheory/MiniValeSemantics.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 45, "end_line": 233, "start_col": 0, "start_line": 232 }
(* 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. Authors: C. Hawblitzel, N. Swamy *) module MiniValeSemantics (* This is a highly-simplified model of Vale/F*, based on Section 3.1-3.3 of the paper of the POPL '19 paper. It is derived from the QuickRegs1 code in the popl-artifact-submit branch of Vale. *) /// We use this tag to mark certain definitions /// and control normalization based on it irreducible let qattr = () /// 2^64 let pow2_64 = 0x10000000000000000 /// Natural numbers representable in 64 bits type nat64 = i:int{0 <= i /\ i < pow2_64} /// We have 4 registers type reg = | Rax | Rbx | Rcx | Rdx /// An operand is either a register or a constant type operand = | OReg: r:reg -> operand | OConst: n:nat64 -> operand /// Only 2 instructions here: /// A move or an add type ins = | Mov64: dst:operand -> src:operand -> ins | Add64: dst:operand -> src:operand -> ins /// A program is /// - a single instruction /// - a block of instructions /// - or a while loop type code = | Ins: ins:ins -> code | Block: block:list code -> code | WhileLessThan: src1:operand -> src2:operand -> whileBody:code -> code /// The state of a program is the register file /// holiding a 64-bit value for each register type state = reg -> nat64 /// fuel: To prove the termination of while loops, we're going to /// instrument while loops with fuel type fuel = nat /// Evaluating an operand: /// -- marked for reduction /// -- Registers evaluated by state lookup [@@qattr] let eval_operand (o:operand) (s:state) : nat64 = match o with | OReg r -> s r | OConst n -> n /// updating a register state `s` at `r` with `v` [@@qattr] let update_reg (s:state) (r:reg) (v:nat64) : state = fun r' -> if r = r' then v else s r' /// updating a register state `s` at `r` with `s' r` [@@qattr] let update_state (r:reg) (s' s:state) : state = update_reg s r (s' r) // We don't have an "ok" flag, so errors just result an arbitrary state: assume val unknown_state (s:state) : state (*** A basic semantics using a big-step interpreter ***) /// Instruction evaluation: /// only some operands are valid let eval_ins (ins:ins) (s:state) : state = match ins with | Mov64 (OConst _) _ -> unknown_state s | Mov64 (OReg dst) src -> update_reg s dst (eval_operand src s) | Add64 (OConst _) _ -> unknown_state s | Add64 (OReg dst) src -> update_reg s dst ((s dst + eval_operand src s) % 0x10000000000000000) /// eval_code: /// A fueled big-step interpreter /// While lops return None when we're out of fuel let rec eval_code (c:code) (f:fuel) (s:state) : option state = match c with | Ins ins -> Some (eval_ins ins s) | Block cs -> eval_codes cs f s | WhileLessThan src1 src2 body -> if f = 0 then None else if eval_operand src1 s < eval_operand src2 s then match eval_code body f s with | None -> None | Some s -> eval_code c (f - 1) s else Some s and eval_codes (cs:list code) (f:fuel) (s:state) : option state = match cs with | [] -> Some s | c::cs -> match eval_code c f s with | None -> None | Some s -> eval_codes cs f s (*** END OF TRUSTED SEMANTICS ***) //////////////////////////////////////////////////////////////////////////////// /// 1. We prove that increasing the fuel is irrelevant to terminating executions val increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code c f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code c fN s0 == Some sN) (decreases %[f0; c]) val increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code (Block c) f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code (Block c) fN s0 == Some sN) (decreases %[f0; c]) let rec increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | Ins ins -> () | Block l -> increase_fuels l s0 f0 sN fN | WhileLessThan src1 src2 body -> if eval_operand src1 s0 < eval_operand src2 s0 then match eval_code body f0 s0 with | None -> () | Some s1 -> increase_fuel body s0 f0 s1 fN; increase_fuel c s1 (f0 - 1) sN (fN - 1) else () and increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | [] -> () | h::t -> let Some s1 = eval_code h f0 s0 in increase_fuel h s0 f0 s1 fN; increase_fuels t s1 f0 sN fN /// 2. We can compute the fuel needed to run a sequential composition /// as the max of the fuel to compute each piece of code in it let lemma_merge (c:code) (cs:list code) (s0:state) (f0:fuel) (sM:state) (fM:fuel) (sN:state) : Ghost fuel (requires eval_code c f0 s0 == Some sM /\ eval_code (Block cs) fM sM == Some sN) (ensures fun fN -> eval_code (Block (c::cs)) fN s0 == Some sN) = let f = if f0 > fM then f0 else fM in increase_fuel c s0 f0 sM f; increase_fuel (Block cs) sM fM sN f; f ///////////////////////////////////////////////////////////////// // Now, we're going to define a verification-condition generator // // The main idea is that we're going to: // // 1. define a kind of typeclass, that associates with a // piece of code a weakest-precondition rule for it // // 2. Define a WP-generator that computes WPs for each of the // control constructs of the language, given a program // represented as the raw code packaged with their typeclass // instances for computing their WPs ///////////////////////////////////////////////////////////////// [@@qattr] let t_post = state -> Type0 [@@qattr] let t_pre = state -> Type0 /// t_wp: The type of weakest preconditions let t_wp = t_post -> t_pre /// c `has_wp` wp: The main judgment in our program logic let has_wp (c:code) (wp:t_wp) : Type = k:t_post -> //for any post-condition s0:state -> //and initial state Ghost (state * fuel) (requires wp k s0) //Given the precondition (ensures fun (sM, f0) -> //we can compute the fuel f0 needed so that eval_code c f0 s0 == Some sM /\ //eval_code with that fuel returns sM k sM) //and the post-condition is true on sM
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "MiniValeSemantics.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
pre: Type0 -> post: Type0 -> Type0
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
false
true
true
let t_lemma (pre post: Type0) =
unit -> Lemma (requires pre) (ensures post)
false
MiniValeSemantics.fst
MiniValeSemantics.vc_sound'
val vc_sound' (cs: list code) (qcs: with_wps cs) : has_wp (Block cs) (vc_gen cs qcs)
val vc_sound' (cs: list code) (qcs: with_wps cs) : has_wp (Block cs) (vc_gen cs qcs)
let vc_sound' (cs:list code) (qcs:with_wps cs) : has_wp (Block cs) (vc_gen cs qcs) = vc_sound cs qcs
{ "file_name": "examples/metatheory/MiniValeSemantics.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 19, "end_line": 304, "start_col": 0, "start_line": 302 }
(* 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. Authors: C. Hawblitzel, N. Swamy *) module MiniValeSemantics (* This is a highly-simplified model of Vale/F*, based on Section 3.1-3.3 of the paper of the POPL '19 paper. It is derived from the QuickRegs1 code in the popl-artifact-submit branch of Vale. *) /// We use this tag to mark certain definitions /// and control normalization based on it irreducible let qattr = () /// 2^64 let pow2_64 = 0x10000000000000000 /// Natural numbers representable in 64 bits type nat64 = i:int{0 <= i /\ i < pow2_64} /// We have 4 registers type reg = | Rax | Rbx | Rcx | Rdx /// An operand is either a register or a constant type operand = | OReg: r:reg -> operand | OConst: n:nat64 -> operand /// Only 2 instructions here: /// A move or an add type ins = | Mov64: dst:operand -> src:operand -> ins | Add64: dst:operand -> src:operand -> ins /// A program is /// - a single instruction /// - a block of instructions /// - or a while loop type code = | Ins: ins:ins -> code | Block: block:list code -> code | WhileLessThan: src1:operand -> src2:operand -> whileBody:code -> code /// The state of a program is the register file /// holiding a 64-bit value for each register type state = reg -> nat64 /// fuel: To prove the termination of while loops, we're going to /// instrument while loops with fuel type fuel = nat /// Evaluating an operand: /// -- marked for reduction /// -- Registers evaluated by state lookup [@@qattr] let eval_operand (o:operand) (s:state) : nat64 = match o with | OReg r -> s r | OConst n -> n /// updating a register state `s` at `r` with `v` [@@qattr] let update_reg (s:state) (r:reg) (v:nat64) : state = fun r' -> if r = r' then v else s r' /// updating a register state `s` at `r` with `s' r` [@@qattr] let update_state (r:reg) (s' s:state) : state = update_reg s r (s' r) // We don't have an "ok" flag, so errors just result an arbitrary state: assume val unknown_state (s:state) : state (*** A basic semantics using a big-step interpreter ***) /// Instruction evaluation: /// only some operands are valid let eval_ins (ins:ins) (s:state) : state = match ins with | Mov64 (OConst _) _ -> unknown_state s | Mov64 (OReg dst) src -> update_reg s dst (eval_operand src s) | Add64 (OConst _) _ -> unknown_state s | Add64 (OReg dst) src -> update_reg s dst ((s dst + eval_operand src s) % 0x10000000000000000) /// eval_code: /// A fueled big-step interpreter /// While lops return None when we're out of fuel let rec eval_code (c:code) (f:fuel) (s:state) : option state = match c with | Ins ins -> Some (eval_ins ins s) | Block cs -> eval_codes cs f s | WhileLessThan src1 src2 body -> if f = 0 then None else if eval_operand src1 s < eval_operand src2 s then match eval_code body f s with | None -> None | Some s -> eval_code c (f - 1) s else Some s and eval_codes (cs:list code) (f:fuel) (s:state) : option state = match cs with | [] -> Some s | c::cs -> match eval_code c f s with | None -> None | Some s -> eval_codes cs f s (*** END OF TRUSTED SEMANTICS ***) //////////////////////////////////////////////////////////////////////////////// /// 1. We prove that increasing the fuel is irrelevant to terminating executions val increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code c f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code c fN s0 == Some sN) (decreases %[f0; c]) val increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code (Block c) f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code (Block c) fN s0 == Some sN) (decreases %[f0; c]) let rec increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | Ins ins -> () | Block l -> increase_fuels l s0 f0 sN fN | WhileLessThan src1 src2 body -> if eval_operand src1 s0 < eval_operand src2 s0 then match eval_code body f0 s0 with | None -> () | Some s1 -> increase_fuel body s0 f0 s1 fN; increase_fuel c s1 (f0 - 1) sN (fN - 1) else () and increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | [] -> () | h::t -> let Some s1 = eval_code h f0 s0 in increase_fuel h s0 f0 s1 fN; increase_fuels t s1 f0 sN fN /// 2. We can compute the fuel needed to run a sequential composition /// as the max of the fuel to compute each piece of code in it let lemma_merge (c:code) (cs:list code) (s0:state) (f0:fuel) (sM:state) (fM:fuel) (sN:state) : Ghost fuel (requires eval_code c f0 s0 == Some sM /\ eval_code (Block cs) fM sM == Some sN) (ensures fun fN -> eval_code (Block (c::cs)) fN s0 == Some sN) = let f = if f0 > fM then f0 else fM in increase_fuel c s0 f0 sM f; increase_fuel (Block cs) sM fM sN f; f ///////////////////////////////////////////////////////////////// // Now, we're going to define a verification-condition generator // // The main idea is that we're going to: // // 1. define a kind of typeclass, that associates with a // piece of code a weakest-precondition rule for it // // 2. Define a WP-generator that computes WPs for each of the // control constructs of the language, given a program // represented as the raw code packaged with their typeclass // instances for computing their WPs ///////////////////////////////////////////////////////////////// [@@qattr] let t_post = state -> Type0 [@@qattr] let t_pre = state -> Type0 /// t_wp: The type of weakest preconditions let t_wp = t_post -> t_pre /// c `has_wp` wp: The main judgment in our program logic let has_wp (c:code) (wp:t_wp) : Type = k:t_post -> //for any post-condition s0:state -> //and initial state Ghost (state * fuel) (requires wp k s0) //Given the precondition (ensures fun (sM, f0) -> //we can compute the fuel f0 needed so that eval_code c f0 s0 == Some sM /\ //eval_code with that fuel returns sM k sM) //and the post-condition is true on sM /// An abbreviation for a thunked lemma let t_lemma (pre:Type0) (post:Type0) = unit -> Lemma (requires pre) (ensures post) /// `with_wp` : A typeclass for code packaged with its wp [@@qattr] noeq type with_wp : code -> Type = | QProc: c:code -> wp:t_wp -> hasWp:has_wp c wp -> with_wp c /// `with_wps`: A typclass for lists of code values packages with their wps noeq type with_wps : list code -> Type = | QEmpty: //empty list with_wps [] | QSeq: //cons #c:code -> #cs:list code -> hd:with_wp c -> tl:with_wps cs -> with_wps (c::cs) | QLemma: //augmenting an instruction sequence with a lemma #cs:list code -> pre:Type0 -> post:Type0 -> t_lemma pre post -> with_wps cs -> with_wps cs [@@qattr] let rec vc_gen (cs:list code) (qcs:with_wps cs) (k:t_post) : Tot (state -> Tot Type0 (decreases qcs)) = fun s0 -> match qcs with | QEmpty -> k s0 //no instructions; prove the postcondition right away | QSeq qc qcs -> // let pre_tl = //compute the VC generator for the tail, a precondition qc.wp (vc_gen (Cons?.tl cs) qcs k) s0 // in // qc.wp pre_tl s0 //apply the wp-generator to the precondition for the tail | QLemma pre post _ qcs -> pre /\ //prove the precondition of the lemma (post ==> vc_gen cs qcs k s0) //and assume its postcondition to verify the program /// The vc-generator is sound let rec vc_sound (cs:list code) (qcs:with_wps cs) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires vc_gen cs qcs k s0) (ensures fun (sN, fN) -> eval_code (Block cs) fN s0 == Some sN /\ k sN) = match qcs with | QEmpty -> (s0, 0) | QSeq qc qcs -> let Cons c cs' = cs in let (sM, fM) = qc.hasWp (vc_gen cs' qcs k) s0 in let (sN, fN) = vc_sound cs' qcs k sM in let fN' = lemma_merge c cs' s0 fM sM fN sN in (sN, fN') | QLemma pre post lem qcs' -> lem (); vc_sound cs qcs' k s0
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "MiniValeSemantics.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
cs: Prims.list MiniValeSemantics.code -> qcs: MiniValeSemantics.with_wps cs -> MiniValeSemantics.has_wp (MiniValeSemantics.Block cs) (MiniValeSemantics.vc_gen cs qcs)
Prims.Tot
[ "total" ]
[]
[ "Prims.list", "MiniValeSemantics.code", "MiniValeSemantics.with_wps", "MiniValeSemantics.vc_sound", "MiniValeSemantics.has_wp", "MiniValeSemantics.Block", "MiniValeSemantics.vc_gen" ]
[]
false
false
false
false
false
let vc_sound' (cs: list code) (qcs: with_wps cs) : has_wp (Block cs) (vc_gen cs qcs) =
vc_sound cs qcs
false
MiniValeSemantics.fst
MiniValeSemantics.eval_ins
val eval_ins (ins: ins) (s: state) : state
val eval_ins (ins: ins) (s: state) : state
let eval_ins (ins:ins) (s:state) : state = match ins with | Mov64 (OConst _) _ -> unknown_state s | Mov64 (OReg dst) src -> update_reg s dst (eval_operand src s) | Add64 (OConst _) _ -> unknown_state s | Add64 (OReg dst) src -> update_reg s dst ((s dst + eval_operand src s) % 0x10000000000000000)
{ "file_name": "examples/metatheory/MiniValeSemantics.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 73, "end_line": 112, "start_col": 0, "start_line": 100 }
(* 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. Authors: C. Hawblitzel, N. Swamy *) module MiniValeSemantics (* This is a highly-simplified model of Vale/F*, based on Section 3.1-3.3 of the paper of the POPL '19 paper. It is derived from the QuickRegs1 code in the popl-artifact-submit branch of Vale. *) /// We use this tag to mark certain definitions /// and control normalization based on it irreducible let qattr = () /// 2^64 let pow2_64 = 0x10000000000000000 /// Natural numbers representable in 64 bits type nat64 = i:int{0 <= i /\ i < pow2_64} /// We have 4 registers type reg = | Rax | Rbx | Rcx | Rdx /// An operand is either a register or a constant type operand = | OReg: r:reg -> operand | OConst: n:nat64 -> operand /// Only 2 instructions here: /// A move or an add type ins = | Mov64: dst:operand -> src:operand -> ins | Add64: dst:operand -> src:operand -> ins /// A program is /// - a single instruction /// - a block of instructions /// - or a while loop type code = | Ins: ins:ins -> code | Block: block:list code -> code | WhileLessThan: src1:operand -> src2:operand -> whileBody:code -> code /// The state of a program is the register file /// holiding a 64-bit value for each register type state = reg -> nat64 /// fuel: To prove the termination of while loops, we're going to /// instrument while loops with fuel type fuel = nat /// Evaluating an operand: /// -- marked for reduction /// -- Registers evaluated by state lookup [@@qattr] let eval_operand (o:operand) (s:state) : nat64 = match o with | OReg r -> s r | OConst n -> n /// updating a register state `s` at `r` with `v` [@@qattr] let update_reg (s:state) (r:reg) (v:nat64) : state = fun r' -> if r = r' then v else s r' /// updating a register state `s` at `r` with `s' r` [@@qattr] let update_state (r:reg) (s' s:state) : state = update_reg s r (s' r) // We don't have an "ok" flag, so errors just result an arbitrary state: assume val unknown_state (s:state) : state (*** A basic semantics using a big-step interpreter ***) /// Instruction evaluation:
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "MiniValeSemantics.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ins: MiniValeSemantics.ins -> s: MiniValeSemantics.state -> MiniValeSemantics.state
Prims.Tot
[ "total" ]
[]
[ "MiniValeSemantics.ins", "MiniValeSemantics.state", "MiniValeSemantics.nat64", "MiniValeSemantics.operand", "MiniValeSemantics.unknown_state", "MiniValeSemantics.reg", "MiniValeSemantics.update_reg", "MiniValeSemantics.eval_operand", "Prims.op_Modulus", "Prims.op_Addition" ]
[]
false
false
false
true
false
let eval_ins (ins: ins) (s: state) : state =
match ins with | Mov64 (OConst _) _ -> unknown_state s | Mov64 (OReg dst) src -> update_reg s dst (eval_operand src s) | Add64 (OConst _) _ -> unknown_state s | Add64 (OReg dst) src -> update_reg s dst ((s dst + eval_operand src s) % 0x10000000000000000)
false
MiniValeSemantics.fst
MiniValeSemantics.eval_code
val eval_code (c: code) (f: fuel) (s: state) : option state
val eval_code (c: code) (f: fuel) (s: state) : option state
let rec eval_code (c:code) (f:fuel) (s:state) : option state = match c with | Ins ins -> Some (eval_ins ins s) | Block cs -> eval_codes cs f s | WhileLessThan src1 src2 body -> if f = 0 then None else if eval_operand src1 s < eval_operand src2 s then match eval_code body f s with | None -> None | Some s -> eval_code c (f - 1) s else Some s and eval_codes (cs:list code) (f:fuel) (s:state) : option state = match cs with | [] -> Some s | c::cs -> match eval_code c f s with | None -> None | Some s -> eval_codes cs f s
{ "file_name": "examples/metatheory/MiniValeSemantics.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 35, "end_line": 139, "start_col": 0, "start_line": 117 }
(* 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. Authors: C. Hawblitzel, N. Swamy *) module MiniValeSemantics (* This is a highly-simplified model of Vale/F*, based on Section 3.1-3.3 of the paper of the POPL '19 paper. It is derived from the QuickRegs1 code in the popl-artifact-submit branch of Vale. *) /// We use this tag to mark certain definitions /// and control normalization based on it irreducible let qattr = () /// 2^64 let pow2_64 = 0x10000000000000000 /// Natural numbers representable in 64 bits type nat64 = i:int{0 <= i /\ i < pow2_64} /// We have 4 registers type reg = | Rax | Rbx | Rcx | Rdx /// An operand is either a register or a constant type operand = | OReg: r:reg -> operand | OConst: n:nat64 -> operand /// Only 2 instructions here: /// A move or an add type ins = | Mov64: dst:operand -> src:operand -> ins | Add64: dst:operand -> src:operand -> ins /// A program is /// - a single instruction /// - a block of instructions /// - or a while loop type code = | Ins: ins:ins -> code | Block: block:list code -> code | WhileLessThan: src1:operand -> src2:operand -> whileBody:code -> code /// The state of a program is the register file /// holiding a 64-bit value for each register type state = reg -> nat64 /// fuel: To prove the termination of while loops, we're going to /// instrument while loops with fuel type fuel = nat /// Evaluating an operand: /// -- marked for reduction /// -- Registers evaluated by state lookup [@@qattr] let eval_operand (o:operand) (s:state) : nat64 = match o with | OReg r -> s r | OConst n -> n /// updating a register state `s` at `r` with `v` [@@qattr] let update_reg (s:state) (r:reg) (v:nat64) : state = fun r' -> if r = r' then v else s r' /// updating a register state `s` at `r` with `s' r` [@@qattr] let update_state (r:reg) (s' s:state) : state = update_reg s r (s' r) // We don't have an "ok" flag, so errors just result an arbitrary state: assume val unknown_state (s:state) : state (*** A basic semantics using a big-step interpreter ***) /// Instruction evaluation: /// only some operands are valid let eval_ins (ins:ins) (s:state) : state = match ins with | Mov64 (OConst _) _ -> unknown_state s | Mov64 (OReg dst) src -> update_reg s dst (eval_operand src s) | Add64 (OConst _) _ -> unknown_state s | Add64 (OReg dst) src -> update_reg s dst ((s dst + eval_operand src s) % 0x10000000000000000) /// eval_code: /// A fueled big-step interpreter
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "MiniValeSemantics.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: MiniValeSemantics.code -> f: MiniValeSemantics.fuel -> s: MiniValeSemantics.state -> FStar.Pervasives.Native.option MiniValeSemantics.state
Prims.Tot
[ "total" ]
[ "eval_code", "eval_codes" ]
[ "MiniValeSemantics.code", "MiniValeSemantics.fuel", "MiniValeSemantics.state", "MiniValeSemantics.ins", "FStar.Pervasives.Native.Some", "MiniValeSemantics.eval_ins", "Prims.list", "MiniValeSemantics.eval_codes", "MiniValeSemantics.operand", "Prims.op_Equality", "Prims.int", "FStar.Pervasives.Native.None", "Prims.bool", "Prims.op_LessThan", "MiniValeSemantics.eval_operand", "MiniValeSemantics.eval_code", "Prims.op_Subtraction", "FStar.Pervasives.Native.option" ]
[ "mutual recursion" ]
false
false
false
true
false
let rec eval_code (c: code) (f: fuel) (s: state) : option state =
match c with | Ins ins -> Some (eval_ins ins s) | Block cs -> eval_codes cs f s | WhileLessThan src1 src2 body -> if f = 0 then None else if eval_operand src1 s < eval_operand src2 s then match eval_code body f s with | None -> None | Some s -> eval_code c (f - 1) s else Some s
false
MiniValeSemantics.fst
MiniValeSemantics.inst_Move
val inst_Move (dst src: operand) : with_wp (Ins (Mov64 dst src))
val inst_Move (dst src: operand) : with_wp (Ins (Mov64 dst src))
let inst_Move (dst:operand) (src:operand) : with_wp (Ins (Mov64 dst src)) = QProc (Ins (Mov64 dst src)) (wp_Move dst src) (hasWp_Move dst src)
{ "file_name": "examples/metatheory/MiniValeSemantics.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 68, "end_line": 340, "start_col": 0, "start_line": 339 }
(* 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. Authors: C. Hawblitzel, N. Swamy *) module MiniValeSemantics (* This is a highly-simplified model of Vale/F*, based on Section 3.1-3.3 of the paper of the POPL '19 paper. It is derived from the QuickRegs1 code in the popl-artifact-submit branch of Vale. *) /// We use this tag to mark certain definitions /// and control normalization based on it irreducible let qattr = () /// 2^64 let pow2_64 = 0x10000000000000000 /// Natural numbers representable in 64 bits type nat64 = i:int{0 <= i /\ i < pow2_64} /// We have 4 registers type reg = | Rax | Rbx | Rcx | Rdx /// An operand is either a register or a constant type operand = | OReg: r:reg -> operand | OConst: n:nat64 -> operand /// Only 2 instructions here: /// A move or an add type ins = | Mov64: dst:operand -> src:operand -> ins | Add64: dst:operand -> src:operand -> ins /// A program is /// - a single instruction /// - a block of instructions /// - or a while loop type code = | Ins: ins:ins -> code | Block: block:list code -> code | WhileLessThan: src1:operand -> src2:operand -> whileBody:code -> code /// The state of a program is the register file /// holiding a 64-bit value for each register type state = reg -> nat64 /// fuel: To prove the termination of while loops, we're going to /// instrument while loops with fuel type fuel = nat /// Evaluating an operand: /// -- marked for reduction /// -- Registers evaluated by state lookup [@@qattr] let eval_operand (o:operand) (s:state) : nat64 = match o with | OReg r -> s r | OConst n -> n /// updating a register state `s` at `r` with `v` [@@qattr] let update_reg (s:state) (r:reg) (v:nat64) : state = fun r' -> if r = r' then v else s r' /// updating a register state `s` at `r` with `s' r` [@@qattr] let update_state (r:reg) (s' s:state) : state = update_reg s r (s' r) // We don't have an "ok" flag, so errors just result an arbitrary state: assume val unknown_state (s:state) : state (*** A basic semantics using a big-step interpreter ***) /// Instruction evaluation: /// only some operands are valid let eval_ins (ins:ins) (s:state) : state = match ins with | Mov64 (OConst _) _ -> unknown_state s | Mov64 (OReg dst) src -> update_reg s dst (eval_operand src s) | Add64 (OConst _) _ -> unknown_state s | Add64 (OReg dst) src -> update_reg s dst ((s dst + eval_operand src s) % 0x10000000000000000) /// eval_code: /// A fueled big-step interpreter /// While lops return None when we're out of fuel let rec eval_code (c:code) (f:fuel) (s:state) : option state = match c with | Ins ins -> Some (eval_ins ins s) | Block cs -> eval_codes cs f s | WhileLessThan src1 src2 body -> if f = 0 then None else if eval_operand src1 s < eval_operand src2 s then match eval_code body f s with | None -> None | Some s -> eval_code c (f - 1) s else Some s and eval_codes (cs:list code) (f:fuel) (s:state) : option state = match cs with | [] -> Some s | c::cs -> match eval_code c f s with | None -> None | Some s -> eval_codes cs f s (*** END OF TRUSTED SEMANTICS ***) //////////////////////////////////////////////////////////////////////////////// /// 1. We prove that increasing the fuel is irrelevant to terminating executions val increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code c f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code c fN s0 == Some sN) (decreases %[f0; c]) val increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code (Block c) f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code (Block c) fN s0 == Some sN) (decreases %[f0; c]) let rec increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | Ins ins -> () | Block l -> increase_fuels l s0 f0 sN fN | WhileLessThan src1 src2 body -> if eval_operand src1 s0 < eval_operand src2 s0 then match eval_code body f0 s0 with | None -> () | Some s1 -> increase_fuel body s0 f0 s1 fN; increase_fuel c s1 (f0 - 1) sN (fN - 1) else () and increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | [] -> () | h::t -> let Some s1 = eval_code h f0 s0 in increase_fuel h s0 f0 s1 fN; increase_fuels t s1 f0 sN fN /// 2. We can compute the fuel needed to run a sequential composition /// as the max of the fuel to compute each piece of code in it let lemma_merge (c:code) (cs:list code) (s0:state) (f0:fuel) (sM:state) (fM:fuel) (sN:state) : Ghost fuel (requires eval_code c f0 s0 == Some sM /\ eval_code (Block cs) fM sM == Some sN) (ensures fun fN -> eval_code (Block (c::cs)) fN s0 == Some sN) = let f = if f0 > fM then f0 else fM in increase_fuel c s0 f0 sM f; increase_fuel (Block cs) sM fM sN f; f ///////////////////////////////////////////////////////////////// // Now, we're going to define a verification-condition generator // // The main idea is that we're going to: // // 1. define a kind of typeclass, that associates with a // piece of code a weakest-precondition rule for it // // 2. Define a WP-generator that computes WPs for each of the // control constructs of the language, given a program // represented as the raw code packaged with their typeclass // instances for computing their WPs ///////////////////////////////////////////////////////////////// [@@qattr] let t_post = state -> Type0 [@@qattr] let t_pre = state -> Type0 /// t_wp: The type of weakest preconditions let t_wp = t_post -> t_pre /// c `has_wp` wp: The main judgment in our program logic let has_wp (c:code) (wp:t_wp) : Type = k:t_post -> //for any post-condition s0:state -> //and initial state Ghost (state * fuel) (requires wp k s0) //Given the precondition (ensures fun (sM, f0) -> //we can compute the fuel f0 needed so that eval_code c f0 s0 == Some sM /\ //eval_code with that fuel returns sM k sM) //and the post-condition is true on sM /// An abbreviation for a thunked lemma let t_lemma (pre:Type0) (post:Type0) = unit -> Lemma (requires pre) (ensures post) /// `with_wp` : A typeclass for code packaged with its wp [@@qattr] noeq type with_wp : code -> Type = | QProc: c:code -> wp:t_wp -> hasWp:has_wp c wp -> with_wp c /// `with_wps`: A typclass for lists of code values packages with their wps noeq type with_wps : list code -> Type = | QEmpty: //empty list with_wps [] | QSeq: //cons #c:code -> #cs:list code -> hd:with_wp c -> tl:with_wps cs -> with_wps (c::cs) | QLemma: //augmenting an instruction sequence with a lemma #cs:list code -> pre:Type0 -> post:Type0 -> t_lemma pre post -> with_wps cs -> with_wps cs [@@qattr] let rec vc_gen (cs:list code) (qcs:with_wps cs) (k:t_post) : Tot (state -> Tot Type0 (decreases qcs)) = fun s0 -> match qcs with | QEmpty -> k s0 //no instructions; prove the postcondition right away | QSeq qc qcs -> // let pre_tl = //compute the VC generator for the tail, a precondition qc.wp (vc_gen (Cons?.tl cs) qcs k) s0 // in // qc.wp pre_tl s0 //apply the wp-generator to the precondition for the tail | QLemma pre post _ qcs -> pre /\ //prove the precondition of the lemma (post ==> vc_gen cs qcs k s0) //and assume its postcondition to verify the program /// The vc-generator is sound let rec vc_sound (cs:list code) (qcs:with_wps cs) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires vc_gen cs qcs k s0) (ensures fun (sN, fN) -> eval_code (Block cs) fN s0 == Some sN /\ k sN) = match qcs with | QEmpty -> (s0, 0) | QSeq qc qcs -> let Cons c cs' = cs in let (sM, fM) = qc.hasWp (vc_gen cs' qcs k) s0 in let (sN, fN) = vc_sound cs' qcs k sM in let fN' = lemma_merge c cs' s0 fM sM fN sN in (sN, fN') | QLemma pre post lem qcs' -> lem (); vc_sound cs qcs' k s0 let vc_sound' (cs:list code) (qcs:with_wps cs) : has_wp (Block cs) (vc_gen cs qcs) = vc_sound cs qcs (*** Instances of with_wp ***) //////////////////////////////////////////////////////////////////////////////// //Instance for Mov //////////////////////////////////////////////////////////////////////////////// let lemma_Move (s0:state) (dst:operand) (src:operand) : Ghost (state * fuel) (requires OReg? dst) (ensures fun (sM, fM) -> eval_code (Ins (Mov64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0 ) = let Some sM = eval_code (Ins (Mov64 dst src)) 0 s0 in (sM, 0) [@@qattr] let wp_Move (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Type0 = OReg? dst /\ (forall (x:nat64). let sM = update_reg s0 (OReg?.r dst) x in eval_operand dst sM == eval_operand src s0 ==> k sM ) let hasWp_Move (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires wp_Move dst src k s0) (ensures fun (sM, f0) -> eval_code (Ins (Mov64 dst src)) f0 s0 == Some sM /\ k sM) = lemma_Move s0 dst src
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "MiniValeSemantics.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: MiniValeSemantics.operand -> src: MiniValeSemantics.operand -> MiniValeSemantics.with_wp (MiniValeSemantics.Ins (MiniValeSemantics.Mov64 dst src))
Prims.Tot
[ "total" ]
[]
[ "MiniValeSemantics.operand", "MiniValeSemantics.QProc", "MiniValeSemantics.Ins", "MiniValeSemantics.Mov64", "MiniValeSemantics.wp_Move", "MiniValeSemantics.hasWp_Move", "MiniValeSemantics.with_wp" ]
[]
false
false
false
false
false
let inst_Move (dst src: operand) : with_wp (Ins (Mov64 dst src)) =
QProc (Ins (Mov64 dst src)) (wp_Move dst src) (hasWp_Move dst src)
false
MiniValeSemantics.fst
MiniValeSemantics.eval_codes
val eval_codes (cs: list code) (f: fuel) (s: state) : option state
val eval_codes (cs: list code) (f: fuel) (s: state) : option state
let rec eval_code (c:code) (f:fuel) (s:state) : option state = match c with | Ins ins -> Some (eval_ins ins s) | Block cs -> eval_codes cs f s | WhileLessThan src1 src2 body -> if f = 0 then None else if eval_operand src1 s < eval_operand src2 s then match eval_code body f s with | None -> None | Some s -> eval_code c (f - 1) s else Some s and eval_codes (cs:list code) (f:fuel) (s:state) : option state = match cs with | [] -> Some s | c::cs -> match eval_code c f s with | None -> None | Some s -> eval_codes cs f s
{ "file_name": "examples/metatheory/MiniValeSemantics.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 35, "end_line": 139, "start_col": 0, "start_line": 117 }
(* 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. Authors: C. Hawblitzel, N. Swamy *) module MiniValeSemantics (* This is a highly-simplified model of Vale/F*, based on Section 3.1-3.3 of the paper of the POPL '19 paper. It is derived from the QuickRegs1 code in the popl-artifact-submit branch of Vale. *) /// We use this tag to mark certain definitions /// and control normalization based on it irreducible let qattr = () /// 2^64 let pow2_64 = 0x10000000000000000 /// Natural numbers representable in 64 bits type nat64 = i:int{0 <= i /\ i < pow2_64} /// We have 4 registers type reg = | Rax | Rbx | Rcx | Rdx /// An operand is either a register or a constant type operand = | OReg: r:reg -> operand | OConst: n:nat64 -> operand /// Only 2 instructions here: /// A move or an add type ins = | Mov64: dst:operand -> src:operand -> ins | Add64: dst:operand -> src:operand -> ins /// A program is /// - a single instruction /// - a block of instructions /// - or a while loop type code = | Ins: ins:ins -> code | Block: block:list code -> code | WhileLessThan: src1:operand -> src2:operand -> whileBody:code -> code /// The state of a program is the register file /// holiding a 64-bit value for each register type state = reg -> nat64 /// fuel: To prove the termination of while loops, we're going to /// instrument while loops with fuel type fuel = nat /// Evaluating an operand: /// -- marked for reduction /// -- Registers evaluated by state lookup [@@qattr] let eval_operand (o:operand) (s:state) : nat64 = match o with | OReg r -> s r | OConst n -> n /// updating a register state `s` at `r` with `v` [@@qattr] let update_reg (s:state) (r:reg) (v:nat64) : state = fun r' -> if r = r' then v else s r' /// updating a register state `s` at `r` with `s' r` [@@qattr] let update_state (r:reg) (s' s:state) : state = update_reg s r (s' r) // We don't have an "ok" flag, so errors just result an arbitrary state: assume val unknown_state (s:state) : state (*** A basic semantics using a big-step interpreter ***) /// Instruction evaluation: /// only some operands are valid let eval_ins (ins:ins) (s:state) : state = match ins with | Mov64 (OConst _) _ -> unknown_state s | Mov64 (OReg dst) src -> update_reg s dst (eval_operand src s) | Add64 (OConst _) _ -> unknown_state s | Add64 (OReg dst) src -> update_reg s dst ((s dst + eval_operand src s) % 0x10000000000000000) /// eval_code: /// A fueled big-step interpreter
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "MiniValeSemantics.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
cs: Prims.list MiniValeSemantics.code -> f: MiniValeSemantics.fuel -> s: MiniValeSemantics.state -> FStar.Pervasives.Native.option MiniValeSemantics.state
Prims.Tot
[ "total" ]
[ "eval_code", "eval_codes" ]
[ "Prims.list", "MiniValeSemantics.code", "MiniValeSemantics.fuel", "MiniValeSemantics.state", "FStar.Pervasives.Native.Some", "MiniValeSemantics.eval_code", "FStar.Pervasives.Native.None", "MiniValeSemantics.eval_codes", "FStar.Pervasives.Native.option" ]
[ "mutual recursion" ]
false
false
false
true
false
let rec eval_codes (cs: list code) (f: fuel) (s: state) : option state =
match cs with | [] -> Some s | c :: cs -> match eval_code c f s with | None -> None | Some s -> eval_codes cs f s
false
MiniValeSemantics.fst
MiniValeSemantics.increase_fuels
val increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code (Block c) f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code (Block c) fN s0 == Some sN) (decreases %[f0; c])
val increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code (Block c) f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code (Block c) fN s0 == Some sN) (decreases %[f0; c])
let rec increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | Ins ins -> () | Block l -> increase_fuels l s0 f0 sN fN | WhileLessThan src1 src2 body -> if eval_operand src1 s0 < eval_operand src2 s0 then match eval_code body f0 s0 with | None -> () | Some s1 -> increase_fuel body s0 f0 s1 fN; increase_fuel c s1 (f0 - 1) sN (fN - 1) else () and increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | [] -> () | h::t -> let Some s1 = eval_code h f0 s0 in increase_fuel h s0 f0 s1 fN; increase_fuels t s1 f0 sN fN
{ "file_name": "examples/metatheory/MiniValeSemantics.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 34, "end_line": 181, "start_col": 0, "start_line": 163 }
(* 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. Authors: C. Hawblitzel, N. Swamy *) module MiniValeSemantics (* This is a highly-simplified model of Vale/F*, based on Section 3.1-3.3 of the paper of the POPL '19 paper. It is derived from the QuickRegs1 code in the popl-artifact-submit branch of Vale. *) /// We use this tag to mark certain definitions /// and control normalization based on it irreducible let qattr = () /// 2^64 let pow2_64 = 0x10000000000000000 /// Natural numbers representable in 64 bits type nat64 = i:int{0 <= i /\ i < pow2_64} /// We have 4 registers type reg = | Rax | Rbx | Rcx | Rdx /// An operand is either a register or a constant type operand = | OReg: r:reg -> operand | OConst: n:nat64 -> operand /// Only 2 instructions here: /// A move or an add type ins = | Mov64: dst:operand -> src:operand -> ins | Add64: dst:operand -> src:operand -> ins /// A program is /// - a single instruction /// - a block of instructions /// - or a while loop type code = | Ins: ins:ins -> code | Block: block:list code -> code | WhileLessThan: src1:operand -> src2:operand -> whileBody:code -> code /// The state of a program is the register file /// holiding a 64-bit value for each register type state = reg -> nat64 /// fuel: To prove the termination of while loops, we're going to /// instrument while loops with fuel type fuel = nat /// Evaluating an operand: /// -- marked for reduction /// -- Registers evaluated by state lookup [@@qattr] let eval_operand (o:operand) (s:state) : nat64 = match o with | OReg r -> s r | OConst n -> n /// updating a register state `s` at `r` with `v` [@@qattr] let update_reg (s:state) (r:reg) (v:nat64) : state = fun r' -> if r = r' then v else s r' /// updating a register state `s` at `r` with `s' r` [@@qattr] let update_state (r:reg) (s' s:state) : state = update_reg s r (s' r) // We don't have an "ok" flag, so errors just result an arbitrary state: assume val unknown_state (s:state) : state (*** A basic semantics using a big-step interpreter ***) /// Instruction evaluation: /// only some operands are valid let eval_ins (ins:ins) (s:state) : state = match ins with | Mov64 (OConst _) _ -> unknown_state s | Mov64 (OReg dst) src -> update_reg s dst (eval_operand src s) | Add64 (OConst _) _ -> unknown_state s | Add64 (OReg dst) src -> update_reg s dst ((s dst + eval_operand src s) % 0x10000000000000000) /// eval_code: /// A fueled big-step interpreter /// While lops return None when we're out of fuel let rec eval_code (c:code) (f:fuel) (s:state) : option state = match c with | Ins ins -> Some (eval_ins ins s) | Block cs -> eval_codes cs f s | WhileLessThan src1 src2 body -> if f = 0 then None else if eval_operand src1 s < eval_operand src2 s then match eval_code body f s with | None -> None | Some s -> eval_code c (f - 1) s else Some s and eval_codes (cs:list code) (f:fuel) (s:state) : option state = match cs with | [] -> Some s | c::cs -> match eval_code c f s with | None -> None | Some s -> eval_codes cs f s (*** END OF TRUSTED SEMANTICS ***) //////////////////////////////////////////////////////////////////////////////// /// 1. We prove that increasing the fuel is irrelevant to terminating executions val increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code c f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code c fN s0 == Some sN) (decreases %[f0; c]) val increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code (Block c) f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code (Block c) fN s0 == Some sN) (decreases %[f0; c])
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "MiniValeSemantics.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: Prims.list MiniValeSemantics.code -> s0: MiniValeSemantics.state -> f0: MiniValeSemantics.fuel -> sN: MiniValeSemantics.state -> fN: MiniValeSemantics.fuel -> FStar.Pervasives.Lemma (requires MiniValeSemantics.eval_code (MiniValeSemantics.Block c) f0 s0 == FStar.Pervasives.Native.Some sN /\ f0 <= fN) (ensures MiniValeSemantics.eval_code (MiniValeSemantics.Block c) fN s0 == FStar.Pervasives.Native.Some sN) (decreases %[f0;c])
FStar.Pervasives.Lemma
[ "lemma", "" ]
[ "increase_fuel", "increase_fuels" ]
[ "Prims.list", "MiniValeSemantics.code", "MiniValeSemantics.state", "MiniValeSemantics.fuel", "MiniValeSemantics.increase_fuels", "Prims.unit", "MiniValeSemantics.increase_fuel", "FStar.Pervasives.Native.option", "MiniValeSemantics.eval_code" ]
[ "mutual recursion" ]
false
false
true
false
false
let rec increase_fuels (c: list code) (s0: state) (f0: fuel) (sN: state) (fN: fuel) =
match c with | [] -> () | h :: t -> let Some s1 = eval_code h f0 s0 in increase_fuel h s0 f0 s1 fN; increase_fuels t s1 f0 sN fN
false
MiniValeSemantics.fst
MiniValeSemantics.inst_Add
val inst_Add (dst src: operand) : with_wp (Ins (Add64 dst src))
val inst_Add (dst src: operand) : with_wp (Ins (Add64 dst src))
let inst_Add (dst:operand) (src:operand) : with_wp (Ins (Add64 dst src)) = QProc (Ins (Add64 dst src)) (wp_Add dst src) (hasWp_Add dst src)
{ "file_name": "examples/metatheory/MiniValeSemantics.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 66, "end_line": 372, "start_col": 0, "start_line": 371 }
(* 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. Authors: C. Hawblitzel, N. Swamy *) module MiniValeSemantics (* This is a highly-simplified model of Vale/F*, based on Section 3.1-3.3 of the paper of the POPL '19 paper. It is derived from the QuickRegs1 code in the popl-artifact-submit branch of Vale. *) /// We use this tag to mark certain definitions /// and control normalization based on it irreducible let qattr = () /// 2^64 let pow2_64 = 0x10000000000000000 /// Natural numbers representable in 64 bits type nat64 = i:int{0 <= i /\ i < pow2_64} /// We have 4 registers type reg = | Rax | Rbx | Rcx | Rdx /// An operand is either a register or a constant type operand = | OReg: r:reg -> operand | OConst: n:nat64 -> operand /// Only 2 instructions here: /// A move or an add type ins = | Mov64: dst:operand -> src:operand -> ins | Add64: dst:operand -> src:operand -> ins /// A program is /// - a single instruction /// - a block of instructions /// - or a while loop type code = | Ins: ins:ins -> code | Block: block:list code -> code | WhileLessThan: src1:operand -> src2:operand -> whileBody:code -> code /// The state of a program is the register file /// holiding a 64-bit value for each register type state = reg -> nat64 /// fuel: To prove the termination of while loops, we're going to /// instrument while loops with fuel type fuel = nat /// Evaluating an operand: /// -- marked for reduction /// -- Registers evaluated by state lookup [@@qattr] let eval_operand (o:operand) (s:state) : nat64 = match o with | OReg r -> s r | OConst n -> n /// updating a register state `s` at `r` with `v` [@@qattr] let update_reg (s:state) (r:reg) (v:nat64) : state = fun r' -> if r = r' then v else s r' /// updating a register state `s` at `r` with `s' r` [@@qattr] let update_state (r:reg) (s' s:state) : state = update_reg s r (s' r) // We don't have an "ok" flag, so errors just result an arbitrary state: assume val unknown_state (s:state) : state (*** A basic semantics using a big-step interpreter ***) /// Instruction evaluation: /// only some operands are valid let eval_ins (ins:ins) (s:state) : state = match ins with | Mov64 (OConst _) _ -> unknown_state s | Mov64 (OReg dst) src -> update_reg s dst (eval_operand src s) | Add64 (OConst _) _ -> unknown_state s | Add64 (OReg dst) src -> update_reg s dst ((s dst + eval_operand src s) % 0x10000000000000000) /// eval_code: /// A fueled big-step interpreter /// While lops return None when we're out of fuel let rec eval_code (c:code) (f:fuel) (s:state) : option state = match c with | Ins ins -> Some (eval_ins ins s) | Block cs -> eval_codes cs f s | WhileLessThan src1 src2 body -> if f = 0 then None else if eval_operand src1 s < eval_operand src2 s then match eval_code body f s with | None -> None | Some s -> eval_code c (f - 1) s else Some s and eval_codes (cs:list code) (f:fuel) (s:state) : option state = match cs with | [] -> Some s | c::cs -> match eval_code c f s with | None -> None | Some s -> eval_codes cs f s (*** END OF TRUSTED SEMANTICS ***) //////////////////////////////////////////////////////////////////////////////// /// 1. We prove that increasing the fuel is irrelevant to terminating executions val increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code c f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code c fN s0 == Some sN) (decreases %[f0; c]) val increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code (Block c) f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code (Block c) fN s0 == Some sN) (decreases %[f0; c]) let rec increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | Ins ins -> () | Block l -> increase_fuels l s0 f0 sN fN | WhileLessThan src1 src2 body -> if eval_operand src1 s0 < eval_operand src2 s0 then match eval_code body f0 s0 with | None -> () | Some s1 -> increase_fuel body s0 f0 s1 fN; increase_fuel c s1 (f0 - 1) sN (fN - 1) else () and increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | [] -> () | h::t -> let Some s1 = eval_code h f0 s0 in increase_fuel h s0 f0 s1 fN; increase_fuels t s1 f0 sN fN /// 2. We can compute the fuel needed to run a sequential composition /// as the max of the fuel to compute each piece of code in it let lemma_merge (c:code) (cs:list code) (s0:state) (f0:fuel) (sM:state) (fM:fuel) (sN:state) : Ghost fuel (requires eval_code c f0 s0 == Some sM /\ eval_code (Block cs) fM sM == Some sN) (ensures fun fN -> eval_code (Block (c::cs)) fN s0 == Some sN) = let f = if f0 > fM then f0 else fM in increase_fuel c s0 f0 sM f; increase_fuel (Block cs) sM fM sN f; f ///////////////////////////////////////////////////////////////// // Now, we're going to define a verification-condition generator // // The main idea is that we're going to: // // 1. define a kind of typeclass, that associates with a // piece of code a weakest-precondition rule for it // // 2. Define a WP-generator that computes WPs for each of the // control constructs of the language, given a program // represented as the raw code packaged with their typeclass // instances for computing their WPs ///////////////////////////////////////////////////////////////// [@@qattr] let t_post = state -> Type0 [@@qattr] let t_pre = state -> Type0 /// t_wp: The type of weakest preconditions let t_wp = t_post -> t_pre /// c `has_wp` wp: The main judgment in our program logic let has_wp (c:code) (wp:t_wp) : Type = k:t_post -> //for any post-condition s0:state -> //and initial state Ghost (state * fuel) (requires wp k s0) //Given the precondition (ensures fun (sM, f0) -> //we can compute the fuel f0 needed so that eval_code c f0 s0 == Some sM /\ //eval_code with that fuel returns sM k sM) //and the post-condition is true on sM /// An abbreviation for a thunked lemma let t_lemma (pre:Type0) (post:Type0) = unit -> Lemma (requires pre) (ensures post) /// `with_wp` : A typeclass for code packaged with its wp [@@qattr] noeq type with_wp : code -> Type = | QProc: c:code -> wp:t_wp -> hasWp:has_wp c wp -> with_wp c /// `with_wps`: A typclass for lists of code values packages with their wps noeq type with_wps : list code -> Type = | QEmpty: //empty list with_wps [] | QSeq: //cons #c:code -> #cs:list code -> hd:with_wp c -> tl:with_wps cs -> with_wps (c::cs) | QLemma: //augmenting an instruction sequence with a lemma #cs:list code -> pre:Type0 -> post:Type0 -> t_lemma pre post -> with_wps cs -> with_wps cs [@@qattr] let rec vc_gen (cs:list code) (qcs:with_wps cs) (k:t_post) : Tot (state -> Tot Type0 (decreases qcs)) = fun s0 -> match qcs with | QEmpty -> k s0 //no instructions; prove the postcondition right away | QSeq qc qcs -> // let pre_tl = //compute the VC generator for the tail, a precondition qc.wp (vc_gen (Cons?.tl cs) qcs k) s0 // in // qc.wp pre_tl s0 //apply the wp-generator to the precondition for the tail | QLemma pre post _ qcs -> pre /\ //prove the precondition of the lemma (post ==> vc_gen cs qcs k s0) //and assume its postcondition to verify the program /// The vc-generator is sound let rec vc_sound (cs:list code) (qcs:with_wps cs) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires vc_gen cs qcs k s0) (ensures fun (sN, fN) -> eval_code (Block cs) fN s0 == Some sN /\ k sN) = match qcs with | QEmpty -> (s0, 0) | QSeq qc qcs -> let Cons c cs' = cs in let (sM, fM) = qc.hasWp (vc_gen cs' qcs k) s0 in let (sN, fN) = vc_sound cs' qcs k sM in let fN' = lemma_merge c cs' s0 fM sM fN sN in (sN, fN') | QLemma pre post lem qcs' -> lem (); vc_sound cs qcs' k s0 let vc_sound' (cs:list code) (qcs:with_wps cs) : has_wp (Block cs) (vc_gen cs qcs) = vc_sound cs qcs (*** Instances of with_wp ***) //////////////////////////////////////////////////////////////////////////////// //Instance for Mov //////////////////////////////////////////////////////////////////////////////// let lemma_Move (s0:state) (dst:operand) (src:operand) : Ghost (state * fuel) (requires OReg? dst) (ensures fun (sM, fM) -> eval_code (Ins (Mov64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0 ) = let Some sM = eval_code (Ins (Mov64 dst src)) 0 s0 in (sM, 0) [@@qattr] let wp_Move (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Type0 = OReg? dst /\ (forall (x:nat64). let sM = update_reg s0 (OReg?.r dst) x in eval_operand dst sM == eval_operand src s0 ==> k sM ) let hasWp_Move (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires wp_Move dst src k s0) (ensures fun (sM, f0) -> eval_code (Ins (Mov64 dst src)) f0 s0 == Some sM /\ k sM) = lemma_Move s0 dst src [@@qattr] let inst_Move (dst:operand) (src:operand) : with_wp (Ins (Mov64 dst src)) = QProc (Ins (Mov64 dst src)) (wp_Move dst src) (hasWp_Move dst src) //////////////////////////////////////////////////////////////////////////////// //Instance for Add //////////////////////////////////////////////////////////////////////////////// let lemma_Add (s0:state) (dst:operand) (src:operand) : Ghost (state * fuel) (requires OReg? dst /\ eval_operand dst s0 + eval_operand src s0 < pow2_64) (ensures fun (sM, fM) -> eval_code (Ins (Add64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand dst s0 + eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0 ) = let Some sM = eval_code (Ins (Add64 dst src)) 0 s0 in (sM, 0) [@@qattr] let wp_Add (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Type0 = OReg? dst /\ eval_operand dst s0 + eval_operand src s0 < pow2_64 /\ (forall (x:nat64). let sM = update_reg s0 (OReg?.r dst) x in eval_operand dst sM == eval_operand dst s0 + eval_operand src s0 ==> k sM ) let hasWp_Add (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires wp_Add dst src k s0) (ensures fun (sM, f0) -> eval_code (Ins (Add64 dst src)) f0 s0 == Some sM /\ k sM) = lemma_Add s0 dst src
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "MiniValeSemantics.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: MiniValeSemantics.operand -> src: MiniValeSemantics.operand -> MiniValeSemantics.with_wp (MiniValeSemantics.Ins (MiniValeSemantics.Add64 dst src))
Prims.Tot
[ "total" ]
[]
[ "MiniValeSemantics.operand", "MiniValeSemantics.QProc", "MiniValeSemantics.Ins", "MiniValeSemantics.Add64", "MiniValeSemantics.wp_Add", "MiniValeSemantics.hasWp_Add", "MiniValeSemantics.with_wp" ]
[]
false
false
false
false
false
let inst_Add (dst src: operand) : with_wp (Ins (Add64 dst src)) =
QProc (Ins (Add64 dst src)) (wp_Add dst src) (hasWp_Add dst src)
false
MiniValeSemantics.fst
MiniValeSemantics.normal_steps
val normal_steps:list string
val normal_steps:list string
let normal_steps : list string = [ `%OReg?; `%OReg?.r; `%QProc?.wp; ]
{ "file_name": "examples/metatheory/MiniValeSemantics.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 3, "end_line": 383, "start_col": 0, "start_line": 378 }
(* 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. Authors: C. Hawblitzel, N. Swamy *) module MiniValeSemantics (* This is a highly-simplified model of Vale/F*, based on Section 3.1-3.3 of the paper of the POPL '19 paper. It is derived from the QuickRegs1 code in the popl-artifact-submit branch of Vale. *) /// We use this tag to mark certain definitions /// and control normalization based on it irreducible let qattr = () /// 2^64 let pow2_64 = 0x10000000000000000 /// Natural numbers representable in 64 bits type nat64 = i:int{0 <= i /\ i < pow2_64} /// We have 4 registers type reg = | Rax | Rbx | Rcx | Rdx /// An operand is either a register or a constant type operand = | OReg: r:reg -> operand | OConst: n:nat64 -> operand /// Only 2 instructions here: /// A move or an add type ins = | Mov64: dst:operand -> src:operand -> ins | Add64: dst:operand -> src:operand -> ins /// A program is /// - a single instruction /// - a block of instructions /// - or a while loop type code = | Ins: ins:ins -> code | Block: block:list code -> code | WhileLessThan: src1:operand -> src2:operand -> whileBody:code -> code /// The state of a program is the register file /// holiding a 64-bit value for each register type state = reg -> nat64 /// fuel: To prove the termination of while loops, we're going to /// instrument while loops with fuel type fuel = nat /// Evaluating an operand: /// -- marked for reduction /// -- Registers evaluated by state lookup [@@qattr] let eval_operand (o:operand) (s:state) : nat64 = match o with | OReg r -> s r | OConst n -> n /// updating a register state `s` at `r` with `v` [@@qattr] let update_reg (s:state) (r:reg) (v:nat64) : state = fun r' -> if r = r' then v else s r' /// updating a register state `s` at `r` with `s' r` [@@qattr] let update_state (r:reg) (s' s:state) : state = update_reg s r (s' r) // We don't have an "ok" flag, so errors just result an arbitrary state: assume val unknown_state (s:state) : state (*** A basic semantics using a big-step interpreter ***) /// Instruction evaluation: /// only some operands are valid let eval_ins (ins:ins) (s:state) : state = match ins with | Mov64 (OConst _) _ -> unknown_state s | Mov64 (OReg dst) src -> update_reg s dst (eval_operand src s) | Add64 (OConst _) _ -> unknown_state s | Add64 (OReg dst) src -> update_reg s dst ((s dst + eval_operand src s) % 0x10000000000000000) /// eval_code: /// A fueled big-step interpreter /// While lops return None when we're out of fuel let rec eval_code (c:code) (f:fuel) (s:state) : option state = match c with | Ins ins -> Some (eval_ins ins s) | Block cs -> eval_codes cs f s | WhileLessThan src1 src2 body -> if f = 0 then None else if eval_operand src1 s < eval_operand src2 s then match eval_code body f s with | None -> None | Some s -> eval_code c (f - 1) s else Some s and eval_codes (cs:list code) (f:fuel) (s:state) : option state = match cs with | [] -> Some s | c::cs -> match eval_code c f s with | None -> None | Some s -> eval_codes cs f s (*** END OF TRUSTED SEMANTICS ***) //////////////////////////////////////////////////////////////////////////////// /// 1. We prove that increasing the fuel is irrelevant to terminating executions val increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code c f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code c fN s0 == Some sN) (decreases %[f0; c]) val increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code (Block c) f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code (Block c) fN s0 == Some sN) (decreases %[f0; c]) let rec increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | Ins ins -> () | Block l -> increase_fuels l s0 f0 sN fN | WhileLessThan src1 src2 body -> if eval_operand src1 s0 < eval_operand src2 s0 then match eval_code body f0 s0 with | None -> () | Some s1 -> increase_fuel body s0 f0 s1 fN; increase_fuel c s1 (f0 - 1) sN (fN - 1) else () and increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | [] -> () | h::t -> let Some s1 = eval_code h f0 s0 in increase_fuel h s0 f0 s1 fN; increase_fuels t s1 f0 sN fN /// 2. We can compute the fuel needed to run a sequential composition /// as the max of the fuel to compute each piece of code in it let lemma_merge (c:code) (cs:list code) (s0:state) (f0:fuel) (sM:state) (fM:fuel) (sN:state) : Ghost fuel (requires eval_code c f0 s0 == Some sM /\ eval_code (Block cs) fM sM == Some sN) (ensures fun fN -> eval_code (Block (c::cs)) fN s0 == Some sN) = let f = if f0 > fM then f0 else fM in increase_fuel c s0 f0 sM f; increase_fuel (Block cs) sM fM sN f; f ///////////////////////////////////////////////////////////////// // Now, we're going to define a verification-condition generator // // The main idea is that we're going to: // // 1. define a kind of typeclass, that associates with a // piece of code a weakest-precondition rule for it // // 2. Define a WP-generator that computes WPs for each of the // control constructs of the language, given a program // represented as the raw code packaged with their typeclass // instances for computing their WPs ///////////////////////////////////////////////////////////////// [@@qattr] let t_post = state -> Type0 [@@qattr] let t_pre = state -> Type0 /// t_wp: The type of weakest preconditions let t_wp = t_post -> t_pre /// c `has_wp` wp: The main judgment in our program logic let has_wp (c:code) (wp:t_wp) : Type = k:t_post -> //for any post-condition s0:state -> //and initial state Ghost (state * fuel) (requires wp k s0) //Given the precondition (ensures fun (sM, f0) -> //we can compute the fuel f0 needed so that eval_code c f0 s0 == Some sM /\ //eval_code with that fuel returns sM k sM) //and the post-condition is true on sM /// An abbreviation for a thunked lemma let t_lemma (pre:Type0) (post:Type0) = unit -> Lemma (requires pre) (ensures post) /// `with_wp` : A typeclass for code packaged with its wp [@@qattr] noeq type with_wp : code -> Type = | QProc: c:code -> wp:t_wp -> hasWp:has_wp c wp -> with_wp c /// `with_wps`: A typclass for lists of code values packages with their wps noeq type with_wps : list code -> Type = | QEmpty: //empty list with_wps [] | QSeq: //cons #c:code -> #cs:list code -> hd:with_wp c -> tl:with_wps cs -> with_wps (c::cs) | QLemma: //augmenting an instruction sequence with a lemma #cs:list code -> pre:Type0 -> post:Type0 -> t_lemma pre post -> with_wps cs -> with_wps cs [@@qattr] let rec vc_gen (cs:list code) (qcs:with_wps cs) (k:t_post) : Tot (state -> Tot Type0 (decreases qcs)) = fun s0 -> match qcs with | QEmpty -> k s0 //no instructions; prove the postcondition right away | QSeq qc qcs -> // let pre_tl = //compute the VC generator for the tail, a precondition qc.wp (vc_gen (Cons?.tl cs) qcs k) s0 // in // qc.wp pre_tl s0 //apply the wp-generator to the precondition for the tail | QLemma pre post _ qcs -> pre /\ //prove the precondition of the lemma (post ==> vc_gen cs qcs k s0) //and assume its postcondition to verify the program /// The vc-generator is sound let rec vc_sound (cs:list code) (qcs:with_wps cs) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires vc_gen cs qcs k s0) (ensures fun (sN, fN) -> eval_code (Block cs) fN s0 == Some sN /\ k sN) = match qcs with | QEmpty -> (s0, 0) | QSeq qc qcs -> let Cons c cs' = cs in let (sM, fM) = qc.hasWp (vc_gen cs' qcs k) s0 in let (sN, fN) = vc_sound cs' qcs k sM in let fN' = lemma_merge c cs' s0 fM sM fN sN in (sN, fN') | QLemma pre post lem qcs' -> lem (); vc_sound cs qcs' k s0 let vc_sound' (cs:list code) (qcs:with_wps cs) : has_wp (Block cs) (vc_gen cs qcs) = vc_sound cs qcs (*** Instances of with_wp ***) //////////////////////////////////////////////////////////////////////////////// //Instance for Mov //////////////////////////////////////////////////////////////////////////////// let lemma_Move (s0:state) (dst:operand) (src:operand) : Ghost (state * fuel) (requires OReg? dst) (ensures fun (sM, fM) -> eval_code (Ins (Mov64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0 ) = let Some sM = eval_code (Ins (Mov64 dst src)) 0 s0 in (sM, 0) [@@qattr] let wp_Move (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Type0 = OReg? dst /\ (forall (x:nat64). let sM = update_reg s0 (OReg?.r dst) x in eval_operand dst sM == eval_operand src s0 ==> k sM ) let hasWp_Move (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires wp_Move dst src k s0) (ensures fun (sM, f0) -> eval_code (Ins (Mov64 dst src)) f0 s0 == Some sM /\ k sM) = lemma_Move s0 dst src [@@qattr] let inst_Move (dst:operand) (src:operand) : with_wp (Ins (Mov64 dst src)) = QProc (Ins (Mov64 dst src)) (wp_Move dst src) (hasWp_Move dst src) //////////////////////////////////////////////////////////////////////////////// //Instance for Add //////////////////////////////////////////////////////////////////////////////// let lemma_Add (s0:state) (dst:operand) (src:operand) : Ghost (state * fuel) (requires OReg? dst /\ eval_operand dst s0 + eval_operand src s0 < pow2_64) (ensures fun (sM, fM) -> eval_code (Ins (Add64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand dst s0 + eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0 ) = let Some sM = eval_code (Ins (Add64 dst src)) 0 s0 in (sM, 0) [@@qattr] let wp_Add (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Type0 = OReg? dst /\ eval_operand dst s0 + eval_operand src s0 < pow2_64 /\ (forall (x:nat64). let sM = update_reg s0 (OReg?.r dst) x in eval_operand dst sM == eval_operand dst s0 + eval_operand src s0 ==> k sM ) let hasWp_Add (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires wp_Add dst src k s0) (ensures fun (sM, f0) -> eval_code (Ins (Add64 dst src)) f0 s0 == Some sM /\ k sM) = lemma_Add s0 dst src [@@qattr] let inst_Add (dst:operand) (src:operand) : with_wp (Ins (Add64 dst src)) = QProc (Ins (Add64 dst src)) (wp_Add dst src) (hasWp_Add dst src) //////////////////////////////////////////////////////////////////////////////// //Running the VC generator using the F* normalizer ////////////////////////////////////////////////////////////////////////////////
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "MiniValeSemantics.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.list Prims.string
Prims.Tot
[ "total" ]
[]
[ "Prims.Cons", "Prims.string", "Prims.Nil" ]
[]
false
false
false
true
false
let normal_steps:list string =
[`%OReg?; `%OReg?.r; `%QProc?.wp]
false
MiniValeSemantics.fst
MiniValeSemantics.normal
val normal (x: Type0) : Type0
val normal (x: Type0) : Type0
let normal (x:Type0) : Type0 = norm [nbe; iota; zeta; simplify; primops; delta_attr [`%qattr]; delta_only normal_steps] x
{ "file_name": "examples/metatheory/MiniValeSemantics.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 92, "end_line": 387, "start_col": 0, "start_line": 386 }
(* 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. Authors: C. Hawblitzel, N. Swamy *) module MiniValeSemantics (* This is a highly-simplified model of Vale/F*, based on Section 3.1-3.3 of the paper of the POPL '19 paper. It is derived from the QuickRegs1 code in the popl-artifact-submit branch of Vale. *) /// We use this tag to mark certain definitions /// and control normalization based on it irreducible let qattr = () /// 2^64 let pow2_64 = 0x10000000000000000 /// Natural numbers representable in 64 bits type nat64 = i:int{0 <= i /\ i < pow2_64} /// We have 4 registers type reg = | Rax | Rbx | Rcx | Rdx /// An operand is either a register or a constant type operand = | OReg: r:reg -> operand | OConst: n:nat64 -> operand /// Only 2 instructions here: /// A move or an add type ins = | Mov64: dst:operand -> src:operand -> ins | Add64: dst:operand -> src:operand -> ins /// A program is /// - a single instruction /// - a block of instructions /// - or a while loop type code = | Ins: ins:ins -> code | Block: block:list code -> code | WhileLessThan: src1:operand -> src2:operand -> whileBody:code -> code /// The state of a program is the register file /// holiding a 64-bit value for each register type state = reg -> nat64 /// fuel: To prove the termination of while loops, we're going to /// instrument while loops with fuel type fuel = nat /// Evaluating an operand: /// -- marked for reduction /// -- Registers evaluated by state lookup [@@qattr] let eval_operand (o:operand) (s:state) : nat64 = match o with | OReg r -> s r | OConst n -> n /// updating a register state `s` at `r` with `v` [@@qattr] let update_reg (s:state) (r:reg) (v:nat64) : state = fun r' -> if r = r' then v else s r' /// updating a register state `s` at `r` with `s' r` [@@qattr] let update_state (r:reg) (s' s:state) : state = update_reg s r (s' r) // We don't have an "ok" flag, so errors just result an arbitrary state: assume val unknown_state (s:state) : state (*** A basic semantics using a big-step interpreter ***) /// Instruction evaluation: /// only some operands are valid let eval_ins (ins:ins) (s:state) : state = match ins with | Mov64 (OConst _) _ -> unknown_state s | Mov64 (OReg dst) src -> update_reg s dst (eval_operand src s) | Add64 (OConst _) _ -> unknown_state s | Add64 (OReg dst) src -> update_reg s dst ((s dst + eval_operand src s) % 0x10000000000000000) /// eval_code: /// A fueled big-step interpreter /// While lops return None when we're out of fuel let rec eval_code (c:code) (f:fuel) (s:state) : option state = match c with | Ins ins -> Some (eval_ins ins s) | Block cs -> eval_codes cs f s | WhileLessThan src1 src2 body -> if f = 0 then None else if eval_operand src1 s < eval_operand src2 s then match eval_code body f s with | None -> None | Some s -> eval_code c (f - 1) s else Some s and eval_codes (cs:list code) (f:fuel) (s:state) : option state = match cs with | [] -> Some s | c::cs -> match eval_code c f s with | None -> None | Some s -> eval_codes cs f s (*** END OF TRUSTED SEMANTICS ***) //////////////////////////////////////////////////////////////////////////////// /// 1. We prove that increasing the fuel is irrelevant to terminating executions val increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code c f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code c fN s0 == Some sN) (decreases %[f0; c]) val increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code (Block c) f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code (Block c) fN s0 == Some sN) (decreases %[f0; c]) let rec increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | Ins ins -> () | Block l -> increase_fuels l s0 f0 sN fN | WhileLessThan src1 src2 body -> if eval_operand src1 s0 < eval_operand src2 s0 then match eval_code body f0 s0 with | None -> () | Some s1 -> increase_fuel body s0 f0 s1 fN; increase_fuel c s1 (f0 - 1) sN (fN - 1) else () and increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | [] -> () | h::t -> let Some s1 = eval_code h f0 s0 in increase_fuel h s0 f0 s1 fN; increase_fuels t s1 f0 sN fN /// 2. We can compute the fuel needed to run a sequential composition /// as the max of the fuel to compute each piece of code in it let lemma_merge (c:code) (cs:list code) (s0:state) (f0:fuel) (sM:state) (fM:fuel) (sN:state) : Ghost fuel (requires eval_code c f0 s0 == Some sM /\ eval_code (Block cs) fM sM == Some sN) (ensures fun fN -> eval_code (Block (c::cs)) fN s0 == Some sN) = let f = if f0 > fM then f0 else fM in increase_fuel c s0 f0 sM f; increase_fuel (Block cs) sM fM sN f; f ///////////////////////////////////////////////////////////////// // Now, we're going to define a verification-condition generator // // The main idea is that we're going to: // // 1. define a kind of typeclass, that associates with a // piece of code a weakest-precondition rule for it // // 2. Define a WP-generator that computes WPs for each of the // control constructs of the language, given a program // represented as the raw code packaged with their typeclass // instances for computing their WPs ///////////////////////////////////////////////////////////////// [@@qattr] let t_post = state -> Type0 [@@qattr] let t_pre = state -> Type0 /// t_wp: The type of weakest preconditions let t_wp = t_post -> t_pre /// c `has_wp` wp: The main judgment in our program logic let has_wp (c:code) (wp:t_wp) : Type = k:t_post -> //for any post-condition s0:state -> //and initial state Ghost (state * fuel) (requires wp k s0) //Given the precondition (ensures fun (sM, f0) -> //we can compute the fuel f0 needed so that eval_code c f0 s0 == Some sM /\ //eval_code with that fuel returns sM k sM) //and the post-condition is true on sM /// An abbreviation for a thunked lemma let t_lemma (pre:Type0) (post:Type0) = unit -> Lemma (requires pre) (ensures post) /// `with_wp` : A typeclass for code packaged with its wp [@@qattr] noeq type with_wp : code -> Type = | QProc: c:code -> wp:t_wp -> hasWp:has_wp c wp -> with_wp c /// `with_wps`: A typclass for lists of code values packages with their wps noeq type with_wps : list code -> Type = | QEmpty: //empty list with_wps [] | QSeq: //cons #c:code -> #cs:list code -> hd:with_wp c -> tl:with_wps cs -> with_wps (c::cs) | QLemma: //augmenting an instruction sequence with a lemma #cs:list code -> pre:Type0 -> post:Type0 -> t_lemma pre post -> with_wps cs -> with_wps cs [@@qattr] let rec vc_gen (cs:list code) (qcs:with_wps cs) (k:t_post) : Tot (state -> Tot Type0 (decreases qcs)) = fun s0 -> match qcs with | QEmpty -> k s0 //no instructions; prove the postcondition right away | QSeq qc qcs -> // let pre_tl = //compute the VC generator for the tail, a precondition qc.wp (vc_gen (Cons?.tl cs) qcs k) s0 // in // qc.wp pre_tl s0 //apply the wp-generator to the precondition for the tail | QLemma pre post _ qcs -> pre /\ //prove the precondition of the lemma (post ==> vc_gen cs qcs k s0) //and assume its postcondition to verify the program /// The vc-generator is sound let rec vc_sound (cs:list code) (qcs:with_wps cs) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires vc_gen cs qcs k s0) (ensures fun (sN, fN) -> eval_code (Block cs) fN s0 == Some sN /\ k sN) = match qcs with | QEmpty -> (s0, 0) | QSeq qc qcs -> let Cons c cs' = cs in let (sM, fM) = qc.hasWp (vc_gen cs' qcs k) s0 in let (sN, fN) = vc_sound cs' qcs k sM in let fN' = lemma_merge c cs' s0 fM sM fN sN in (sN, fN') | QLemma pre post lem qcs' -> lem (); vc_sound cs qcs' k s0 let vc_sound' (cs:list code) (qcs:with_wps cs) : has_wp (Block cs) (vc_gen cs qcs) = vc_sound cs qcs (*** Instances of with_wp ***) //////////////////////////////////////////////////////////////////////////////// //Instance for Mov //////////////////////////////////////////////////////////////////////////////// let lemma_Move (s0:state) (dst:operand) (src:operand) : Ghost (state * fuel) (requires OReg? dst) (ensures fun (sM, fM) -> eval_code (Ins (Mov64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0 ) = let Some sM = eval_code (Ins (Mov64 dst src)) 0 s0 in (sM, 0) [@@qattr] let wp_Move (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Type0 = OReg? dst /\ (forall (x:nat64). let sM = update_reg s0 (OReg?.r dst) x in eval_operand dst sM == eval_operand src s0 ==> k sM ) let hasWp_Move (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires wp_Move dst src k s0) (ensures fun (sM, f0) -> eval_code (Ins (Mov64 dst src)) f0 s0 == Some sM /\ k sM) = lemma_Move s0 dst src [@@qattr] let inst_Move (dst:operand) (src:operand) : with_wp (Ins (Mov64 dst src)) = QProc (Ins (Mov64 dst src)) (wp_Move dst src) (hasWp_Move dst src) //////////////////////////////////////////////////////////////////////////////// //Instance for Add //////////////////////////////////////////////////////////////////////////////// let lemma_Add (s0:state) (dst:operand) (src:operand) : Ghost (state * fuel) (requires OReg? dst /\ eval_operand dst s0 + eval_operand src s0 < pow2_64) (ensures fun (sM, fM) -> eval_code (Ins (Add64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand dst s0 + eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0 ) = let Some sM = eval_code (Ins (Add64 dst src)) 0 s0 in (sM, 0) [@@qattr] let wp_Add (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Type0 = OReg? dst /\ eval_operand dst s0 + eval_operand src s0 < pow2_64 /\ (forall (x:nat64). let sM = update_reg s0 (OReg?.r dst) x in eval_operand dst sM == eval_operand dst s0 + eval_operand src s0 ==> k sM ) let hasWp_Add (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires wp_Add dst src k s0) (ensures fun (sM, f0) -> eval_code (Ins (Add64 dst src)) f0 s0 == Some sM /\ k sM) = lemma_Add s0 dst src [@@qattr] let inst_Add (dst:operand) (src:operand) : with_wp (Ins (Add64 dst src)) = QProc (Ins (Add64 dst src)) (wp_Add dst src) (hasWp_Add dst src) //////////////////////////////////////////////////////////////////////////////// //Running the VC generator using the F* normalizer //////////////////////////////////////////////////////////////////////////////// unfold let normal_steps : list string = [ `%OReg?; `%OReg?.r; `%QProc?.wp; ]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "MiniValeSemantics.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Type0 -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.nbe", "FStar.Pervasives.iota", "FStar.Pervasives.zeta", "FStar.Pervasives.simplify", "FStar.Pervasives.primops", "FStar.Pervasives.delta_attr", "Prims.string", "Prims.Nil", "FStar.Pervasives.delta_only", "MiniValeSemantics.normal_steps" ]
[]
false
false
false
true
true
let normal (x: Type0) : Type0 =
norm [nbe; iota; zeta; simplify; primops; delta_attr [`%qattr]; delta_only normal_steps] x
false
MiniValeSemantics.fst
MiniValeSemantics.vc_sound
val vc_sound (cs: list code) (qcs: with_wps cs) (k: (state -> Type0)) (s0: state) : Ghost (state * fuel) (requires vc_gen cs qcs k s0) (ensures fun (sN, fN) -> eval_code (Block cs) fN s0 == Some sN /\ k sN)
val vc_sound (cs: list code) (qcs: with_wps cs) (k: (state -> Type0)) (s0: state) : Ghost (state * fuel) (requires vc_gen cs qcs k s0) (ensures fun (sN, fN) -> eval_code (Block cs) fN s0 == Some sN /\ k sN)
let rec vc_sound (cs:list code) (qcs:with_wps cs) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires vc_gen cs qcs k s0) (ensures fun (sN, fN) -> eval_code (Block cs) fN s0 == Some sN /\ k sN) = match qcs with | QEmpty -> (s0, 0) | QSeq qc qcs -> let Cons c cs' = cs in let (sM, fM) = qc.hasWp (vc_gen cs' qcs k) s0 in let (sN, fN) = vc_sound cs' qcs k sM in let fN' = lemma_merge c cs' s0 fM sM fN sN in (sN, fN') | QLemma pre post lem qcs' -> lem (); vc_sound cs qcs' k s0
{ "file_name": "examples/metatheory/MiniValeSemantics.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 27, "end_line": 300, "start_col": 0, "start_line": 283 }
(* 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. Authors: C. Hawblitzel, N. Swamy *) module MiniValeSemantics (* This is a highly-simplified model of Vale/F*, based on Section 3.1-3.3 of the paper of the POPL '19 paper. It is derived from the QuickRegs1 code in the popl-artifact-submit branch of Vale. *) /// We use this tag to mark certain definitions /// and control normalization based on it irreducible let qattr = () /// 2^64 let pow2_64 = 0x10000000000000000 /// Natural numbers representable in 64 bits type nat64 = i:int{0 <= i /\ i < pow2_64} /// We have 4 registers type reg = | Rax | Rbx | Rcx | Rdx /// An operand is either a register or a constant type operand = | OReg: r:reg -> operand | OConst: n:nat64 -> operand /// Only 2 instructions here: /// A move or an add type ins = | Mov64: dst:operand -> src:operand -> ins | Add64: dst:operand -> src:operand -> ins /// A program is /// - a single instruction /// - a block of instructions /// - or a while loop type code = | Ins: ins:ins -> code | Block: block:list code -> code | WhileLessThan: src1:operand -> src2:operand -> whileBody:code -> code /// The state of a program is the register file /// holiding a 64-bit value for each register type state = reg -> nat64 /// fuel: To prove the termination of while loops, we're going to /// instrument while loops with fuel type fuel = nat /// Evaluating an operand: /// -- marked for reduction /// -- Registers evaluated by state lookup [@@qattr] let eval_operand (o:operand) (s:state) : nat64 = match o with | OReg r -> s r | OConst n -> n /// updating a register state `s` at `r` with `v` [@@qattr] let update_reg (s:state) (r:reg) (v:nat64) : state = fun r' -> if r = r' then v else s r' /// updating a register state `s` at `r` with `s' r` [@@qattr] let update_state (r:reg) (s' s:state) : state = update_reg s r (s' r) // We don't have an "ok" flag, so errors just result an arbitrary state: assume val unknown_state (s:state) : state (*** A basic semantics using a big-step interpreter ***) /// Instruction evaluation: /// only some operands are valid let eval_ins (ins:ins) (s:state) : state = match ins with | Mov64 (OConst _) _ -> unknown_state s | Mov64 (OReg dst) src -> update_reg s dst (eval_operand src s) | Add64 (OConst _) _ -> unknown_state s | Add64 (OReg dst) src -> update_reg s dst ((s dst + eval_operand src s) % 0x10000000000000000) /// eval_code: /// A fueled big-step interpreter /// While lops return None when we're out of fuel let rec eval_code (c:code) (f:fuel) (s:state) : option state = match c with | Ins ins -> Some (eval_ins ins s) | Block cs -> eval_codes cs f s | WhileLessThan src1 src2 body -> if f = 0 then None else if eval_operand src1 s < eval_operand src2 s then match eval_code body f s with | None -> None | Some s -> eval_code c (f - 1) s else Some s and eval_codes (cs:list code) (f:fuel) (s:state) : option state = match cs with | [] -> Some s | c::cs -> match eval_code c f s with | None -> None | Some s -> eval_codes cs f s (*** END OF TRUSTED SEMANTICS ***) //////////////////////////////////////////////////////////////////////////////// /// 1. We prove that increasing the fuel is irrelevant to terminating executions val increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code c f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code c fN s0 == Some sN) (decreases %[f0; c]) val increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code (Block c) f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code (Block c) fN s0 == Some sN) (decreases %[f0; c]) let rec increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | Ins ins -> () | Block l -> increase_fuels l s0 f0 sN fN | WhileLessThan src1 src2 body -> if eval_operand src1 s0 < eval_operand src2 s0 then match eval_code body f0 s0 with | None -> () | Some s1 -> increase_fuel body s0 f0 s1 fN; increase_fuel c s1 (f0 - 1) sN (fN - 1) else () and increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | [] -> () | h::t -> let Some s1 = eval_code h f0 s0 in increase_fuel h s0 f0 s1 fN; increase_fuels t s1 f0 sN fN /// 2. We can compute the fuel needed to run a sequential composition /// as the max of the fuel to compute each piece of code in it let lemma_merge (c:code) (cs:list code) (s0:state) (f0:fuel) (sM:state) (fM:fuel) (sN:state) : Ghost fuel (requires eval_code c f0 s0 == Some sM /\ eval_code (Block cs) fM sM == Some sN) (ensures fun fN -> eval_code (Block (c::cs)) fN s0 == Some sN) = let f = if f0 > fM then f0 else fM in increase_fuel c s0 f0 sM f; increase_fuel (Block cs) sM fM sN f; f ///////////////////////////////////////////////////////////////// // Now, we're going to define a verification-condition generator // // The main idea is that we're going to: // // 1. define a kind of typeclass, that associates with a // piece of code a weakest-precondition rule for it // // 2. Define a WP-generator that computes WPs for each of the // control constructs of the language, given a program // represented as the raw code packaged with their typeclass // instances for computing their WPs ///////////////////////////////////////////////////////////////// [@@qattr] let t_post = state -> Type0 [@@qattr] let t_pre = state -> Type0 /// t_wp: The type of weakest preconditions let t_wp = t_post -> t_pre /// c `has_wp` wp: The main judgment in our program logic let has_wp (c:code) (wp:t_wp) : Type = k:t_post -> //for any post-condition s0:state -> //and initial state Ghost (state * fuel) (requires wp k s0) //Given the precondition (ensures fun (sM, f0) -> //we can compute the fuel f0 needed so that eval_code c f0 s0 == Some sM /\ //eval_code with that fuel returns sM k sM) //and the post-condition is true on sM /// An abbreviation for a thunked lemma let t_lemma (pre:Type0) (post:Type0) = unit -> Lemma (requires pre) (ensures post) /// `with_wp` : A typeclass for code packaged with its wp [@@qattr] noeq type with_wp : code -> Type = | QProc: c:code -> wp:t_wp -> hasWp:has_wp c wp -> with_wp c /// `with_wps`: A typclass for lists of code values packages with their wps noeq type with_wps : list code -> Type = | QEmpty: //empty list with_wps [] | QSeq: //cons #c:code -> #cs:list code -> hd:with_wp c -> tl:with_wps cs -> with_wps (c::cs) | QLemma: //augmenting an instruction sequence with a lemma #cs:list code -> pre:Type0 -> post:Type0 -> t_lemma pre post -> with_wps cs -> with_wps cs [@@qattr] let rec vc_gen (cs:list code) (qcs:with_wps cs) (k:t_post) : Tot (state -> Tot Type0 (decreases qcs)) = fun s0 -> match qcs with | QEmpty -> k s0 //no instructions; prove the postcondition right away | QSeq qc qcs -> // let pre_tl = //compute the VC generator for the tail, a precondition qc.wp (vc_gen (Cons?.tl cs) qcs k) s0 // in // qc.wp pre_tl s0 //apply the wp-generator to the precondition for the tail | QLemma pre post _ qcs -> pre /\ //prove the precondition of the lemma (post ==> vc_gen cs qcs k s0) //and assume its postcondition to verify the program
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "MiniValeSemantics.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
cs: Prims.list MiniValeSemantics.code -> qcs: MiniValeSemantics.with_wps cs -> k: (_: MiniValeSemantics.state -> Type0) -> s0: MiniValeSemantics.state -> Prims.Ghost (MiniValeSemantics.state * MiniValeSemantics.fuel)
Prims.Ghost
[]
[]
[ "Prims.list", "MiniValeSemantics.code", "MiniValeSemantics.with_wps", "MiniValeSemantics.state", "FStar.Pervasives.Native.Mktuple2", "MiniValeSemantics.fuel", "MiniValeSemantics.with_wp", "MiniValeSemantics.lemma_merge", "FStar.Pervasives.Native.tuple2", "MiniValeSemantics.vc_sound", "MiniValeSemantics.__proj__QProc__item__hasWp", "MiniValeSemantics.vc_gen", "MiniValeSemantics.t_lemma", "Prims.unit", "Prims.l_and", "Prims.eq2", "FStar.Pervasives.Native.option", "MiniValeSemantics.eval_code", "MiniValeSemantics.Block", "FStar.Pervasives.Native.Some" ]
[ "recursion" ]
false
false
false
false
false
let rec vc_sound (cs: list code) (qcs: with_wps cs) (k: (state -> Type0)) (s0: state) : Ghost (state * fuel) (requires vc_gen cs qcs k s0) (ensures fun (sN, fN) -> eval_code (Block cs) fN s0 == Some sN /\ k sN) =
match qcs with | QEmpty -> (s0, 0) | QSeq qc qcs -> let Cons c cs' = cs in let sM, fM = qc.hasWp (vc_gen cs' qcs k) s0 in let sN, fN = vc_sound cs' qcs k sM in let fN' = lemma_merge c cs' s0 fM sM fN sN in (sN, fN') | QLemma pre post lem qcs' -> lem (); vc_sound cs qcs' k s0
false
MiniValeSemantics.fst
MiniValeSemantics.vc_gen
val vc_gen (cs: list code) (qcs: with_wps cs) (k: t_post) : Tot (state -> Tot Type0 (decreases qcs))
val vc_gen (cs: list code) (qcs: with_wps cs) (k: t_post) : Tot (state -> Tot Type0 (decreases qcs))
let rec vc_gen (cs:list code) (qcs:with_wps cs) (k:t_post) : Tot (state -> Tot Type0 (decreases qcs)) = fun s0 -> match qcs with | QEmpty -> k s0 //no instructions; prove the postcondition right away | QSeq qc qcs -> // let pre_tl = //compute the VC generator for the tail, a precondition qc.wp (vc_gen (Cons?.tl cs) qcs k) s0 // in // qc.wp pre_tl s0 //apply the wp-generator to the precondition for the tail | QLemma pre post _ qcs -> pre /\ //prove the precondition of the lemma (post ==> vc_gen cs qcs k s0)
{ "file_name": "examples/metatheory/MiniValeSemantics.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 33, "end_line": 280, "start_col": 0, "start_line": 264 }
(* 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. Authors: C. Hawblitzel, N. Swamy *) module MiniValeSemantics (* This is a highly-simplified model of Vale/F*, based on Section 3.1-3.3 of the paper of the POPL '19 paper. It is derived from the QuickRegs1 code in the popl-artifact-submit branch of Vale. *) /// We use this tag to mark certain definitions /// and control normalization based on it irreducible let qattr = () /// 2^64 let pow2_64 = 0x10000000000000000 /// Natural numbers representable in 64 bits type nat64 = i:int{0 <= i /\ i < pow2_64} /// We have 4 registers type reg = | Rax | Rbx | Rcx | Rdx /// An operand is either a register or a constant type operand = | OReg: r:reg -> operand | OConst: n:nat64 -> operand /// Only 2 instructions here: /// A move or an add type ins = | Mov64: dst:operand -> src:operand -> ins | Add64: dst:operand -> src:operand -> ins /// A program is /// - a single instruction /// - a block of instructions /// - or a while loop type code = | Ins: ins:ins -> code | Block: block:list code -> code | WhileLessThan: src1:operand -> src2:operand -> whileBody:code -> code /// The state of a program is the register file /// holiding a 64-bit value for each register type state = reg -> nat64 /// fuel: To prove the termination of while loops, we're going to /// instrument while loops with fuel type fuel = nat /// Evaluating an operand: /// -- marked for reduction /// -- Registers evaluated by state lookup [@@qattr] let eval_operand (o:operand) (s:state) : nat64 = match o with | OReg r -> s r | OConst n -> n /// updating a register state `s` at `r` with `v` [@@qattr] let update_reg (s:state) (r:reg) (v:nat64) : state = fun r' -> if r = r' then v else s r' /// updating a register state `s` at `r` with `s' r` [@@qattr] let update_state (r:reg) (s' s:state) : state = update_reg s r (s' r) // We don't have an "ok" flag, so errors just result an arbitrary state: assume val unknown_state (s:state) : state (*** A basic semantics using a big-step interpreter ***) /// Instruction evaluation: /// only some operands are valid let eval_ins (ins:ins) (s:state) : state = match ins with | Mov64 (OConst _) _ -> unknown_state s | Mov64 (OReg dst) src -> update_reg s dst (eval_operand src s) | Add64 (OConst _) _ -> unknown_state s | Add64 (OReg dst) src -> update_reg s dst ((s dst + eval_operand src s) % 0x10000000000000000) /// eval_code: /// A fueled big-step interpreter /// While lops return None when we're out of fuel let rec eval_code (c:code) (f:fuel) (s:state) : option state = match c with | Ins ins -> Some (eval_ins ins s) | Block cs -> eval_codes cs f s | WhileLessThan src1 src2 body -> if f = 0 then None else if eval_operand src1 s < eval_operand src2 s then match eval_code body f s with | None -> None | Some s -> eval_code c (f - 1) s else Some s and eval_codes (cs:list code) (f:fuel) (s:state) : option state = match cs with | [] -> Some s | c::cs -> match eval_code c f s with | None -> None | Some s -> eval_codes cs f s (*** END OF TRUSTED SEMANTICS ***) //////////////////////////////////////////////////////////////////////////////// /// 1. We prove that increasing the fuel is irrelevant to terminating executions val increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code c f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code c fN s0 == Some sN) (decreases %[f0; c]) val increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code (Block c) f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code (Block c) fN s0 == Some sN) (decreases %[f0; c]) let rec increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | Ins ins -> () | Block l -> increase_fuels l s0 f0 sN fN | WhileLessThan src1 src2 body -> if eval_operand src1 s0 < eval_operand src2 s0 then match eval_code body f0 s0 with | None -> () | Some s1 -> increase_fuel body s0 f0 s1 fN; increase_fuel c s1 (f0 - 1) sN (fN - 1) else () and increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | [] -> () | h::t -> let Some s1 = eval_code h f0 s0 in increase_fuel h s0 f0 s1 fN; increase_fuels t s1 f0 sN fN /// 2. We can compute the fuel needed to run a sequential composition /// as the max of the fuel to compute each piece of code in it let lemma_merge (c:code) (cs:list code) (s0:state) (f0:fuel) (sM:state) (fM:fuel) (sN:state) : Ghost fuel (requires eval_code c f0 s0 == Some sM /\ eval_code (Block cs) fM sM == Some sN) (ensures fun fN -> eval_code (Block (c::cs)) fN s0 == Some sN) = let f = if f0 > fM then f0 else fM in increase_fuel c s0 f0 sM f; increase_fuel (Block cs) sM fM sN f; f ///////////////////////////////////////////////////////////////// // Now, we're going to define a verification-condition generator // // The main idea is that we're going to: // // 1. define a kind of typeclass, that associates with a // piece of code a weakest-precondition rule for it // // 2. Define a WP-generator that computes WPs for each of the // control constructs of the language, given a program // represented as the raw code packaged with their typeclass // instances for computing their WPs ///////////////////////////////////////////////////////////////// [@@qattr] let t_post = state -> Type0 [@@qattr] let t_pre = state -> Type0 /// t_wp: The type of weakest preconditions let t_wp = t_post -> t_pre /// c `has_wp` wp: The main judgment in our program logic let has_wp (c:code) (wp:t_wp) : Type = k:t_post -> //for any post-condition s0:state -> //and initial state Ghost (state * fuel) (requires wp k s0) //Given the precondition (ensures fun (sM, f0) -> //we can compute the fuel f0 needed so that eval_code c f0 s0 == Some sM /\ //eval_code with that fuel returns sM k sM) //and the post-condition is true on sM /// An abbreviation for a thunked lemma let t_lemma (pre:Type0) (post:Type0) = unit -> Lemma (requires pre) (ensures post) /// `with_wp` : A typeclass for code packaged with its wp [@@qattr] noeq type with_wp : code -> Type = | QProc: c:code -> wp:t_wp -> hasWp:has_wp c wp -> with_wp c /// `with_wps`: A typclass for lists of code values packages with their wps noeq type with_wps : list code -> Type = | QEmpty: //empty list with_wps [] | QSeq: //cons #c:code -> #cs:list code -> hd:with_wp c -> tl:with_wps cs -> with_wps (c::cs) | QLemma: //augmenting an instruction sequence with a lemma #cs:list code -> pre:Type0 -> post:Type0 -> t_lemma pre post -> with_wps cs -> with_wps cs
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "MiniValeSemantics.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
cs: Prims.list MiniValeSemantics.code -> qcs: MiniValeSemantics.with_wps cs -> k: MiniValeSemantics.t_post -> _: MiniValeSemantics.state -> Prims.Tot Type0
Prims.Tot
[ "total", "" ]
[]
[ "Prims.list", "MiniValeSemantics.code", "MiniValeSemantics.with_wps", "MiniValeSemantics.t_post", "MiniValeSemantics.state", "MiniValeSemantics.with_wp", "MiniValeSemantics.__proj__QProc__item__wp", "MiniValeSemantics.vc_gen", "Prims.__proj__Cons__item__tl", "MiniValeSemantics.t_lemma", "Prims.l_and", "Prims.l_imp" ]
[ "recursion" ]
false
false
false
false
true
let rec vc_gen (cs: list code) (qcs: with_wps cs) (k: t_post) : Tot (state -> Tot Type0 (decreases qcs)) =
fun s0 -> match qcs with | QEmpty -> k s0 | QSeq qc qcs -> qc.wp (vc_gen (Cons?.tl cs) qcs k) s0 | QLemma pre post _ qcs -> pre /\ (post ==> vc_gen cs qcs k s0)
false
MiniValeSemantics.fst
MiniValeSemantics.hasWp_Move
val hasWp_Move (dst src: operand) (k: (state -> Type0)) (s0: state) : Ghost (state * fuel) (requires wp_Move dst src k s0) (ensures fun (sM, f0) -> eval_code (Ins (Mov64 dst src)) f0 s0 == Some sM /\ k sM)
val hasWp_Move (dst src: operand) (k: (state -> Type0)) (s0: state) : Ghost (state * fuel) (requires wp_Move dst src k s0) (ensures fun (sM, f0) -> eval_code (Ins (Mov64 dst src)) f0 s0 == Some sM /\ k sM)
let hasWp_Move (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires wp_Move dst src k s0) (ensures fun (sM, f0) -> eval_code (Ins (Mov64 dst src)) f0 s0 == Some sM /\ k sM) = lemma_Move s0 dst src
{ "file_name": "examples/metatheory/MiniValeSemantics.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 23, "end_line": 336, "start_col": 0, "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. Authors: C. Hawblitzel, N. Swamy *) module MiniValeSemantics (* This is a highly-simplified model of Vale/F*, based on Section 3.1-3.3 of the paper of the POPL '19 paper. It is derived from the QuickRegs1 code in the popl-artifact-submit branch of Vale. *) /// We use this tag to mark certain definitions /// and control normalization based on it irreducible let qattr = () /// 2^64 let pow2_64 = 0x10000000000000000 /// Natural numbers representable in 64 bits type nat64 = i:int{0 <= i /\ i < pow2_64} /// We have 4 registers type reg = | Rax | Rbx | Rcx | Rdx /// An operand is either a register or a constant type operand = | OReg: r:reg -> operand | OConst: n:nat64 -> operand /// Only 2 instructions here: /// A move or an add type ins = | Mov64: dst:operand -> src:operand -> ins | Add64: dst:operand -> src:operand -> ins /// A program is /// - a single instruction /// - a block of instructions /// - or a while loop type code = | Ins: ins:ins -> code | Block: block:list code -> code | WhileLessThan: src1:operand -> src2:operand -> whileBody:code -> code /// The state of a program is the register file /// holiding a 64-bit value for each register type state = reg -> nat64 /// fuel: To prove the termination of while loops, we're going to /// instrument while loops with fuel type fuel = nat /// Evaluating an operand: /// -- marked for reduction /// -- Registers evaluated by state lookup [@@qattr] let eval_operand (o:operand) (s:state) : nat64 = match o with | OReg r -> s r | OConst n -> n /// updating a register state `s` at `r` with `v` [@@qattr] let update_reg (s:state) (r:reg) (v:nat64) : state = fun r' -> if r = r' then v else s r' /// updating a register state `s` at `r` with `s' r` [@@qattr] let update_state (r:reg) (s' s:state) : state = update_reg s r (s' r) // We don't have an "ok" flag, so errors just result an arbitrary state: assume val unknown_state (s:state) : state (*** A basic semantics using a big-step interpreter ***) /// Instruction evaluation: /// only some operands are valid let eval_ins (ins:ins) (s:state) : state = match ins with | Mov64 (OConst _) _ -> unknown_state s | Mov64 (OReg dst) src -> update_reg s dst (eval_operand src s) | Add64 (OConst _) _ -> unknown_state s | Add64 (OReg dst) src -> update_reg s dst ((s dst + eval_operand src s) % 0x10000000000000000) /// eval_code: /// A fueled big-step interpreter /// While lops return None when we're out of fuel let rec eval_code (c:code) (f:fuel) (s:state) : option state = match c with | Ins ins -> Some (eval_ins ins s) | Block cs -> eval_codes cs f s | WhileLessThan src1 src2 body -> if f = 0 then None else if eval_operand src1 s < eval_operand src2 s then match eval_code body f s with | None -> None | Some s -> eval_code c (f - 1) s else Some s and eval_codes (cs:list code) (f:fuel) (s:state) : option state = match cs with | [] -> Some s | c::cs -> match eval_code c f s with | None -> None | Some s -> eval_codes cs f s (*** END OF TRUSTED SEMANTICS ***) //////////////////////////////////////////////////////////////////////////////// /// 1. We prove that increasing the fuel is irrelevant to terminating executions val increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code c f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code c fN s0 == Some sN) (decreases %[f0; c]) val increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code (Block c) f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code (Block c) fN s0 == Some sN) (decreases %[f0; c]) let rec increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | Ins ins -> () | Block l -> increase_fuels l s0 f0 sN fN | WhileLessThan src1 src2 body -> if eval_operand src1 s0 < eval_operand src2 s0 then match eval_code body f0 s0 with | None -> () | Some s1 -> increase_fuel body s0 f0 s1 fN; increase_fuel c s1 (f0 - 1) sN (fN - 1) else () and increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | [] -> () | h::t -> let Some s1 = eval_code h f0 s0 in increase_fuel h s0 f0 s1 fN; increase_fuels t s1 f0 sN fN /// 2. We can compute the fuel needed to run a sequential composition /// as the max of the fuel to compute each piece of code in it let lemma_merge (c:code) (cs:list code) (s0:state) (f0:fuel) (sM:state) (fM:fuel) (sN:state) : Ghost fuel (requires eval_code c f0 s0 == Some sM /\ eval_code (Block cs) fM sM == Some sN) (ensures fun fN -> eval_code (Block (c::cs)) fN s0 == Some sN) = let f = if f0 > fM then f0 else fM in increase_fuel c s0 f0 sM f; increase_fuel (Block cs) sM fM sN f; f ///////////////////////////////////////////////////////////////// // Now, we're going to define a verification-condition generator // // The main idea is that we're going to: // // 1. define a kind of typeclass, that associates with a // piece of code a weakest-precondition rule for it // // 2. Define a WP-generator that computes WPs for each of the // control constructs of the language, given a program // represented as the raw code packaged with their typeclass // instances for computing their WPs ///////////////////////////////////////////////////////////////// [@@qattr] let t_post = state -> Type0 [@@qattr] let t_pre = state -> Type0 /// t_wp: The type of weakest preconditions let t_wp = t_post -> t_pre /// c `has_wp` wp: The main judgment in our program logic let has_wp (c:code) (wp:t_wp) : Type = k:t_post -> //for any post-condition s0:state -> //and initial state Ghost (state * fuel) (requires wp k s0) //Given the precondition (ensures fun (sM, f0) -> //we can compute the fuel f0 needed so that eval_code c f0 s0 == Some sM /\ //eval_code with that fuel returns sM k sM) //and the post-condition is true on sM /// An abbreviation for a thunked lemma let t_lemma (pre:Type0) (post:Type0) = unit -> Lemma (requires pre) (ensures post) /// `with_wp` : A typeclass for code packaged with its wp [@@qattr] noeq type with_wp : code -> Type = | QProc: c:code -> wp:t_wp -> hasWp:has_wp c wp -> with_wp c /// `with_wps`: A typclass for lists of code values packages with their wps noeq type with_wps : list code -> Type = | QEmpty: //empty list with_wps [] | QSeq: //cons #c:code -> #cs:list code -> hd:with_wp c -> tl:with_wps cs -> with_wps (c::cs) | QLemma: //augmenting an instruction sequence with a lemma #cs:list code -> pre:Type0 -> post:Type0 -> t_lemma pre post -> with_wps cs -> with_wps cs [@@qattr] let rec vc_gen (cs:list code) (qcs:with_wps cs) (k:t_post) : Tot (state -> Tot Type0 (decreases qcs)) = fun s0 -> match qcs with | QEmpty -> k s0 //no instructions; prove the postcondition right away | QSeq qc qcs -> // let pre_tl = //compute the VC generator for the tail, a precondition qc.wp (vc_gen (Cons?.tl cs) qcs k) s0 // in // qc.wp pre_tl s0 //apply the wp-generator to the precondition for the tail | QLemma pre post _ qcs -> pre /\ //prove the precondition of the lemma (post ==> vc_gen cs qcs k s0) //and assume its postcondition to verify the program /// The vc-generator is sound let rec vc_sound (cs:list code) (qcs:with_wps cs) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires vc_gen cs qcs k s0) (ensures fun (sN, fN) -> eval_code (Block cs) fN s0 == Some sN /\ k sN) = match qcs with | QEmpty -> (s0, 0) | QSeq qc qcs -> let Cons c cs' = cs in let (sM, fM) = qc.hasWp (vc_gen cs' qcs k) s0 in let (sN, fN) = vc_sound cs' qcs k sM in let fN' = lemma_merge c cs' s0 fM sM fN sN in (sN, fN') | QLemma pre post lem qcs' -> lem (); vc_sound cs qcs' k s0 let vc_sound' (cs:list code) (qcs:with_wps cs) : has_wp (Block cs) (vc_gen cs qcs) = vc_sound cs qcs (*** Instances of with_wp ***) //////////////////////////////////////////////////////////////////////////////// //Instance for Mov //////////////////////////////////////////////////////////////////////////////// let lemma_Move (s0:state) (dst:operand) (src:operand) : Ghost (state * fuel) (requires OReg? dst) (ensures fun (sM, fM) -> eval_code (Ins (Mov64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0 ) = let Some sM = eval_code (Ins (Mov64 dst src)) 0 s0 in (sM, 0) [@@qattr] let wp_Move (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Type0 = OReg? dst /\ (forall (x:nat64). let sM = update_reg s0 (OReg?.r dst) x in eval_operand dst sM == eval_operand src s0 ==> k sM )
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "MiniValeSemantics.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: MiniValeSemantics.operand -> src: MiniValeSemantics.operand -> k: (_: MiniValeSemantics.state -> Type0) -> s0: MiniValeSemantics.state -> Prims.Ghost (MiniValeSemantics.state * MiniValeSemantics.fuel)
Prims.Ghost
[]
[]
[ "MiniValeSemantics.operand", "MiniValeSemantics.state", "MiniValeSemantics.lemma_Move", "FStar.Pervasives.Native.tuple2", "MiniValeSemantics.fuel", "MiniValeSemantics.wp_Move", "Prims.l_and", "Prims.eq2", "FStar.Pervasives.Native.option", "MiniValeSemantics.eval_code", "MiniValeSemantics.Ins", "MiniValeSemantics.Mov64", "FStar.Pervasives.Native.Some" ]
[]
false
false
false
false
false
let hasWp_Move (dst src: operand) (k: (state -> Type0)) (s0: state) : Ghost (state * fuel) (requires wp_Move dst src k s0) (ensures fun (sM, f0) -> eval_code (Ins (Mov64 dst src)) f0 s0 == Some sM /\ k sM) =
lemma_Move s0 dst src
false
MiniValeSemantics.fst
MiniValeSemantics.lemma_Move
val lemma_Move (s0: state) (dst src: operand) : Ghost (state * fuel) (requires OReg? dst) (ensures fun (sM, fM) -> eval_code (Ins (Mov64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0)
val lemma_Move (s0: state) (dst src: operand) : Ghost (state * fuel) (requires OReg? dst) (ensures fun (sM, fM) -> eval_code (Ins (Mov64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0)
let lemma_Move (s0:state) (dst:operand) (src:operand) : Ghost (state * fuel) (requires OReg? dst) (ensures fun (sM, fM) -> eval_code (Ins (Mov64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0 ) = let Some sM = eval_code (Ins (Mov64 dst src)) 0 s0 in (sM, 0)
{ "file_name": "examples/metatheory/MiniValeSemantics.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 9, "end_line": 322, "start_col": 0, "start_line": 312 }
(* 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. Authors: C. Hawblitzel, N. Swamy *) module MiniValeSemantics (* This is a highly-simplified model of Vale/F*, based on Section 3.1-3.3 of the paper of the POPL '19 paper. It is derived from the QuickRegs1 code in the popl-artifact-submit branch of Vale. *) /// We use this tag to mark certain definitions /// and control normalization based on it irreducible let qattr = () /// 2^64 let pow2_64 = 0x10000000000000000 /// Natural numbers representable in 64 bits type nat64 = i:int{0 <= i /\ i < pow2_64} /// We have 4 registers type reg = | Rax | Rbx | Rcx | Rdx /// An operand is either a register or a constant type operand = | OReg: r:reg -> operand | OConst: n:nat64 -> operand /// Only 2 instructions here: /// A move or an add type ins = | Mov64: dst:operand -> src:operand -> ins | Add64: dst:operand -> src:operand -> ins /// A program is /// - a single instruction /// - a block of instructions /// - or a while loop type code = | Ins: ins:ins -> code | Block: block:list code -> code | WhileLessThan: src1:operand -> src2:operand -> whileBody:code -> code /// The state of a program is the register file /// holiding a 64-bit value for each register type state = reg -> nat64 /// fuel: To prove the termination of while loops, we're going to /// instrument while loops with fuel type fuel = nat /// Evaluating an operand: /// -- marked for reduction /// -- Registers evaluated by state lookup [@@qattr] let eval_operand (o:operand) (s:state) : nat64 = match o with | OReg r -> s r | OConst n -> n /// updating a register state `s` at `r` with `v` [@@qattr] let update_reg (s:state) (r:reg) (v:nat64) : state = fun r' -> if r = r' then v else s r' /// updating a register state `s` at `r` with `s' r` [@@qattr] let update_state (r:reg) (s' s:state) : state = update_reg s r (s' r) // We don't have an "ok" flag, so errors just result an arbitrary state: assume val unknown_state (s:state) : state (*** A basic semantics using a big-step interpreter ***) /// Instruction evaluation: /// only some operands are valid let eval_ins (ins:ins) (s:state) : state = match ins with | Mov64 (OConst _) _ -> unknown_state s | Mov64 (OReg dst) src -> update_reg s dst (eval_operand src s) | Add64 (OConst _) _ -> unknown_state s | Add64 (OReg dst) src -> update_reg s dst ((s dst + eval_operand src s) % 0x10000000000000000) /// eval_code: /// A fueled big-step interpreter /// While lops return None when we're out of fuel let rec eval_code (c:code) (f:fuel) (s:state) : option state = match c with | Ins ins -> Some (eval_ins ins s) | Block cs -> eval_codes cs f s | WhileLessThan src1 src2 body -> if f = 0 then None else if eval_operand src1 s < eval_operand src2 s then match eval_code body f s with | None -> None | Some s -> eval_code c (f - 1) s else Some s and eval_codes (cs:list code) (f:fuel) (s:state) : option state = match cs with | [] -> Some s | c::cs -> match eval_code c f s with | None -> None | Some s -> eval_codes cs f s (*** END OF TRUSTED SEMANTICS ***) //////////////////////////////////////////////////////////////////////////////// /// 1. We prove that increasing the fuel is irrelevant to terminating executions val increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code c f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code c fN s0 == Some sN) (decreases %[f0; c]) val increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code (Block c) f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code (Block c) fN s0 == Some sN) (decreases %[f0; c]) let rec increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | Ins ins -> () | Block l -> increase_fuels l s0 f0 sN fN | WhileLessThan src1 src2 body -> if eval_operand src1 s0 < eval_operand src2 s0 then match eval_code body f0 s0 with | None -> () | Some s1 -> increase_fuel body s0 f0 s1 fN; increase_fuel c s1 (f0 - 1) sN (fN - 1) else () and increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | [] -> () | h::t -> let Some s1 = eval_code h f0 s0 in increase_fuel h s0 f0 s1 fN; increase_fuels t s1 f0 sN fN /// 2. We can compute the fuel needed to run a sequential composition /// as the max of the fuel to compute each piece of code in it let lemma_merge (c:code) (cs:list code) (s0:state) (f0:fuel) (sM:state) (fM:fuel) (sN:state) : Ghost fuel (requires eval_code c f0 s0 == Some sM /\ eval_code (Block cs) fM sM == Some sN) (ensures fun fN -> eval_code (Block (c::cs)) fN s0 == Some sN) = let f = if f0 > fM then f0 else fM in increase_fuel c s0 f0 sM f; increase_fuel (Block cs) sM fM sN f; f ///////////////////////////////////////////////////////////////// // Now, we're going to define a verification-condition generator // // The main idea is that we're going to: // // 1. define a kind of typeclass, that associates with a // piece of code a weakest-precondition rule for it // // 2. Define a WP-generator that computes WPs for each of the // control constructs of the language, given a program // represented as the raw code packaged with their typeclass // instances for computing their WPs ///////////////////////////////////////////////////////////////// [@@qattr] let t_post = state -> Type0 [@@qattr] let t_pre = state -> Type0 /// t_wp: The type of weakest preconditions let t_wp = t_post -> t_pre /// c `has_wp` wp: The main judgment in our program logic let has_wp (c:code) (wp:t_wp) : Type = k:t_post -> //for any post-condition s0:state -> //and initial state Ghost (state * fuel) (requires wp k s0) //Given the precondition (ensures fun (sM, f0) -> //we can compute the fuel f0 needed so that eval_code c f0 s0 == Some sM /\ //eval_code with that fuel returns sM k sM) //and the post-condition is true on sM /// An abbreviation for a thunked lemma let t_lemma (pre:Type0) (post:Type0) = unit -> Lemma (requires pre) (ensures post) /// `with_wp` : A typeclass for code packaged with its wp [@@qattr] noeq type with_wp : code -> Type = | QProc: c:code -> wp:t_wp -> hasWp:has_wp c wp -> with_wp c /// `with_wps`: A typclass for lists of code values packages with their wps noeq type with_wps : list code -> Type = | QEmpty: //empty list with_wps [] | QSeq: //cons #c:code -> #cs:list code -> hd:with_wp c -> tl:with_wps cs -> with_wps (c::cs) | QLemma: //augmenting an instruction sequence with a lemma #cs:list code -> pre:Type0 -> post:Type0 -> t_lemma pre post -> with_wps cs -> with_wps cs [@@qattr] let rec vc_gen (cs:list code) (qcs:with_wps cs) (k:t_post) : Tot (state -> Tot Type0 (decreases qcs)) = fun s0 -> match qcs with | QEmpty -> k s0 //no instructions; prove the postcondition right away | QSeq qc qcs -> // let pre_tl = //compute the VC generator for the tail, a precondition qc.wp (vc_gen (Cons?.tl cs) qcs k) s0 // in // qc.wp pre_tl s0 //apply the wp-generator to the precondition for the tail | QLemma pre post _ qcs -> pre /\ //prove the precondition of the lemma (post ==> vc_gen cs qcs k s0) //and assume its postcondition to verify the program /// The vc-generator is sound let rec vc_sound (cs:list code) (qcs:with_wps cs) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires vc_gen cs qcs k s0) (ensures fun (sN, fN) -> eval_code (Block cs) fN s0 == Some sN /\ k sN) = match qcs with | QEmpty -> (s0, 0) | QSeq qc qcs -> let Cons c cs' = cs in let (sM, fM) = qc.hasWp (vc_gen cs' qcs k) s0 in let (sN, fN) = vc_sound cs' qcs k sM in let fN' = lemma_merge c cs' s0 fM sM fN sN in (sN, fN') | QLemma pre post lem qcs' -> lem (); vc_sound cs qcs' k s0 let vc_sound' (cs:list code) (qcs:with_wps cs) : has_wp (Block cs) (vc_gen cs qcs) = vc_sound cs qcs (*** Instances of with_wp ***) //////////////////////////////////////////////////////////////////////////////// //Instance for Mov
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "MiniValeSemantics.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s0: MiniValeSemantics.state -> dst: MiniValeSemantics.operand -> src: MiniValeSemantics.operand -> Prims.Ghost (MiniValeSemantics.state * MiniValeSemantics.fuel)
Prims.Ghost
[]
[]
[ "MiniValeSemantics.state", "MiniValeSemantics.operand", "FStar.Pervasives.Native.Mktuple2", "MiniValeSemantics.fuel", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.option", "MiniValeSemantics.eval_code", "MiniValeSemantics.Ins", "MiniValeSemantics.Mov64", "Prims.b2t", "MiniValeSemantics.uu___is_OReg", "Prims.l_and", "Prims.eq2", "FStar.Pervasives.Native.Some", "MiniValeSemantics.nat64", "MiniValeSemantics.eval_operand", "MiniValeSemantics.update_state", "MiniValeSemantics.__proj__OReg__item__r" ]
[]
false
false
false
false
false
let lemma_Move (s0: state) (dst src: operand) : Ghost (state * fuel) (requires OReg? dst) (ensures fun (sM, fM) -> eval_code (Ins (Mov64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0) =
let Some sM = eval_code (Ins (Mov64 dst src)) 0 s0 in (sM, 0)
false
MiniValeSemantics.fst
MiniValeSemantics.wp_Move
val wp_Move (dst src: operand) (k: (state -> Type0)) (s0: state) : Type0
val wp_Move (dst src: operand) (k: (state -> Type0)) (s0: state) : Type0
let wp_Move (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Type0 = OReg? dst /\ (forall (x:nat64). let sM = update_reg s0 (OReg?.r dst) x in eval_operand dst sM == eval_operand src s0 ==> k sM )
{ "file_name": "examples/metatheory/MiniValeSemantics.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 3, "end_line": 330, "start_col": 0, "start_line": 325 }
(* 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. Authors: C. Hawblitzel, N. Swamy *) module MiniValeSemantics (* This is a highly-simplified model of Vale/F*, based on Section 3.1-3.3 of the paper of the POPL '19 paper. It is derived from the QuickRegs1 code in the popl-artifact-submit branch of Vale. *) /// We use this tag to mark certain definitions /// and control normalization based on it irreducible let qattr = () /// 2^64 let pow2_64 = 0x10000000000000000 /// Natural numbers representable in 64 bits type nat64 = i:int{0 <= i /\ i < pow2_64} /// We have 4 registers type reg = | Rax | Rbx | Rcx | Rdx /// An operand is either a register or a constant type operand = | OReg: r:reg -> operand | OConst: n:nat64 -> operand /// Only 2 instructions here: /// A move or an add type ins = | Mov64: dst:operand -> src:operand -> ins | Add64: dst:operand -> src:operand -> ins /// A program is /// - a single instruction /// - a block of instructions /// - or a while loop type code = | Ins: ins:ins -> code | Block: block:list code -> code | WhileLessThan: src1:operand -> src2:operand -> whileBody:code -> code /// The state of a program is the register file /// holiding a 64-bit value for each register type state = reg -> nat64 /// fuel: To prove the termination of while loops, we're going to /// instrument while loops with fuel type fuel = nat /// Evaluating an operand: /// -- marked for reduction /// -- Registers evaluated by state lookup [@@qattr] let eval_operand (o:operand) (s:state) : nat64 = match o with | OReg r -> s r | OConst n -> n /// updating a register state `s` at `r` with `v` [@@qattr] let update_reg (s:state) (r:reg) (v:nat64) : state = fun r' -> if r = r' then v else s r' /// updating a register state `s` at `r` with `s' r` [@@qattr] let update_state (r:reg) (s' s:state) : state = update_reg s r (s' r) // We don't have an "ok" flag, so errors just result an arbitrary state: assume val unknown_state (s:state) : state (*** A basic semantics using a big-step interpreter ***) /// Instruction evaluation: /// only some operands are valid let eval_ins (ins:ins) (s:state) : state = match ins with | Mov64 (OConst _) _ -> unknown_state s | Mov64 (OReg dst) src -> update_reg s dst (eval_operand src s) | Add64 (OConst _) _ -> unknown_state s | Add64 (OReg dst) src -> update_reg s dst ((s dst + eval_operand src s) % 0x10000000000000000) /// eval_code: /// A fueled big-step interpreter /// While lops return None when we're out of fuel let rec eval_code (c:code) (f:fuel) (s:state) : option state = match c with | Ins ins -> Some (eval_ins ins s) | Block cs -> eval_codes cs f s | WhileLessThan src1 src2 body -> if f = 0 then None else if eval_operand src1 s < eval_operand src2 s then match eval_code body f s with | None -> None | Some s -> eval_code c (f - 1) s else Some s and eval_codes (cs:list code) (f:fuel) (s:state) : option state = match cs with | [] -> Some s | c::cs -> match eval_code c f s with | None -> None | Some s -> eval_codes cs f s (*** END OF TRUSTED SEMANTICS ***) //////////////////////////////////////////////////////////////////////////////// /// 1. We prove that increasing the fuel is irrelevant to terminating executions val increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code c f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code c fN s0 == Some sN) (decreases %[f0; c]) val increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code (Block c) f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code (Block c) fN s0 == Some sN) (decreases %[f0; c]) let rec increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | Ins ins -> () | Block l -> increase_fuels l s0 f0 sN fN | WhileLessThan src1 src2 body -> if eval_operand src1 s0 < eval_operand src2 s0 then match eval_code body f0 s0 with | None -> () | Some s1 -> increase_fuel body s0 f0 s1 fN; increase_fuel c s1 (f0 - 1) sN (fN - 1) else () and increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | [] -> () | h::t -> let Some s1 = eval_code h f0 s0 in increase_fuel h s0 f0 s1 fN; increase_fuels t s1 f0 sN fN /// 2. We can compute the fuel needed to run a sequential composition /// as the max of the fuel to compute each piece of code in it let lemma_merge (c:code) (cs:list code) (s0:state) (f0:fuel) (sM:state) (fM:fuel) (sN:state) : Ghost fuel (requires eval_code c f0 s0 == Some sM /\ eval_code (Block cs) fM sM == Some sN) (ensures fun fN -> eval_code (Block (c::cs)) fN s0 == Some sN) = let f = if f0 > fM then f0 else fM in increase_fuel c s0 f0 sM f; increase_fuel (Block cs) sM fM sN f; f ///////////////////////////////////////////////////////////////// // Now, we're going to define a verification-condition generator // // The main idea is that we're going to: // // 1. define a kind of typeclass, that associates with a // piece of code a weakest-precondition rule for it // // 2. Define a WP-generator that computes WPs for each of the // control constructs of the language, given a program // represented as the raw code packaged with their typeclass // instances for computing their WPs ///////////////////////////////////////////////////////////////// [@@qattr] let t_post = state -> Type0 [@@qattr] let t_pre = state -> Type0 /// t_wp: The type of weakest preconditions let t_wp = t_post -> t_pre /// c `has_wp` wp: The main judgment in our program logic let has_wp (c:code) (wp:t_wp) : Type = k:t_post -> //for any post-condition s0:state -> //and initial state Ghost (state * fuel) (requires wp k s0) //Given the precondition (ensures fun (sM, f0) -> //we can compute the fuel f0 needed so that eval_code c f0 s0 == Some sM /\ //eval_code with that fuel returns sM k sM) //and the post-condition is true on sM /// An abbreviation for a thunked lemma let t_lemma (pre:Type0) (post:Type0) = unit -> Lemma (requires pre) (ensures post) /// `with_wp` : A typeclass for code packaged with its wp [@@qattr] noeq type with_wp : code -> Type = | QProc: c:code -> wp:t_wp -> hasWp:has_wp c wp -> with_wp c /// `with_wps`: A typclass for lists of code values packages with their wps noeq type with_wps : list code -> Type = | QEmpty: //empty list with_wps [] | QSeq: //cons #c:code -> #cs:list code -> hd:with_wp c -> tl:with_wps cs -> with_wps (c::cs) | QLemma: //augmenting an instruction sequence with a lemma #cs:list code -> pre:Type0 -> post:Type0 -> t_lemma pre post -> with_wps cs -> with_wps cs [@@qattr] let rec vc_gen (cs:list code) (qcs:with_wps cs) (k:t_post) : Tot (state -> Tot Type0 (decreases qcs)) = fun s0 -> match qcs with | QEmpty -> k s0 //no instructions; prove the postcondition right away | QSeq qc qcs -> // let pre_tl = //compute the VC generator for the tail, a precondition qc.wp (vc_gen (Cons?.tl cs) qcs k) s0 // in // qc.wp pre_tl s0 //apply the wp-generator to the precondition for the tail | QLemma pre post _ qcs -> pre /\ //prove the precondition of the lemma (post ==> vc_gen cs qcs k s0) //and assume its postcondition to verify the program /// The vc-generator is sound let rec vc_sound (cs:list code) (qcs:with_wps cs) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires vc_gen cs qcs k s0) (ensures fun (sN, fN) -> eval_code (Block cs) fN s0 == Some sN /\ k sN) = match qcs with | QEmpty -> (s0, 0) | QSeq qc qcs -> let Cons c cs' = cs in let (sM, fM) = qc.hasWp (vc_gen cs' qcs k) s0 in let (sN, fN) = vc_sound cs' qcs k sM in let fN' = lemma_merge c cs' s0 fM sM fN sN in (sN, fN') | QLemma pre post lem qcs' -> lem (); vc_sound cs qcs' k s0 let vc_sound' (cs:list code) (qcs:with_wps cs) : has_wp (Block cs) (vc_gen cs qcs) = vc_sound cs qcs (*** Instances of with_wp ***) //////////////////////////////////////////////////////////////////////////////// //Instance for Mov //////////////////////////////////////////////////////////////////////////////// let lemma_Move (s0:state) (dst:operand) (src:operand) : Ghost (state * fuel) (requires OReg? dst) (ensures fun (sM, fM) -> eval_code (Ins (Mov64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0 ) = let Some sM = eval_code (Ins (Mov64 dst src)) 0 s0 in (sM, 0)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "MiniValeSemantics.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: MiniValeSemantics.operand -> src: MiniValeSemantics.operand -> k: (_: MiniValeSemantics.state -> Type0) -> s0: MiniValeSemantics.state -> Type0
Prims.Tot
[ "total" ]
[]
[ "MiniValeSemantics.operand", "MiniValeSemantics.state", "Prims.l_and", "Prims.b2t", "MiniValeSemantics.uu___is_OReg", "Prims.l_Forall", "MiniValeSemantics.nat64", "Prims.l_imp", "Prims.eq2", "MiniValeSemantics.eval_operand", "MiniValeSemantics.update_reg", "MiniValeSemantics.__proj__OReg__item__r" ]
[]
false
false
false
true
true
let wp_Move (dst src: operand) (k: (state -> Type0)) (s0: state) : Type0 =
OReg? dst /\ (forall (x: nat64). let sM = update_reg s0 (OReg?.r dst) x in eval_operand dst sM == eval_operand src s0 ==> k sM)
false
FStar.DM4F.OTP.Heap.fsti
FStar.DM4F.OTP.Heap.size
val size : Prims.int
let size = 10
{ "file_name": "examples/dm4free/FStar.DM4F.OTP.Heap.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 13, "end_line": 23, "start_col": 0, "start_line": 23 }
(* 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.DM4F.OTP.Heap open FStar.BitVector open FStar.Seq (***** Random tape *****)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.DM4F.OTP.Heap.fsti" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.int
Prims.Tot
[ "total" ]
[]
[]
[]
false
false
false
true
false
let size =
10
false
FStar.DM4F.OTP.Heap.fsti
FStar.DM4F.OTP.Heap.sel
val sel : h: FStar.DM4F.OTP.Heap.tape -> i: FStar.DM4F.OTP.Heap.id -> FStar.DM4F.OTP.Heap.elem
let sel = index
{ "file_name": "examples/dm4free/FStar.DM4F.OTP.Heap.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 15, "end_line": 40, "start_col": 0, "start_line": 40 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.OTP.Heap open FStar.BitVector open FStar.Seq (***** Random tape *****) let size = 10 val q: pos let elem = bv_t q val id : eqtype val tape : eqtype val to_id (n:nat{n < size}) : id val incrementable: id -> bool val incr (i:id{incrementable i}) : id
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.DM4F.OTP.Heap.fsti" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: FStar.DM4F.OTP.Heap.tape -> i: FStar.DM4F.OTP.Heap.id -> FStar.DM4F.OTP.Heap.elem
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.OTP.Heap.index" ]
[]
false
false
false
true
false
let sel =
index
false
MiniValeSemantics.fst
MiniValeSemantics.lemma_merge
val lemma_merge (c: code) (cs: list code) (s0: state) (f0: fuel) (sM: state) (fM: fuel) (sN: state) : Ghost fuel (requires eval_code c f0 s0 == Some sM /\ eval_code (Block cs) fM sM == Some sN) (ensures fun fN -> eval_code (Block (c :: cs)) fN s0 == Some sN)
val lemma_merge (c: code) (cs: list code) (s0: state) (f0: fuel) (sM: state) (fM: fuel) (sN: state) : Ghost fuel (requires eval_code c f0 s0 == Some sM /\ eval_code (Block cs) fM sM == Some sN) (ensures fun fN -> eval_code (Block (c :: cs)) fN s0 == Some sN)
let lemma_merge (c:code) (cs:list code) (s0:state) (f0:fuel) (sM:state) (fM:fuel) (sN:state) : Ghost fuel (requires eval_code c f0 s0 == Some sM /\ eval_code (Block cs) fM sM == Some sN) (ensures fun fN -> eval_code (Block (c::cs)) fN s0 == Some sN) = let f = if f0 > fM then f0 else fM in increase_fuel c s0 f0 sM f; increase_fuel (Block cs) sM fM sN f; f
{ "file_name": "examples/metatheory/MiniValeSemantics.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 3, "end_line": 197, "start_col": 0, "start_line": 186 }
(* 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. Authors: C. Hawblitzel, N. Swamy *) module MiniValeSemantics (* This is a highly-simplified model of Vale/F*, based on Section 3.1-3.3 of the paper of the POPL '19 paper. It is derived from the QuickRegs1 code in the popl-artifact-submit branch of Vale. *) /// We use this tag to mark certain definitions /// and control normalization based on it irreducible let qattr = () /// 2^64 let pow2_64 = 0x10000000000000000 /// Natural numbers representable in 64 bits type nat64 = i:int{0 <= i /\ i < pow2_64} /// We have 4 registers type reg = | Rax | Rbx | Rcx | Rdx /// An operand is either a register or a constant type operand = | OReg: r:reg -> operand | OConst: n:nat64 -> operand /// Only 2 instructions here: /// A move or an add type ins = | Mov64: dst:operand -> src:operand -> ins | Add64: dst:operand -> src:operand -> ins /// A program is /// - a single instruction /// - a block of instructions /// - or a while loop type code = | Ins: ins:ins -> code | Block: block:list code -> code | WhileLessThan: src1:operand -> src2:operand -> whileBody:code -> code /// The state of a program is the register file /// holiding a 64-bit value for each register type state = reg -> nat64 /// fuel: To prove the termination of while loops, we're going to /// instrument while loops with fuel type fuel = nat /// Evaluating an operand: /// -- marked for reduction /// -- Registers evaluated by state lookup [@@qattr] let eval_operand (o:operand) (s:state) : nat64 = match o with | OReg r -> s r | OConst n -> n /// updating a register state `s` at `r` with `v` [@@qattr] let update_reg (s:state) (r:reg) (v:nat64) : state = fun r' -> if r = r' then v else s r' /// updating a register state `s` at `r` with `s' r` [@@qattr] let update_state (r:reg) (s' s:state) : state = update_reg s r (s' r) // We don't have an "ok" flag, so errors just result an arbitrary state: assume val unknown_state (s:state) : state (*** A basic semantics using a big-step interpreter ***) /// Instruction evaluation: /// only some operands are valid let eval_ins (ins:ins) (s:state) : state = match ins with | Mov64 (OConst _) _ -> unknown_state s | Mov64 (OReg dst) src -> update_reg s dst (eval_operand src s) | Add64 (OConst _) _ -> unknown_state s | Add64 (OReg dst) src -> update_reg s dst ((s dst + eval_operand src s) % 0x10000000000000000) /// eval_code: /// A fueled big-step interpreter /// While lops return None when we're out of fuel let rec eval_code (c:code) (f:fuel) (s:state) : option state = match c with | Ins ins -> Some (eval_ins ins s) | Block cs -> eval_codes cs f s | WhileLessThan src1 src2 body -> if f = 0 then None else if eval_operand src1 s < eval_operand src2 s then match eval_code body f s with | None -> None | Some s -> eval_code c (f - 1) s else Some s and eval_codes (cs:list code) (f:fuel) (s:state) : option state = match cs with | [] -> Some s | c::cs -> match eval_code c f s with | None -> None | Some s -> eval_codes cs f s (*** END OF TRUSTED SEMANTICS ***) //////////////////////////////////////////////////////////////////////////////// /// 1. We prove that increasing the fuel is irrelevant to terminating executions val increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code c f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code c fN s0 == Some sN) (decreases %[f0; c]) val increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code (Block c) f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code (Block c) fN s0 == Some sN) (decreases %[f0; c]) let rec increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | Ins ins -> () | Block l -> increase_fuels l s0 f0 sN fN | WhileLessThan src1 src2 body -> if eval_operand src1 s0 < eval_operand src2 s0 then match eval_code body f0 s0 with | None -> () | Some s1 -> increase_fuel body s0 f0 s1 fN; increase_fuel c s1 (f0 - 1) sN (fN - 1) else () and increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | [] -> () | h::t -> let Some s1 = eval_code h f0 s0 in increase_fuel h s0 f0 s1 fN; increase_fuels t s1 f0 sN fN /// 2. We can compute the fuel needed to run a sequential composition
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "MiniValeSemantics.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: MiniValeSemantics.code -> cs: Prims.list MiniValeSemantics.code -> s0: MiniValeSemantics.state -> f0: MiniValeSemantics.fuel -> sM: MiniValeSemantics.state -> fM: MiniValeSemantics.fuel -> sN: MiniValeSemantics.state -> Prims.Ghost MiniValeSemantics.fuel
Prims.Ghost
[]
[]
[ "MiniValeSemantics.code", "Prims.list", "MiniValeSemantics.state", "MiniValeSemantics.fuel", "Prims.unit", "MiniValeSemantics.increase_fuel", "MiniValeSemantics.Block", "Prims.op_GreaterThan", "Prims.bool", "Prims.l_and", "Prims.eq2", "FStar.Pervasives.Native.option", "MiniValeSemantics.eval_code", "FStar.Pervasives.Native.Some", "Prims.Cons" ]
[]
false
false
false
false
false
let lemma_merge (c: code) (cs: list code) (s0: state) (f0: fuel) (sM: state) (fM: fuel) (sN: state) : Ghost fuel (requires eval_code c f0 s0 == Some sM /\ eval_code (Block cs) fM sM == Some sN) (ensures fun fN -> eval_code (Block (c :: cs)) fN s0 == Some sN) =
let f = if f0 > fM then f0 else fM in increase_fuel c s0 f0 sM f; increase_fuel (Block cs) sM fM sN f; f
false
MiniValeSemantics.fst
MiniValeSemantics.hasWp_Add
val hasWp_Add (dst src: operand) (k: (state -> Type0)) (s0: state) : Ghost (state * fuel) (requires wp_Add dst src k s0) (ensures fun (sM, f0) -> eval_code (Ins (Add64 dst src)) f0 s0 == Some sM /\ k sM)
val hasWp_Add (dst src: operand) (k: (state -> Type0)) (s0: state) : Ghost (state * fuel) (requires wp_Add dst src k s0) (ensures fun (sM, f0) -> eval_code (Ins (Add64 dst src)) f0 s0 == Some sM /\ k sM)
let hasWp_Add (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires wp_Add dst src k s0) (ensures fun (sM, f0) -> eval_code (Ins (Add64 dst src)) f0 s0 == Some sM /\ k sM) = lemma_Add s0 dst src
{ "file_name": "examples/metatheory/MiniValeSemantics.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 22, "end_line": 368, "start_col": 0, "start_line": 364 }
(* 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. Authors: C. Hawblitzel, N. Swamy *) module MiniValeSemantics (* This is a highly-simplified model of Vale/F*, based on Section 3.1-3.3 of the paper of the POPL '19 paper. It is derived from the QuickRegs1 code in the popl-artifact-submit branch of Vale. *) /// We use this tag to mark certain definitions /// and control normalization based on it irreducible let qattr = () /// 2^64 let pow2_64 = 0x10000000000000000 /// Natural numbers representable in 64 bits type nat64 = i:int{0 <= i /\ i < pow2_64} /// We have 4 registers type reg = | Rax | Rbx | Rcx | Rdx /// An operand is either a register or a constant type operand = | OReg: r:reg -> operand | OConst: n:nat64 -> operand /// Only 2 instructions here: /// A move or an add type ins = | Mov64: dst:operand -> src:operand -> ins | Add64: dst:operand -> src:operand -> ins /// A program is /// - a single instruction /// - a block of instructions /// - or a while loop type code = | Ins: ins:ins -> code | Block: block:list code -> code | WhileLessThan: src1:operand -> src2:operand -> whileBody:code -> code /// The state of a program is the register file /// holiding a 64-bit value for each register type state = reg -> nat64 /// fuel: To prove the termination of while loops, we're going to /// instrument while loops with fuel type fuel = nat /// Evaluating an operand: /// -- marked for reduction /// -- Registers evaluated by state lookup [@@qattr] let eval_operand (o:operand) (s:state) : nat64 = match o with | OReg r -> s r | OConst n -> n /// updating a register state `s` at `r` with `v` [@@qattr] let update_reg (s:state) (r:reg) (v:nat64) : state = fun r' -> if r = r' then v else s r' /// updating a register state `s` at `r` with `s' r` [@@qattr] let update_state (r:reg) (s' s:state) : state = update_reg s r (s' r) // We don't have an "ok" flag, so errors just result an arbitrary state: assume val unknown_state (s:state) : state (*** A basic semantics using a big-step interpreter ***) /// Instruction evaluation: /// only some operands are valid let eval_ins (ins:ins) (s:state) : state = match ins with | Mov64 (OConst _) _ -> unknown_state s | Mov64 (OReg dst) src -> update_reg s dst (eval_operand src s) | Add64 (OConst _) _ -> unknown_state s | Add64 (OReg dst) src -> update_reg s dst ((s dst + eval_operand src s) % 0x10000000000000000) /// eval_code: /// A fueled big-step interpreter /// While lops return None when we're out of fuel let rec eval_code (c:code) (f:fuel) (s:state) : option state = match c with | Ins ins -> Some (eval_ins ins s) | Block cs -> eval_codes cs f s | WhileLessThan src1 src2 body -> if f = 0 then None else if eval_operand src1 s < eval_operand src2 s then match eval_code body f s with | None -> None | Some s -> eval_code c (f - 1) s else Some s and eval_codes (cs:list code) (f:fuel) (s:state) : option state = match cs with | [] -> Some s | c::cs -> match eval_code c f s with | None -> None | Some s -> eval_codes cs f s (*** END OF TRUSTED SEMANTICS ***) //////////////////////////////////////////////////////////////////////////////// /// 1. We prove that increasing the fuel is irrelevant to terminating executions val increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code c f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code c fN s0 == Some sN) (decreases %[f0; c]) val increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code (Block c) f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code (Block c) fN s0 == Some sN) (decreases %[f0; c]) let rec increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | Ins ins -> () | Block l -> increase_fuels l s0 f0 sN fN | WhileLessThan src1 src2 body -> if eval_operand src1 s0 < eval_operand src2 s0 then match eval_code body f0 s0 with | None -> () | Some s1 -> increase_fuel body s0 f0 s1 fN; increase_fuel c s1 (f0 - 1) sN (fN - 1) else () and increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | [] -> () | h::t -> let Some s1 = eval_code h f0 s0 in increase_fuel h s0 f0 s1 fN; increase_fuels t s1 f0 sN fN /// 2. We can compute the fuel needed to run a sequential composition /// as the max of the fuel to compute each piece of code in it let lemma_merge (c:code) (cs:list code) (s0:state) (f0:fuel) (sM:state) (fM:fuel) (sN:state) : Ghost fuel (requires eval_code c f0 s0 == Some sM /\ eval_code (Block cs) fM sM == Some sN) (ensures fun fN -> eval_code (Block (c::cs)) fN s0 == Some sN) = let f = if f0 > fM then f0 else fM in increase_fuel c s0 f0 sM f; increase_fuel (Block cs) sM fM sN f; f ///////////////////////////////////////////////////////////////// // Now, we're going to define a verification-condition generator // // The main idea is that we're going to: // // 1. define a kind of typeclass, that associates with a // piece of code a weakest-precondition rule for it // // 2. Define a WP-generator that computes WPs for each of the // control constructs of the language, given a program // represented as the raw code packaged with their typeclass // instances for computing their WPs ///////////////////////////////////////////////////////////////// [@@qattr] let t_post = state -> Type0 [@@qattr] let t_pre = state -> Type0 /// t_wp: The type of weakest preconditions let t_wp = t_post -> t_pre /// c `has_wp` wp: The main judgment in our program logic let has_wp (c:code) (wp:t_wp) : Type = k:t_post -> //for any post-condition s0:state -> //and initial state Ghost (state * fuel) (requires wp k s0) //Given the precondition (ensures fun (sM, f0) -> //we can compute the fuel f0 needed so that eval_code c f0 s0 == Some sM /\ //eval_code with that fuel returns sM k sM) //and the post-condition is true on sM /// An abbreviation for a thunked lemma let t_lemma (pre:Type0) (post:Type0) = unit -> Lemma (requires pre) (ensures post) /// `with_wp` : A typeclass for code packaged with its wp [@@qattr] noeq type with_wp : code -> Type = | QProc: c:code -> wp:t_wp -> hasWp:has_wp c wp -> with_wp c /// `with_wps`: A typclass for lists of code values packages with their wps noeq type with_wps : list code -> Type = | QEmpty: //empty list with_wps [] | QSeq: //cons #c:code -> #cs:list code -> hd:with_wp c -> tl:with_wps cs -> with_wps (c::cs) | QLemma: //augmenting an instruction sequence with a lemma #cs:list code -> pre:Type0 -> post:Type0 -> t_lemma pre post -> with_wps cs -> with_wps cs [@@qattr] let rec vc_gen (cs:list code) (qcs:with_wps cs) (k:t_post) : Tot (state -> Tot Type0 (decreases qcs)) = fun s0 -> match qcs with | QEmpty -> k s0 //no instructions; prove the postcondition right away | QSeq qc qcs -> // let pre_tl = //compute the VC generator for the tail, a precondition qc.wp (vc_gen (Cons?.tl cs) qcs k) s0 // in // qc.wp pre_tl s0 //apply the wp-generator to the precondition for the tail | QLemma pre post _ qcs -> pre /\ //prove the precondition of the lemma (post ==> vc_gen cs qcs k s0) //and assume its postcondition to verify the program /// The vc-generator is sound let rec vc_sound (cs:list code) (qcs:with_wps cs) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires vc_gen cs qcs k s0) (ensures fun (sN, fN) -> eval_code (Block cs) fN s0 == Some sN /\ k sN) = match qcs with | QEmpty -> (s0, 0) | QSeq qc qcs -> let Cons c cs' = cs in let (sM, fM) = qc.hasWp (vc_gen cs' qcs k) s0 in let (sN, fN) = vc_sound cs' qcs k sM in let fN' = lemma_merge c cs' s0 fM sM fN sN in (sN, fN') | QLemma pre post lem qcs' -> lem (); vc_sound cs qcs' k s0 let vc_sound' (cs:list code) (qcs:with_wps cs) : has_wp (Block cs) (vc_gen cs qcs) = vc_sound cs qcs (*** Instances of with_wp ***) //////////////////////////////////////////////////////////////////////////////// //Instance for Mov //////////////////////////////////////////////////////////////////////////////// let lemma_Move (s0:state) (dst:operand) (src:operand) : Ghost (state * fuel) (requires OReg? dst) (ensures fun (sM, fM) -> eval_code (Ins (Mov64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0 ) = let Some sM = eval_code (Ins (Mov64 dst src)) 0 s0 in (sM, 0) [@@qattr] let wp_Move (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Type0 = OReg? dst /\ (forall (x:nat64). let sM = update_reg s0 (OReg?.r dst) x in eval_operand dst sM == eval_operand src s0 ==> k sM ) let hasWp_Move (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires wp_Move dst src k s0) (ensures fun (sM, f0) -> eval_code (Ins (Mov64 dst src)) f0 s0 == Some sM /\ k sM) = lemma_Move s0 dst src [@@qattr] let inst_Move (dst:operand) (src:operand) : with_wp (Ins (Mov64 dst src)) = QProc (Ins (Mov64 dst src)) (wp_Move dst src) (hasWp_Move dst src) //////////////////////////////////////////////////////////////////////////////// //Instance for Add //////////////////////////////////////////////////////////////////////////////// let lemma_Add (s0:state) (dst:operand) (src:operand) : Ghost (state * fuel) (requires OReg? dst /\ eval_operand dst s0 + eval_operand src s0 < pow2_64) (ensures fun (sM, fM) -> eval_code (Ins (Add64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand dst s0 + eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0 ) = let Some sM = eval_code (Ins (Add64 dst src)) 0 s0 in (sM, 0) [@@qattr] let wp_Add (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Type0 = OReg? dst /\ eval_operand dst s0 + eval_operand src s0 < pow2_64 /\ (forall (x:nat64). let sM = update_reg s0 (OReg?.r dst) x in eval_operand dst sM == eval_operand dst s0 + eval_operand src s0 ==> k sM )
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "MiniValeSemantics.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: MiniValeSemantics.operand -> src: MiniValeSemantics.operand -> k: (_: MiniValeSemantics.state -> Type0) -> s0: MiniValeSemantics.state -> Prims.Ghost (MiniValeSemantics.state * MiniValeSemantics.fuel)
Prims.Ghost
[]
[]
[ "MiniValeSemantics.operand", "MiniValeSemantics.state", "MiniValeSemantics.lemma_Add", "FStar.Pervasives.Native.tuple2", "MiniValeSemantics.fuel", "MiniValeSemantics.wp_Add", "Prims.l_and", "Prims.eq2", "FStar.Pervasives.Native.option", "MiniValeSemantics.eval_code", "MiniValeSemantics.Ins", "MiniValeSemantics.Add64", "FStar.Pervasives.Native.Some" ]
[]
false
false
false
false
false
let hasWp_Add (dst src: operand) (k: (state -> Type0)) (s0: state) : Ghost (state * fuel) (requires wp_Add dst src k s0) (ensures fun (sM, f0) -> eval_code (Ins (Add64 dst src)) f0 s0 == Some sM /\ k sM) =
lemma_Add s0 dst src
false
Vale.Curve25519.X64.FastUtil.fst
Vale.Curve25519.X64.FastUtil.va_lemma_Fast_sub
val va_lemma_Fast_sub : va_b0:va_code -> va_s0:va_state -> dst_b:buffer64 -> inA_b:buffer64 -> inB_b:buffer64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Fast_sub ()) va_s0 /\ va_get_ok va_s0 /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in (Vale.X64.Decls.buffers_disjoint dst_b inA_b \/ dst_b == inA_b) /\ (Vale.X64.Decls.buffers_disjoint dst_b inB_b \/ dst_b == inB_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdi va_s0) dst_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) inA_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRcx va_s0) inB_b 4 (va_get_mem_layout va_s0) Secret))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in let d = Vale.Curve25519.Fast_defs.pow2_four d0 d1 d2 d3 in d - va_mul_nat (va_get_reg64 rRax va_sM) pow2_256 == a - b /\ (va_get_reg64 rRax va_sM == 0 \/ va_get_reg64 rRax va_sM == 1) /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM)) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))
val va_lemma_Fast_sub : va_b0:va_code -> va_s0:va_state -> dst_b:buffer64 -> inA_b:buffer64 -> inB_b:buffer64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Fast_sub ()) va_s0 /\ va_get_ok va_s0 /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in (Vale.X64.Decls.buffers_disjoint dst_b inA_b \/ dst_b == inA_b) /\ (Vale.X64.Decls.buffers_disjoint dst_b inB_b \/ dst_b == inB_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdi va_s0) dst_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) inA_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRcx va_s0) inB_b 4 (va_get_mem_layout va_s0) Secret))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in let d = Vale.Curve25519.Fast_defs.pow2_four d0 d1 d2 d3 in d - va_mul_nat (va_get_reg64 rRax va_sM) pow2_256 == a - b /\ (va_get_reg64 rRax va_sM == 0 \/ va_get_reg64 rRax va_sM == 1) /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM)) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))
let va_lemma_Fast_sub va_b0 va_s0 dst_b inA_b inB_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Fast_sub va_mods dst_b inA_b inB_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Fast_sub ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 627 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_ok va_sM) /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in label va_range1 "***** POSTCONDITION NOT MET AT line 663 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 664 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 665 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 666 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 667 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d = Vale.Curve25519.Fast_defs.pow2_four d0 d1 d2 d3 in label va_range1 "***** POSTCONDITION NOT MET AT line 668 column 41 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (d - va_mul_nat (va_get_reg64 rRax va_sM) pow2_256 == a - b) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 669 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_reg64 rRax va_sM == 0 \/ va_get_reg64 rRax va_sM == 1) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 671 column 69 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 672 column 50 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM))))))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM)
{ "file_name": "obj/Vale.Curve25519.X64.FastUtil.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 16, "end_line": 1441, "start_col": 0, "start_line": 1399 }
module Vale.Curve25519.X64.FastUtil open Vale.Def.Types_s open Vale.Arch.Types open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsStack open Vale.X64.QuickCode open Vale.X64.QuickCodes open FStar.Tactics open Vale.Curve25519.Fast_defs open Vale.Curve25519.Fast_lemmas_external open Vale.Curve25519.FastUtil_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 60" //-- Fast_mul1 #push-options "--z3rlimit 600" val va_code_Fast_mul1 : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Fast_mul1 () = (va_Block (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Mulx64 (va_op_dst_opr64_reg64 rR9) (va_op_dst_opr64_reg64 rR8) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR8)) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Mulx64 (va_op_dst_opr64_reg64 rR11) (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_CCons (va_code_Add64Wrap (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR9)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 8 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Mulx64 (va_op_dst_opr64_reg64 rR13) (va_op_dst_opr64_reg64 rRbx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 Secret)) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR11)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRbx) 16 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Mulx64 (va_op_dst_opr64_reg64 rRax) (va_op_dst_opr64_reg64 rR14) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 Secret)) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rR13)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR14) 24 Secret) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR8)) (va_CNil ()))))))))))))))))))) val va_codegen_success_Fast_mul1 : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Fast_mul1 () = (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Mulx64 (va_op_dst_opr64_reg64 rR9) (va_op_dst_opr64_reg64 rR8) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR8)) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Mulx64 (va_op_dst_opr64_reg64 rR11) (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_pbool_and (va_codegen_success_Add64Wrap (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR9)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 8 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Mulx64 (va_op_dst_opr64_reg64 rR13) (va_op_dst_opr64_reg64 rRbx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 Secret)) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR11)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRbx) 16 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Mulx64 (va_op_dst_opr64_reg64 rRax) (va_op_dst_opr64_reg64 rR14) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 Secret)) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR14) 24 Secret) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR8)) (va_ttrue ())))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Fast_mul1 (va_mods:va_mods_t) (dst_b:buffer64) (inA_b:buffer64) : (va_quickCode unit (va_code_Fast_mul1 ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 91 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Arch.Types.xor_lemmas ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 93 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 inA_b 0 Secret) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 93 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mulx64 (va_op_dst_opr64_reg64 rR9) (va_op_dst_opr64_reg64 rR8) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (fun (va_s:va_state) _ -> let (va_arg48:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in let (va_arg47:Vale.Def.Types_s.nat64) = va_get_reg64 rR8 va_s in let (va_arg46:Vale.Def.Types_s.nat64) = va_get_reg64 rR9 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 93 column 99 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Curve25519.Fast_lemmas_external.lemma_prod_bounds va_arg46 va_arg47 va_arg48 a0) (let (old_r8:nat64) = va_get_reg64 rR8 va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 94 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 0 Secret dst_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 95 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR8)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 96 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 inA_b 1 Secret) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 96 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mulx64 (va_op_dst_opr64_reg64 rR11) (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (fun (va_s:va_state) _ -> let (va_arg45:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in let (va_arg44:Vale.Def.Types_s.nat64) = va_get_reg64 rR10 va_s in let (va_arg43:Vale.Def.Types_s.nat64) = va_get_reg64 rR11 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 96 column 99 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Curve25519.Fast_lemmas_external.lemma_prod_bounds va_arg43 va_arg44 va_arg45 a1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 97 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Add64Wrap (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR9)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 98 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 8 Secret dst_b 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 99 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 inA_b 2 Secret) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 99 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mulx64 (va_op_dst_opr64_reg64 rR13) (va_op_dst_opr64_reg64 rRbx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 Secret)) (fun (va_s:va_state) _ -> let (va_arg42:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in let (va_arg41:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in let (va_arg40:Vale.Def.Types_s.nat64) = va_get_reg64 rR13 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 99 column 99 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Curve25519.Fast_lemmas_external.lemma_prod_bounds va_arg40 va_arg41 va_arg42 a2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 100 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR11)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 101 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRbx) 16 Secret dst_b 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 102 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 inA_b 3 Secret) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 102 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mulx64 (va_op_dst_opr64_reg64 rRax) (va_op_dst_opr64_reg64 rR14) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 Secret)) (fun (va_s:va_state) _ -> let (va_arg39:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in let (va_arg38:Vale.Def.Types_s.nat64) = va_get_reg64 rR14 va_s in let (va_arg37:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 102 column 99 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Curve25519.Fast_lemmas_external.lemma_prod_bounds va_arg37 va_arg38 va_arg39 a3) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 103 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rR13)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 104 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR14) 24 Secret dst_b 3) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 105 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR8)) (fun (va_s:va_state) _ -> let (carry_bit:Vale.Curve25519.Fast_defs.bit) = Vale.Curve25519.Fast_defs.bool_bit (Vale.X64.Decls.cf (va_get_flags va_s)) in va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 108 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (carry_bit == 0) (let (va_arg36:prop) = va_mul_nat a (va_get_reg64 rRdx va_s) == 0 + Vale.Curve25519.Fast_defs.pow2_four (va_mul_nat (va_get_reg64 rRdx va_s) a0) (va_mul_nat (va_get_reg64 rRdx va_s) a1) (va_mul_nat (va_get_reg64 rRdx va_s) a2) (va_mul_nat (va_get_reg64 rRdx va_s) a3) in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 109 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> assert_by_tactic va_arg36 int_canon) (va_QEmpty (()))))))))))))))))))))))))))) val va_lemma_Fast_mul1 : va_b0:va_code -> va_s0:va_state -> dst_b:buffer64 -> inA_b:buffer64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Fast_mul1 ()) va_s0 /\ va_get_ok va_s0 /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in adx_enabled /\ bmi2_enabled /\ (Vale.X64.Decls.buffers_disjoint dst_b inA_b \/ inA_b == dst_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdi va_s0) dst_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) inA_b 4 (va_get_mem_layout va_s0) Secret))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in let d = Vale.Curve25519.Fast_defs.pow2_five d0 d1 d2 d3 (va_get_reg64 rRax va_sM) in d == va_mul_nat a (va_get_reg64 rRdx va_s0) /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM)) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))) [@"opaque_to_smt"] let va_lemma_Fast_mul1 va_b0 va_s0 dst_b inA_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Fast_mul1 va_mods dst_b inA_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Fast_mul1 ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 52 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_ok va_sM) /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in label va_range1 "***** POSTCONDITION NOT MET AT line 81 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 82 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 83 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 84 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 85 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d = Vale.Curve25519.Fast_defs.pow2_five d0 d1 d2 d3 (va_get_reg64 rRax va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 86 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (d == va_mul_nat a (va_get_reg64 rRdx va_s0)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 88 column 69 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 89 column 50 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM))))))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Fast_mul1 (dst_b:buffer64) (inA_b:buffer64) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in adx_enabled /\ bmi2_enabled /\ (Vale.X64.Decls.buffers_disjoint dst_b inA_b \/ inA_b == dst_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdi va_s0) dst_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) inA_b 4 (va_get_mem_layout va_s0) Secret) /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64) (va_x_r11:nat64) (va_x_rbx:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_heap0:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 0 va_x_heap0 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13 (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10 (va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem va_s0)))))))))) in va_get_ok va_sM /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in let d = Vale.Curve25519.Fast_defs.pow2_five d0 d1 d2 d3 (va_get_reg64 rRax va_sM) in d == va_mul_nat a (va_get_reg64 rRdx va_s0) /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM)) ==> va_k va_sM (()))) val va_wpProof_Fast_mul1 : dst_b:buffer64 -> inA_b:buffer64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Fast_mul1 dst_b inA_b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Fast_mul1 ()) ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Fast_mul1 dst_b inA_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_Fast_mul1 (va_code_Fast_mul1 ()) va_s0 dst_b inA_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Fast_mul1 (dst_b:buffer64) (inA_b:buffer64) : (va_quickCode unit (va_code_Fast_mul1 ())) = (va_QProc (va_code_Fast_mul1 ()) ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_Fast_mul1 dst_b inA_b) (va_wpProof_Fast_mul1 dst_b inA_b)) #pop-options //-- //-- Fast_add1 #push-options "--z3rlimit 600" [@ "opaque_to_smt" va_qattr] let va_code_Fast_add1 () = (va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (va_code_Comment "Clear registers to propagate the carry bit" ) (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR8)) (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9)) (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR10)) (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR11)) (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Newline ()) (va_CCons (va_code_Comment "Begin addition chain" ) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Add64Wrap (va_op_dst_opr64_reg64 rRdx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRdx) 0 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rR8) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 8 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rR9) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 16 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 24 Secret) (va_CCons (va_code_Newline ()) (va_CCons (va_code_Comment "Return the carry bit in a register" ) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_CCons (va_code_DestroyHeaplets ()) (va_CNil ()))))))))))))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Fast_add1 () = (va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and (va_codegen_success_Comment "Clear registers to propagate the carry bit" ) (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR8)) (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9)) (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR10)) (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR11)) (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_Newline ()) (va_pbool_and (va_codegen_success_Comment "Begin addition chain" ) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Add64Wrap (va_op_dst_opr64_reg64 rRdx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRdx) 0 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rR8) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 8 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rR9) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 16 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 24 Secret) (va_pbool_and (va_codegen_success_Newline ()) (va_pbool_and (va_codegen_success_Comment "Return the carry bit in a register" ) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_pbool_and (va_codegen_success_DestroyHeaplets ()) (va_ttrue ())))))))))))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Fast_add1 (va_mods:va_mods_t) (dst_b:buffer64) (inA_b:buffer64) (inB:nat64) : (va_quickCode unit (va_code_Fast_add1 ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem va_s) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem va_s) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem va_s) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem va_s) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 224 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_CreateHeaplets ([declare_buffer64 inA_b 0 Secret Immutable; declare_buffer64 dst_b 0 Secret Mutable])) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 228 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Arch.Types.xor_lemmas ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 229 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Comment "Clear registers to propagate the carry bit" ) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 230 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR8)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 231 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 232 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR10)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 233 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR11)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 234 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 236 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Newline ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 237 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Comment "Begin addition chain" ) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 238 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 inA_b 0 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 238 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Add64Wrap (va_op_dst_opr64_reg64 rRdx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 239 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRdx) 0 Secret dst_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 241 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 inA_b 1 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 241 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rR8) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 242 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 8 Secret dst_b 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 244 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 inA_b 2 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 244 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rR9) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 245 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 16 Secret dst_b 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 247 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 inA_b 3 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 247 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 248 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 24 Secret dst_b 3) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 250 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Newline ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 251 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Comment "Return the carry bit in a register" ) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 252 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 254 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_DestroyHeaplets ()) (va_QEmpty (()))))))))))))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Fast_add1 va_b0 va_s0 dst_b inA_b inB = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Fast_add1 va_mods dst_b inA_b inB in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Fast_add1 ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 182 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_ok va_sM) /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in label va_range1 "***** POSTCONDITION NOT MET AT line 215 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 216 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 217 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 218 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 219 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d = Vale.Curve25519.Fast_defs.pow2_five d0 d1 d2 d3 (va_get_reg64 rRax va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 220 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (d == a + va_get_reg64 rRdx va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 222 column 46 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.modifies_buffer dst_b (va_get_mem va_s0) (va_get_mem va_sM))))))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Fast_add1 dst_b inA_b inB va_s0 va_k = let (va_sM, va_f0) = va_lemma_Fast_add1 (va_code_Fast_add1 ()) va_s0 dst_b inA_b inB in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) #pop-options //-- //-- Fast_add1_stdcall #push-options "--z3rlimit 600" [@ "opaque_to_smt" va_qattr] let va_code_Fast_add1_stdcall win = (va_Block (va_CCons (va_code_Push_Secret (va_op_reg_opr64_reg64 rRdi)) (va_CCons (va_code_Push_Secret (va_op_reg_opr64_reg64 rRsi)) (va_CCons (if win then va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRsi) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR8)) (va_CNil ())))) else va_Block (va_CNil ())) (va_CCons (va_code_Fast_add1 ()) (va_CCons (va_code_Pop_Secret (va_op_dst_opr64_reg64 rRsi)) (va_CCons (va_code_Pop_Secret (va_op_dst_opr64_reg64 rRdi)) (va_CNil ())))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Fast_add1_stdcall win = (va_pbool_and (va_codegen_success_Push_Secret (va_op_reg_opr64_reg64 rRdi)) (va_pbool_and (va_codegen_success_Push_Secret (va_op_reg_opr64_reg64 rRsi)) (va_pbool_and (if win then va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRsi) (va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR8)) (va_ttrue ()))) else va_ttrue ()) (va_pbool_and (va_codegen_success_Fast_add1 ()) (va_pbool_and (va_codegen_success_Pop_Secret (va_op_dst_opr64_reg64 rRsi)) (va_pbool_and (va_codegen_success_Pop_Secret (va_op_dst_opr64_reg64 rRdi)) (va_ttrue ()))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Fast_add1_stdcall (va_mods:va_mods_t) (win:bool) (dst_b:buffer64) (inA_b:buffer64) (inB_in:nat64) : (va_quickCode unit (va_code_Fast_add1_stdcall win)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (dst_in:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s) in let (inA_in:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 323 column 16 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Push_Secret (va_op_reg_opr64_reg64 rRdi)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 324 column 16 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Push_Secret (va_op_reg_opr64_reg64 rRsi)) (fun (va_s:va_state) _ -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 327 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 328 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 329 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRsi) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 330 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR8)) (va_QEmpty (())))))) (qblock va_mods (fun (va_s:va_state) -> va_QEmpty (())))) (fun (va_s:va_state) va_g -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 333 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Fast_add1 dst_b inA_b inB_in) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 335 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Pop_Secret (va_op_dst_opr64_reg64 rRsi)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 336 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Pop_Secret (va_op_dst_opr64_reg64 rRdi)) (va_QEmpty (()))))))))) [@"opaque_to_smt"] let va_lemma_Fast_add1_stdcall va_b0 va_s0 win dst_b inA_b inB_in = let (va_mods:va_mods_t) = [va_Mod_stackTaint; va_Mod_stack; va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRsp; va_Mod_reg64 rRbp; va_Mod_reg64 rRdi; va_Mod_reg64 rRsi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Fast_add1_stdcall va_mods win dst_b inA_b inB_in in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Fast_add1_stdcall win) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 257 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_ok va_sM) /\ (let (dst_in:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (inA_in:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in label va_range1 "***** POSTCONDITION NOT MET AT line 284 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let a0 = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem va_s0) in label va_range1 "***** POSTCONDITION NOT MET AT line 285 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let a1 = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem va_s0) in label va_range1 "***** POSTCONDITION NOT MET AT line 286 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let a2 = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem va_s0) in label va_range1 "***** POSTCONDITION NOT MET AT line 287 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let a3 = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem va_s0) in label va_range1 "***** POSTCONDITION NOT MET AT line 289 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 290 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 291 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 292 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 294 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let a = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in label va_range1 "***** POSTCONDITION NOT MET AT line 295 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d = Vale.Curve25519.Fast_defs.pow2_five d0 d1 d2 d3 (va_get_reg64 rRax va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 297 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (d == a + inB_in) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 303 column 46 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.modifies_buffer dst_b (va_get_mem va_s0) (va_get_mem va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 306 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 307 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 308 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 309 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (win ==> va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 310 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (win ==> va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 311 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 312 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 313 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (win ==> va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 314 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (~win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 315 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (~win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 316 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (~win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 317 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (~win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 318 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (~win ==> va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 320 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0))))))))))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRsp; va_Mod_reg64 rRbp; va_Mod_reg64 rRdi; va_Mod_reg64 rRsi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Fast_add1_stdcall win dst_b inA_b inB_in va_s0 va_k = let (va_sM, va_f0) = va_lemma_Fast_add1_stdcall (va_code_Fast_add1_stdcall win) va_s0 win dst_b inA_b inB_in in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 0 va_sM (va_update_flags va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRsp va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))))))))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRsp; va_Mod_reg64 rRbp; va_Mod_reg64 rRdi; va_Mod_reg64 rRsi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) #pop-options //-- //-- Fast_sub1 #push-options "--z3rlimit 1200" val va_code_Fast_sub1 : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Fast_sub1 () = (va_Block (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsi) 0 Secret) (va_CCons (va_code_Sub64Wrap (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRsi) 8 Secret) (va_CCons (va_code_Sbb64 (va_op_dst_opr64_reg64 rR9) (va_const_opr64 0)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 8 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR10) (va_op_reg_opr64_reg64 rRsi) 16 Secret) (va_CCons (va_code_Sbb64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 0)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 16 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRsi) 24 Secret) (va_CCons (va_code_Sbb64 (va_op_dst_opr64_reg64 rR11) (va_const_opr64 0)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 24 Secret) (va_CCons (va_code_Adc64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_CNil ())))))))))))))))) val va_codegen_success_Fast_sub1 : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Fast_sub1 () = (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsi) 0 Secret) (va_pbool_and (va_codegen_success_Sub64Wrap (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRsi) 8 Secret) (va_pbool_and (va_codegen_success_Sbb64 (va_op_dst_opr64_reg64 rR9) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 8 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR10) (va_op_reg_opr64_reg64 rRsi) 16 Secret) (va_pbool_and (va_codegen_success_Sbb64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 16 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRsi) 24 Secret) (va_pbool_and (va_codegen_success_Sbb64 (va_op_dst_opr64_reg64 rR11) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 24 Secret) (va_pbool_and (va_codegen_success_Adc64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_ttrue ()))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Fast_sub1 (va_mods:va_mods_t) (dst_b:buffer64) (inA_b:buffer64) : (va_quickCode unit (va_code_Fast_sub1 ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 378 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Arch.Types.xor_lemmas ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 379 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 381 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsi) 0 Secret inA_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 382 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Sub64Wrap (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 383 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 0 Secret dst_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 385 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRsi) 8 Secret inA_b 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 386 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Sbb64 (va_op_dst_opr64_reg64 rR9) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 387 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 8 Secret dst_b 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 389 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR10) (va_op_reg_opr64_reg64 rRsi) 16 Secret inA_b 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 390 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Sbb64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 391 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 16 Secret dst_b 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 393 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRsi) 24 Secret inA_b 3) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 394 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Sbb64 (va_op_dst_opr64_reg64 rR11) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 395 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 24 Secret dst_b 3) (fun (va_s:va_state) _ -> let (c:bool) = Vale.X64.Decls.cf (va_get_flags va_s) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 398 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adc64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (fun (va_s:va_state) _ -> va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 399 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_reg64 rRax va_s == Vale.Curve25519.Fast_defs.bool_bit c) (va_QEmpty (()))))))))))))))))))) val va_lemma_Fast_sub1 : va_b0:va_code -> va_s0:va_state -> dst_b:buffer64 -> inA_b:buffer64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Fast_sub1 ()) va_s0 /\ va_get_ok va_s0 /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in (Vale.X64.Decls.buffers_disjoint dst_b inA_b \/ dst_b == inA_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdi va_s0) dst_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) inA_b 4 (va_get_mem_layout va_s0) Secret))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in let d = Vale.Curve25519.Fast_defs.pow2_four d0 d1 d2 d3 in d - va_mul_nat (va_get_reg64 rRax va_sM) pow2_256 == a - va_get_reg64 rRcx va_s0 /\ (va_get_reg64 rRax va_sM == 0 \/ va_get_reg64 rRax va_sM == 1) /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM)) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))) [@"opaque_to_smt"] let va_lemma_Fast_sub1 va_b0 va_s0 dst_b inA_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Fast_sub1 va_mods dst_b inA_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Fast_sub1 ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 339 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_ok va_sM) /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in label va_range1 "***** POSTCONDITION NOT MET AT line 367 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 368 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 369 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 370 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 371 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d = Vale.Curve25519.Fast_defs.pow2_four d0 d1 d2 d3 in label va_range1 "***** POSTCONDITION NOT MET AT line 372 column 41 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (d - va_mul_nat (va_get_reg64 rRax va_sM) pow2_256 == a - va_get_reg64 rRcx va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 373 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_reg64 rRax va_sM == 0 \/ va_get_reg64 rRax va_sM == 1) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 375 column 69 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 376 column 50 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM))))))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Fast_sub1 (dst_b:buffer64) (inA_b:buffer64) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in (Vale.X64.Decls.buffers_disjoint dst_b inA_b \/ dst_b == inA_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdi va_s0) dst_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) inA_b 4 (va_get_mem_layout va_s0) Secret) /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64) (va_x_r11:nat64) (va_x_heap0:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 0 va_x_heap0 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10 (va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem va_s0))))))) in va_get_ok va_sM /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in let d = Vale.Curve25519.Fast_defs.pow2_four d0 d1 d2 d3 in d - va_mul_nat (va_get_reg64 rRax va_sM) pow2_256 == a - va_get_reg64 rRcx va_s0 /\ (va_get_reg64 rRax va_sM == 0 \/ va_get_reg64 rRax va_sM == 1) /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM)) ==> va_k va_sM (()))) val va_wpProof_Fast_sub1 : dst_b:buffer64 -> inA_b:buffer64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Fast_sub1 dst_b inA_b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Fast_sub1 ()) ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Fast_sub1 dst_b inA_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_Fast_sub1 (va_code_Fast_sub1 ()) va_s0 dst_b inA_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Fast_sub1 (dst_b:buffer64) (inA_b:buffer64) : (va_quickCode unit (va_code_Fast_sub1 ())) = (va_QProc (va_code_Fast_sub1 ()) ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_Fast_sub1 dst_b inA_b) (va_wpProof_Fast_sub1 dst_b inA_b)) #pop-options //-- //-- Fast_add #push-options "--z3rlimit 600" val va_code_Fast_add : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Fast_add () = (va_Block (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR8)) (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Add64Wrap (va_op_dst_opr64_reg64 rR9) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 0 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR10) (va_op_reg_opr64_reg64 rRcx) 8 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 8 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRcx) 16 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rR11) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 16 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRcx) 24 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rRbx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRbx) 24 Secret) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR8)) (va_CNil ()))))))))))))))))))))) val va_codegen_success_Fast_add : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Fast_add () = (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR8)) (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Add64Wrap (va_op_dst_opr64_reg64 rR9) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 0 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR10) (va_op_reg_opr64_reg64 rRcx) 8 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 8 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRcx) 16 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rR11) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 16 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRcx) 24 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rRbx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRbx) 24 Secret) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR8)) (va_ttrue ())))))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Fast_add (va_mods:va_mods_t) (dst_b:buffer64) (inA_b:buffer64) (inB_b:buffer64) : (va_quickCode unit (va_code_Fast_add ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 521 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Arch.Types.xor_lemmas ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 522 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR8)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 523 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 525 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRcx) 0 Secret inB_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 526 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 inA_b 0 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 526 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Add64Wrap (va_op_dst_opr64_reg64 rR9) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 527 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 0 Secret dst_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 529 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR10) (va_op_reg_opr64_reg64 rRcx) 8 Secret inB_b 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 530 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 inA_b 1 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 530 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 531 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 8 Secret dst_b 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 533 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRcx) 16 Secret inB_b 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 534 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 inA_b 2 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 534 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rR11) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 535 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 16 Secret dst_b 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 537 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRcx) 24 Secret inB_b 3) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 538 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 inA_b 3 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 538 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rRbx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 539 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRbx) 24 Secret dst_b 3) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 541 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR8)) (va_QEmpty (()))))))))))))))))))))))) val va_lemma_Fast_add : va_b0:va_code -> va_s0:va_state -> dst_b:buffer64 -> inA_b:buffer64 -> inB_b:buffer64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Fast_add ()) va_s0 /\ va_get_ok va_s0 /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in adx_enabled /\ bmi2_enabled /\ (Vale.X64.Decls.buffers_disjoint dst_b inA_b \/ dst_b == inA_b) /\ (Vale.X64.Decls.buffers_disjoint dst_b inB_b \/ dst_b == inB_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdi va_s0) dst_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) inA_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRcx va_s0) inB_b 4 (va_get_mem_layout va_s0) Secret))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in let d = Vale.Curve25519.Fast_defs.pow2_five d0 d1 d2 d3 (va_get_reg64 rRax va_sM) in d == a + b /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM)) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))) [@"opaque_to_smt"] let va_lemma_Fast_add va_b0 va_s0 dst_b inA_b inB_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Fast_add va_mods dst_b inA_b inB_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Fast_add ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 474 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_ok va_sM) /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in label va_range1 "***** POSTCONDITION NOT MET AT line 511 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 512 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 513 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 514 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 515 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d = Vale.Curve25519.Fast_defs.pow2_five d0 d1 d2 d3 (va_get_reg64 rRax va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 516 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (d == a + b) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 518 column 69 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 519 column 50 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM))))))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Fast_add (dst_b:buffer64) (inA_b:buffer64) (inB_b:buffer64) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in adx_enabled /\ bmi2_enabled /\ (Vale.X64.Decls.buffers_disjoint dst_b inA_b \/ dst_b == inA_b) /\ (Vale.X64.Decls.buffers_disjoint dst_b inB_b \/ dst_b == inB_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdi va_s0) dst_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) inA_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRcx va_s0) inB_b 4 (va_get_mem_layout va_s0) Secret) /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64) (va_x_r11:nat64) (va_x_rbx:nat64) (va_x_heap0:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 0 va_x_heap0 (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10 (va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem va_s0)))))))) in va_get_ok va_sM /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in let d = Vale.Curve25519.Fast_defs.pow2_five d0 d1 d2 d3 (va_get_reg64 rRax va_sM) in d == a + b /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM)) ==> va_k va_sM (()))) val va_wpProof_Fast_add : dst_b:buffer64 -> inA_b:buffer64 -> inB_b:buffer64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Fast_add dst_b inA_b inB_b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Fast_add ()) ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Fast_add dst_b inA_b inB_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_Fast_add (va_code_Fast_add ()) va_s0 dst_b inA_b inB_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Fast_add (dst_b:buffer64) (inA_b:buffer64) (inB_b:buffer64) : (va_quickCode unit (va_code_Fast_add ())) = (va_QProc (va_code_Fast_add ()) ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_Fast_add dst_b inA_b inB_b) (va_wpProof_Fast_add dst_b inA_b inB_b)) #pop-options //-- //-- Fast_sub #push-options "--z3rlimit 600" val va_code_Fast_sub : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Fast_sub () = (va_Block (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsi) 0 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Sub64Wrap (va_op_dst_opr64_reg64 rR8) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 0 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRsi) 8 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Sbb64 (va_op_dst_opr64_reg64 rR9) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 8 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 8 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR10) (va_op_reg_opr64_reg64 rRsi) 16 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Sbb64 (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 16 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 16 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRsi) 24 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Sbb64 (va_op_dst_opr64_reg64 rR11) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 24 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 24 Secret) (va_CCons (va_code_Adc64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_CNil ())))))))))))))))))))) val va_codegen_success_Fast_sub : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Fast_sub () = (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsi) 0 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Sub64Wrap (va_op_dst_opr64_reg64 rR8) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 0 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRsi) 8 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Sbb64 (va_op_dst_opr64_reg64 rR9) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 8 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 8 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR10) (va_op_reg_opr64_reg64 rRsi) 16 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Sbb64 (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 16 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 16 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRsi) 24 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Sbb64 (va_op_dst_opr64_reg64 rR11) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 24 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 24 Secret) (va_pbool_and (va_codegen_success_Adc64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_ttrue ()))))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Fast_sub (va_mods:va_mods_t) (dst_b:buffer64) (inA_b:buffer64) (inB_b:buffer64) : (va_quickCode unit (va_code_Fast_sub ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 674 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Arch.Types.xor_lemmas ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 677 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 679 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsi) 0 Secret inA_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 680 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 0 inB_b 0 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 680 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Sub64Wrap (va_op_dst_opr64_reg64 rR8) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 0 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 681 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 0 Secret dst_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 685 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRsi) 8 Secret inA_b 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 686 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 8 inB_b 1 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 686 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Sbb64 (va_op_dst_opr64_reg64 rR9) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 8 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 687 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 8 Secret dst_b 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 691 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR10) (va_op_reg_opr64_reg64 rRsi) 16 Secret inA_b 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 692 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 16 inB_b 2 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 692 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Sbb64 (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 16 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 694 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 16 Secret dst_b 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 696 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRsi) 24 Secret inA_b 3) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 697 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 24 inB_b 3 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 697 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Sbb64 (va_op_dst_opr64_reg64 rR11) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 24 Secret)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 698 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 24 Secret dst_b 3) (fun (va_s:va_state) _ -> let (c:bool) = Vale.X64.Decls.cf (va_get_flags va_s) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 701 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adc64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (fun (va_s:va_state) _ -> va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 702 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_reg64 rRax va_s == Vale.Curve25519.Fast_defs.bool_bit c) (let (va_arg41:Vale.Curve25519.Fast_defs.bit) = Vale.Curve25519.Fast_defs.bool_bit c in let (va_arg40:Vale.Def.Types_s.nat64) = va_get_reg64 rR11 va_s in let (va_arg39:Vale.Def.Types_s.nat64) = va_get_reg64 rR10 va_s in let (va_arg38:Vale.Def.Types_s.nat64) = va_get_reg64 rR9 va_s in let (va_arg37:Vale.Def.Types_s.nat64) = va_get_reg64 rR8 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 704 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Curve25519.FastUtil_helpers.lemma_sub a a0 a1 a2 a3 b b0 b1 b2 b3 va_arg37 va_arg38 va_arg39 va_arg40 va_arg41) (va_QEmpty (())))))))))))))))))))))))) val va_lemma_Fast_sub : va_b0:va_code -> va_s0:va_state -> dst_b:buffer64 -> inA_b:buffer64 -> inB_b:buffer64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Fast_sub ()) va_s0 /\ va_get_ok va_s0 /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in (Vale.X64.Decls.buffers_disjoint dst_b inA_b \/ dst_b == inA_b) /\ (Vale.X64.Decls.buffers_disjoint dst_b inB_b \/ dst_b == inB_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdi va_s0) dst_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) inA_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRcx va_s0) inB_b 4 (va_get_mem_layout va_s0) Secret))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in let d = Vale.Curve25519.Fast_defs.pow2_four d0 d1 d2 d3 in d - va_mul_nat (va_get_reg64 rRax va_sM) pow2_256 == a - b /\ (va_get_reg64 rRax va_sM == 0 \/ va_get_reg64 rRax va_sM == 1) /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM)) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsStack.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.FastUtil_helpers.fsti.checked", "Vale.Curve25519.Fast_lemmas_external.fsti.checked", "Vale.Curve25519.Fast_defs.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.Curve25519.X64.FastUtil.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.FastUtil_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_lemmas_external", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 600, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> dst_b: Vale.X64.Memory.buffer64 -> inA_b: Vale.X64.Memory.buffer64 -> inB_b: Vale.X64.Memory.buffer64 -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
Prims.Ghost
[]
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Vale.X64.Memory.buffer64", "Vale.X64.QuickCodes.fuel", "Prims.unit", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_fuel", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_Mod_mem_heaplet", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rR11", "Vale.X64.Machine_s.rR10", "Vale.X64.Machine_s.rR9", "Vale.X64.Machine_s.rR8", "Vale.X64.Machine_s.rRax", "Vale.X64.QuickCode.va_Mod_ok", "Vale.X64.QuickCode.va_Mod_mem", "Prims.Nil", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.list", "Vale.X64.QuickCode.__proj__QProc__item__mods", "Vale.Curve25519.X64.FastUtil.va_code_Fast_sub", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.tuple3", "Vale.X64.State.vale_state", "Vale.X64.QuickCodes.va_wp_sound_code_norm", "Prims.l_and", "Vale.X64.QuickCodes.label", "Vale.X64.QuickCodes.va_range1", "Prims.b2t", "Vale.X64.Decls.va_get_ok", "Prims.int", "Prims.op_Subtraction", "Vale.X64.Decls.va_mul_nat", "Vale.X64.Decls.va_get_reg64", "Vale.Curve25519.Fast_defs.pow2_256", "Prims.l_or", "Vale.X64.Decls.validSrcAddrs64", "Vale.X64.Decls.va_get_mem_heaplet", "Vale.X64.Machine_s.rRdi", "Vale.X64.Decls.va_get_mem_layout", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.Decls.modifies_buffer", "Prims.nat", "Vale.Curve25519.Fast_defs.pow2_four", "Vale.Def.Words_s.nat64", "Vale.X64.Decls.buffer64_read", "Vale.X64.QuickCode.quickCode", "Vale.Curve25519.X64.FastUtil.va_qcode_Fast_sub" ]
[]
false
false
false
false
false
let va_lemma_Fast_sub va_b0 va_s0 dst_b inA_b inB_b =
let va_mods:va_mods_t = [ va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem ] in let va_qc = va_qcode_Fast_sub va_mods dst_b inA_b inB_b in let va_sM, va_fM, va_g = va_wp_sound_code_norm (va_code_Fast_sub ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 627 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_ok va_sM) /\ (let a0:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let a1:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let a2:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let a3:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let b0:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let b1:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let b2:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let b3:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let a:Prims.nat = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let b:Prims.nat = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in label va_range1 "***** POSTCONDITION NOT MET AT line 663 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 664 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 665 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 666 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 667 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d = Vale.Curve25519.Fast_defs.pow2_four d0 d1 d2 d3 in label va_range1 "***** POSTCONDITION NOT MET AT line 668 column 41 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (d - va_mul_nat (va_get_reg64 rRax va_sM) pow2_256 == a - b) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 669 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_reg64 rRax va_sM == 0 \/ va_get_reg64 rRax va_sM == 1) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 671 column 69 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 672 column 50 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM))))))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([ va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem ]) va_sM va_s0; (va_sM, va_fM)
false
MiniValeSemantics.fst
MiniValeSemantics.wp_Add
val wp_Add (dst src: operand) (k: (state -> Type0)) (s0: state) : Type0
val wp_Add (dst src: operand) (k: (state -> Type0)) (s0: state) : Type0
let wp_Add (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Type0 = OReg? dst /\ eval_operand dst s0 + eval_operand src s0 < pow2_64 /\ (forall (x:nat64). let sM = update_reg s0 (OReg?.r dst) x in eval_operand dst sM == eval_operand dst s0 + eval_operand src s0 ==> k sM )
{ "file_name": "examples/metatheory/MiniValeSemantics.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 3, "end_line": 362, "start_col": 0, "start_line": 357 }
(* 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. Authors: C. Hawblitzel, N. Swamy *) module MiniValeSemantics (* This is a highly-simplified model of Vale/F*, based on Section 3.1-3.3 of the paper of the POPL '19 paper. It is derived from the QuickRegs1 code in the popl-artifact-submit branch of Vale. *) /// We use this tag to mark certain definitions /// and control normalization based on it irreducible let qattr = () /// 2^64 let pow2_64 = 0x10000000000000000 /// Natural numbers representable in 64 bits type nat64 = i:int{0 <= i /\ i < pow2_64} /// We have 4 registers type reg = | Rax | Rbx | Rcx | Rdx /// An operand is either a register or a constant type operand = | OReg: r:reg -> operand | OConst: n:nat64 -> operand /// Only 2 instructions here: /// A move or an add type ins = | Mov64: dst:operand -> src:operand -> ins | Add64: dst:operand -> src:operand -> ins /// A program is /// - a single instruction /// - a block of instructions /// - or a while loop type code = | Ins: ins:ins -> code | Block: block:list code -> code | WhileLessThan: src1:operand -> src2:operand -> whileBody:code -> code /// The state of a program is the register file /// holiding a 64-bit value for each register type state = reg -> nat64 /// fuel: To prove the termination of while loops, we're going to /// instrument while loops with fuel type fuel = nat /// Evaluating an operand: /// -- marked for reduction /// -- Registers evaluated by state lookup [@@qattr] let eval_operand (o:operand) (s:state) : nat64 = match o with | OReg r -> s r | OConst n -> n /// updating a register state `s` at `r` with `v` [@@qattr] let update_reg (s:state) (r:reg) (v:nat64) : state = fun r' -> if r = r' then v else s r' /// updating a register state `s` at `r` with `s' r` [@@qattr] let update_state (r:reg) (s' s:state) : state = update_reg s r (s' r) // We don't have an "ok" flag, so errors just result an arbitrary state: assume val unknown_state (s:state) : state (*** A basic semantics using a big-step interpreter ***) /// Instruction evaluation: /// only some operands are valid let eval_ins (ins:ins) (s:state) : state = match ins with | Mov64 (OConst _) _ -> unknown_state s | Mov64 (OReg dst) src -> update_reg s dst (eval_operand src s) | Add64 (OConst _) _ -> unknown_state s | Add64 (OReg dst) src -> update_reg s dst ((s dst + eval_operand src s) % 0x10000000000000000) /// eval_code: /// A fueled big-step interpreter /// While lops return None when we're out of fuel let rec eval_code (c:code) (f:fuel) (s:state) : option state = match c with | Ins ins -> Some (eval_ins ins s) | Block cs -> eval_codes cs f s | WhileLessThan src1 src2 body -> if f = 0 then None else if eval_operand src1 s < eval_operand src2 s then match eval_code body f s with | None -> None | Some s -> eval_code c (f - 1) s else Some s and eval_codes (cs:list code) (f:fuel) (s:state) : option state = match cs with | [] -> Some s | c::cs -> match eval_code c f s with | None -> None | Some s -> eval_codes cs f s (*** END OF TRUSTED SEMANTICS ***) //////////////////////////////////////////////////////////////////////////////// /// 1. We prove that increasing the fuel is irrelevant to terminating executions val increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code c f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code c fN s0 == Some sN) (decreases %[f0; c]) val increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code (Block c) f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code (Block c) fN s0 == Some sN) (decreases %[f0; c]) let rec increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | Ins ins -> () | Block l -> increase_fuels l s0 f0 sN fN | WhileLessThan src1 src2 body -> if eval_operand src1 s0 < eval_operand src2 s0 then match eval_code body f0 s0 with | None -> () | Some s1 -> increase_fuel body s0 f0 s1 fN; increase_fuel c s1 (f0 - 1) sN (fN - 1) else () and increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | [] -> () | h::t -> let Some s1 = eval_code h f0 s0 in increase_fuel h s0 f0 s1 fN; increase_fuels t s1 f0 sN fN /// 2. We can compute the fuel needed to run a sequential composition /// as the max of the fuel to compute each piece of code in it let lemma_merge (c:code) (cs:list code) (s0:state) (f0:fuel) (sM:state) (fM:fuel) (sN:state) : Ghost fuel (requires eval_code c f0 s0 == Some sM /\ eval_code (Block cs) fM sM == Some sN) (ensures fun fN -> eval_code (Block (c::cs)) fN s0 == Some sN) = let f = if f0 > fM then f0 else fM in increase_fuel c s0 f0 sM f; increase_fuel (Block cs) sM fM sN f; f ///////////////////////////////////////////////////////////////// // Now, we're going to define a verification-condition generator // // The main idea is that we're going to: // // 1. define a kind of typeclass, that associates with a // piece of code a weakest-precondition rule for it // // 2. Define a WP-generator that computes WPs for each of the // control constructs of the language, given a program // represented as the raw code packaged with their typeclass // instances for computing their WPs ///////////////////////////////////////////////////////////////// [@@qattr] let t_post = state -> Type0 [@@qattr] let t_pre = state -> Type0 /// t_wp: The type of weakest preconditions let t_wp = t_post -> t_pre /// c `has_wp` wp: The main judgment in our program logic let has_wp (c:code) (wp:t_wp) : Type = k:t_post -> //for any post-condition s0:state -> //and initial state Ghost (state * fuel) (requires wp k s0) //Given the precondition (ensures fun (sM, f0) -> //we can compute the fuel f0 needed so that eval_code c f0 s0 == Some sM /\ //eval_code with that fuel returns sM k sM) //and the post-condition is true on sM /// An abbreviation for a thunked lemma let t_lemma (pre:Type0) (post:Type0) = unit -> Lemma (requires pre) (ensures post) /// `with_wp` : A typeclass for code packaged with its wp [@@qattr] noeq type with_wp : code -> Type = | QProc: c:code -> wp:t_wp -> hasWp:has_wp c wp -> with_wp c /// `with_wps`: A typclass for lists of code values packages with their wps noeq type with_wps : list code -> Type = | QEmpty: //empty list with_wps [] | QSeq: //cons #c:code -> #cs:list code -> hd:with_wp c -> tl:with_wps cs -> with_wps (c::cs) | QLemma: //augmenting an instruction sequence with a lemma #cs:list code -> pre:Type0 -> post:Type0 -> t_lemma pre post -> with_wps cs -> with_wps cs [@@qattr] let rec vc_gen (cs:list code) (qcs:with_wps cs) (k:t_post) : Tot (state -> Tot Type0 (decreases qcs)) = fun s0 -> match qcs with | QEmpty -> k s0 //no instructions; prove the postcondition right away | QSeq qc qcs -> // let pre_tl = //compute the VC generator for the tail, a precondition qc.wp (vc_gen (Cons?.tl cs) qcs k) s0 // in // qc.wp pre_tl s0 //apply the wp-generator to the precondition for the tail | QLemma pre post _ qcs -> pre /\ //prove the precondition of the lemma (post ==> vc_gen cs qcs k s0) //and assume its postcondition to verify the program /// The vc-generator is sound let rec vc_sound (cs:list code) (qcs:with_wps cs) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires vc_gen cs qcs k s0) (ensures fun (sN, fN) -> eval_code (Block cs) fN s0 == Some sN /\ k sN) = match qcs with | QEmpty -> (s0, 0) | QSeq qc qcs -> let Cons c cs' = cs in let (sM, fM) = qc.hasWp (vc_gen cs' qcs k) s0 in let (sN, fN) = vc_sound cs' qcs k sM in let fN' = lemma_merge c cs' s0 fM sM fN sN in (sN, fN') | QLemma pre post lem qcs' -> lem (); vc_sound cs qcs' k s0 let vc_sound' (cs:list code) (qcs:with_wps cs) : has_wp (Block cs) (vc_gen cs qcs) = vc_sound cs qcs (*** Instances of with_wp ***) //////////////////////////////////////////////////////////////////////////////// //Instance for Mov //////////////////////////////////////////////////////////////////////////////// let lemma_Move (s0:state) (dst:operand) (src:operand) : Ghost (state * fuel) (requires OReg? dst) (ensures fun (sM, fM) -> eval_code (Ins (Mov64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0 ) = let Some sM = eval_code (Ins (Mov64 dst src)) 0 s0 in (sM, 0) [@@qattr] let wp_Move (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Type0 = OReg? dst /\ (forall (x:nat64). let sM = update_reg s0 (OReg?.r dst) x in eval_operand dst sM == eval_operand src s0 ==> k sM ) let hasWp_Move (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires wp_Move dst src k s0) (ensures fun (sM, f0) -> eval_code (Ins (Mov64 dst src)) f0 s0 == Some sM /\ k sM) = lemma_Move s0 dst src [@@qattr] let inst_Move (dst:operand) (src:operand) : with_wp (Ins (Mov64 dst src)) = QProc (Ins (Mov64 dst src)) (wp_Move dst src) (hasWp_Move dst src) //////////////////////////////////////////////////////////////////////////////// //Instance for Add //////////////////////////////////////////////////////////////////////////////// let lemma_Add (s0:state) (dst:operand) (src:operand) : Ghost (state * fuel) (requires OReg? dst /\ eval_operand dst s0 + eval_operand src s0 < pow2_64) (ensures fun (sM, fM) -> eval_code (Ins (Add64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand dst s0 + eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0 ) = let Some sM = eval_code (Ins (Add64 dst src)) 0 s0 in (sM, 0)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "MiniValeSemantics.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: MiniValeSemantics.operand -> src: MiniValeSemantics.operand -> k: (_: MiniValeSemantics.state -> Type0) -> s0: MiniValeSemantics.state -> Type0
Prims.Tot
[ "total" ]
[]
[ "MiniValeSemantics.operand", "MiniValeSemantics.state", "Prims.l_and", "Prims.b2t", "MiniValeSemantics.uu___is_OReg", "Prims.op_LessThan", "Prims.op_Addition", "MiniValeSemantics.eval_operand", "MiniValeSemantics.pow2_64", "Prims.l_Forall", "MiniValeSemantics.nat64", "Prims.l_imp", "Prims.eq2", "Prims.int", "MiniValeSemantics.update_reg", "MiniValeSemantics.__proj__OReg__item__r" ]
[]
false
false
false
true
true
let wp_Add (dst src: operand) (k: (state -> Type0)) (s0: state) : Type0 =
OReg? dst /\ eval_operand dst s0 + eval_operand src s0 < pow2_64 /\ (forall (x: nat64). let sM = update_reg s0 (OReg?.r dst) x in eval_operand dst sM == eval_operand dst s0 + eval_operand src s0 ==> k sM)
false
MiniValeSemantics.fst
MiniValeSemantics.codes_Triple
val codes_Triple:list code
val codes_Triple:list code
let codes_Triple : list code = [Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //1 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //2 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //3 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //4 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //5 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //6 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //7 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //8 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //9 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //10 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //11 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //1 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //2 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //3 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //4 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //5 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //6 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //7 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //8 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //9 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //10 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //11 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //1 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //2 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //3 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //4 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //5 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //6 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //7 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //8 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //9 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //10 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //11 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //1 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //2 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //3 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //4 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //5 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //6 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //7 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //8 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //9 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //10 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //11 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //1 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //2 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //3 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //4 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //5 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //6 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //7 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //8 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //9 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //10 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //11 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //1 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //2 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //3 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //4 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //5 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //6 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //7 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //8 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //9 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //10 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //11 Ins (Add64 (OReg Rax) (OReg Rbx)); //add rax rbx; Ins (Add64 (OReg Rbx) (OReg Rax))]
{ "file_name": "examples/metatheory/MiniValeSemantics.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 37, "end_line": 672, "start_col": 0, "start_line": 406 }
(* 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. Authors: C. Hawblitzel, N. Swamy *) module MiniValeSemantics (* This is a highly-simplified model of Vale/F*, based on Section 3.1-3.3 of the paper of the POPL '19 paper. It is derived from the QuickRegs1 code in the popl-artifact-submit branch of Vale. *) /// We use this tag to mark certain definitions /// and control normalization based on it irreducible let qattr = () /// 2^64 let pow2_64 = 0x10000000000000000 /// Natural numbers representable in 64 bits type nat64 = i:int{0 <= i /\ i < pow2_64} /// We have 4 registers type reg = | Rax | Rbx | Rcx | Rdx /// An operand is either a register or a constant type operand = | OReg: r:reg -> operand | OConst: n:nat64 -> operand /// Only 2 instructions here: /// A move or an add type ins = | Mov64: dst:operand -> src:operand -> ins | Add64: dst:operand -> src:operand -> ins /// A program is /// - a single instruction /// - a block of instructions /// - or a while loop type code = | Ins: ins:ins -> code | Block: block:list code -> code | WhileLessThan: src1:operand -> src2:operand -> whileBody:code -> code /// The state of a program is the register file /// holiding a 64-bit value for each register type state = reg -> nat64 /// fuel: To prove the termination of while loops, we're going to /// instrument while loops with fuel type fuel = nat /// Evaluating an operand: /// -- marked for reduction /// -- Registers evaluated by state lookup [@@qattr] let eval_operand (o:operand) (s:state) : nat64 = match o with | OReg r -> s r | OConst n -> n /// updating a register state `s` at `r` with `v` [@@qattr] let update_reg (s:state) (r:reg) (v:nat64) : state = fun r' -> if r = r' then v else s r' /// updating a register state `s` at `r` with `s' r` [@@qattr] let update_state (r:reg) (s' s:state) : state = update_reg s r (s' r) // We don't have an "ok" flag, so errors just result an arbitrary state: assume val unknown_state (s:state) : state (*** A basic semantics using a big-step interpreter ***) /// Instruction evaluation: /// only some operands are valid let eval_ins (ins:ins) (s:state) : state = match ins with | Mov64 (OConst _) _ -> unknown_state s | Mov64 (OReg dst) src -> update_reg s dst (eval_operand src s) | Add64 (OConst _) _ -> unknown_state s | Add64 (OReg dst) src -> update_reg s dst ((s dst + eval_operand src s) % 0x10000000000000000) /// eval_code: /// A fueled big-step interpreter /// While lops return None when we're out of fuel let rec eval_code (c:code) (f:fuel) (s:state) : option state = match c with | Ins ins -> Some (eval_ins ins s) | Block cs -> eval_codes cs f s | WhileLessThan src1 src2 body -> if f = 0 then None else if eval_operand src1 s < eval_operand src2 s then match eval_code body f s with | None -> None | Some s -> eval_code c (f - 1) s else Some s and eval_codes (cs:list code) (f:fuel) (s:state) : option state = match cs with | [] -> Some s | c::cs -> match eval_code c f s with | None -> None | Some s -> eval_codes cs f s (*** END OF TRUSTED SEMANTICS ***) //////////////////////////////////////////////////////////////////////////////// /// 1. We prove that increasing the fuel is irrelevant to terminating executions val increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code c f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code c fN s0 == Some sN) (decreases %[f0; c]) val increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code (Block c) f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code (Block c) fN s0 == Some sN) (decreases %[f0; c]) let rec increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | Ins ins -> () | Block l -> increase_fuels l s0 f0 sN fN | WhileLessThan src1 src2 body -> if eval_operand src1 s0 < eval_operand src2 s0 then match eval_code body f0 s0 with | None -> () | Some s1 -> increase_fuel body s0 f0 s1 fN; increase_fuel c s1 (f0 - 1) sN (fN - 1) else () and increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | [] -> () | h::t -> let Some s1 = eval_code h f0 s0 in increase_fuel h s0 f0 s1 fN; increase_fuels t s1 f0 sN fN /// 2. We can compute the fuel needed to run a sequential composition /// as the max of the fuel to compute each piece of code in it let lemma_merge (c:code) (cs:list code) (s0:state) (f0:fuel) (sM:state) (fM:fuel) (sN:state) : Ghost fuel (requires eval_code c f0 s0 == Some sM /\ eval_code (Block cs) fM sM == Some sN) (ensures fun fN -> eval_code (Block (c::cs)) fN s0 == Some sN) = let f = if f0 > fM then f0 else fM in increase_fuel c s0 f0 sM f; increase_fuel (Block cs) sM fM sN f; f ///////////////////////////////////////////////////////////////// // Now, we're going to define a verification-condition generator // // The main idea is that we're going to: // // 1. define a kind of typeclass, that associates with a // piece of code a weakest-precondition rule for it // // 2. Define a WP-generator that computes WPs for each of the // control constructs of the language, given a program // represented as the raw code packaged with their typeclass // instances for computing their WPs ///////////////////////////////////////////////////////////////// [@@qattr] let t_post = state -> Type0 [@@qattr] let t_pre = state -> Type0 /// t_wp: The type of weakest preconditions let t_wp = t_post -> t_pre /// c `has_wp` wp: The main judgment in our program logic let has_wp (c:code) (wp:t_wp) : Type = k:t_post -> //for any post-condition s0:state -> //and initial state Ghost (state * fuel) (requires wp k s0) //Given the precondition (ensures fun (sM, f0) -> //we can compute the fuel f0 needed so that eval_code c f0 s0 == Some sM /\ //eval_code with that fuel returns sM k sM) //and the post-condition is true on sM /// An abbreviation for a thunked lemma let t_lemma (pre:Type0) (post:Type0) = unit -> Lemma (requires pre) (ensures post) /// `with_wp` : A typeclass for code packaged with its wp [@@qattr] noeq type with_wp : code -> Type = | QProc: c:code -> wp:t_wp -> hasWp:has_wp c wp -> with_wp c /// `with_wps`: A typclass for lists of code values packages with their wps noeq type with_wps : list code -> Type = | QEmpty: //empty list with_wps [] | QSeq: //cons #c:code -> #cs:list code -> hd:with_wp c -> tl:with_wps cs -> with_wps (c::cs) | QLemma: //augmenting an instruction sequence with a lemma #cs:list code -> pre:Type0 -> post:Type0 -> t_lemma pre post -> with_wps cs -> with_wps cs [@@qattr] let rec vc_gen (cs:list code) (qcs:with_wps cs) (k:t_post) : Tot (state -> Tot Type0 (decreases qcs)) = fun s0 -> match qcs with | QEmpty -> k s0 //no instructions; prove the postcondition right away | QSeq qc qcs -> // let pre_tl = //compute the VC generator for the tail, a precondition qc.wp (vc_gen (Cons?.tl cs) qcs k) s0 // in // qc.wp pre_tl s0 //apply the wp-generator to the precondition for the tail | QLemma pre post _ qcs -> pre /\ //prove the precondition of the lemma (post ==> vc_gen cs qcs k s0) //and assume its postcondition to verify the program /// The vc-generator is sound let rec vc_sound (cs:list code) (qcs:with_wps cs) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires vc_gen cs qcs k s0) (ensures fun (sN, fN) -> eval_code (Block cs) fN s0 == Some sN /\ k sN) = match qcs with | QEmpty -> (s0, 0) | QSeq qc qcs -> let Cons c cs' = cs in let (sM, fM) = qc.hasWp (vc_gen cs' qcs k) s0 in let (sN, fN) = vc_sound cs' qcs k sM in let fN' = lemma_merge c cs' s0 fM sM fN sN in (sN, fN') | QLemma pre post lem qcs' -> lem (); vc_sound cs qcs' k s0 let vc_sound' (cs:list code) (qcs:with_wps cs) : has_wp (Block cs) (vc_gen cs qcs) = vc_sound cs qcs (*** Instances of with_wp ***) //////////////////////////////////////////////////////////////////////////////// //Instance for Mov //////////////////////////////////////////////////////////////////////////////// let lemma_Move (s0:state) (dst:operand) (src:operand) : Ghost (state * fuel) (requires OReg? dst) (ensures fun (sM, fM) -> eval_code (Ins (Mov64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0 ) = let Some sM = eval_code (Ins (Mov64 dst src)) 0 s0 in (sM, 0) [@@qattr] let wp_Move (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Type0 = OReg? dst /\ (forall (x:nat64). let sM = update_reg s0 (OReg?.r dst) x in eval_operand dst sM == eval_operand src s0 ==> k sM ) let hasWp_Move (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires wp_Move dst src k s0) (ensures fun (sM, f0) -> eval_code (Ins (Mov64 dst src)) f0 s0 == Some sM /\ k sM) = lemma_Move s0 dst src [@@qattr] let inst_Move (dst:operand) (src:operand) : with_wp (Ins (Mov64 dst src)) = QProc (Ins (Mov64 dst src)) (wp_Move dst src) (hasWp_Move dst src) //////////////////////////////////////////////////////////////////////////////// //Instance for Add //////////////////////////////////////////////////////////////////////////////// let lemma_Add (s0:state) (dst:operand) (src:operand) : Ghost (state * fuel) (requires OReg? dst /\ eval_operand dst s0 + eval_operand src s0 < pow2_64) (ensures fun (sM, fM) -> eval_code (Ins (Add64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand dst s0 + eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0 ) = let Some sM = eval_code (Ins (Add64 dst src)) 0 s0 in (sM, 0) [@@qattr] let wp_Add (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Type0 = OReg? dst /\ eval_operand dst s0 + eval_operand src s0 < pow2_64 /\ (forall (x:nat64). let sM = update_reg s0 (OReg?.r dst) x in eval_operand dst sM == eval_operand dst s0 + eval_operand src s0 ==> k sM ) let hasWp_Add (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires wp_Add dst src k s0) (ensures fun (sM, f0) -> eval_code (Ins (Add64 dst src)) f0 s0 == Some sM /\ k sM) = lemma_Add s0 dst src [@@qattr] let inst_Add (dst:operand) (src:operand) : with_wp (Ins (Add64 dst src)) = QProc (Ins (Add64 dst src)) (wp_Add dst src) (hasWp_Add dst src) //////////////////////////////////////////////////////////////////////////////// //Running the VC generator using the F* normalizer //////////////////////////////////////////////////////////////////////////////// unfold let normal_steps : list string = [ `%OReg?; `%OReg?.r; `%QProc?.wp; ] unfold let normal (x:Type0) : Type0 = norm [nbe; iota; zeta; simplify; primops; delta_attr [`%qattr]; delta_only normal_steps] x let vc_sound_norm (cs:list code) (qcs:with_wps cs) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires normal (vc_gen cs qcs k s0)) (ensures fun (sN, fN) -> eval_code (Block cs) fN s0 == Some sN /\ k sN) = vc_sound cs qcs k s0 //////////////////////////////////////////////////////////////////////////////// // Verifying a simple program ////////////////////////////////////////////////////////////////////////////////
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "MiniValeSemantics.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.list MiniValeSemantics.code
Prims.Tot
[ "total" ]
[]
[ "Prims.Cons", "MiniValeSemantics.code", "MiniValeSemantics.Ins", "MiniValeSemantics.Mov64", "MiniValeSemantics.OReg", "MiniValeSemantics.Rbx", "MiniValeSemantics.Rax", "MiniValeSemantics.Add64", "Prims.Nil" ]
[]
false
false
false
true
false
let codes_Triple:list code =
[ Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Mov64 (OReg Rbx) (OReg Rax)); Ins (Add64 (OReg Rax) (OReg Rbx)); Ins (Add64 (OReg Rbx) (OReg Rax)) ]
false
MiniValeSemantics.fst
MiniValeSemantics.vc_sound_norm
val vc_sound_norm (cs: list code) (qcs: with_wps cs) (k: (state -> Type0)) (s0: state) : Ghost (state * fuel) (requires normal (vc_gen cs qcs k s0)) (ensures fun (sN, fN) -> eval_code (Block cs) fN s0 == Some sN /\ k sN)
val vc_sound_norm (cs: list code) (qcs: with_wps cs) (k: (state -> Type0)) (s0: state) : Ghost (state * fuel) (requires normal (vc_gen cs qcs k s0)) (ensures fun (sN, fN) -> eval_code (Block cs) fN s0 == Some sN /\ k sN)
let vc_sound_norm (cs:list code) (qcs:with_wps cs) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires normal (vc_gen cs qcs k s0)) (ensures fun (sN, fN) -> eval_code (Block cs) fN s0 == Some sN /\ k sN) = vc_sound cs qcs k s0
{ "file_name": "examples/metatheory/MiniValeSemantics.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 24, "end_line": 399, "start_col": 0, "start_line": 389 }
(* 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. Authors: C. Hawblitzel, N. Swamy *) module MiniValeSemantics (* This is a highly-simplified model of Vale/F*, based on Section 3.1-3.3 of the paper of the POPL '19 paper. It is derived from the QuickRegs1 code in the popl-artifact-submit branch of Vale. *) /// We use this tag to mark certain definitions /// and control normalization based on it irreducible let qattr = () /// 2^64 let pow2_64 = 0x10000000000000000 /// Natural numbers representable in 64 bits type nat64 = i:int{0 <= i /\ i < pow2_64} /// We have 4 registers type reg = | Rax | Rbx | Rcx | Rdx /// An operand is either a register or a constant type operand = | OReg: r:reg -> operand | OConst: n:nat64 -> operand /// Only 2 instructions here: /// A move or an add type ins = | Mov64: dst:operand -> src:operand -> ins | Add64: dst:operand -> src:operand -> ins /// A program is /// - a single instruction /// - a block of instructions /// - or a while loop type code = | Ins: ins:ins -> code | Block: block:list code -> code | WhileLessThan: src1:operand -> src2:operand -> whileBody:code -> code /// The state of a program is the register file /// holiding a 64-bit value for each register type state = reg -> nat64 /// fuel: To prove the termination of while loops, we're going to /// instrument while loops with fuel type fuel = nat /// Evaluating an operand: /// -- marked for reduction /// -- Registers evaluated by state lookup [@@qattr] let eval_operand (o:operand) (s:state) : nat64 = match o with | OReg r -> s r | OConst n -> n /// updating a register state `s` at `r` with `v` [@@qattr] let update_reg (s:state) (r:reg) (v:nat64) : state = fun r' -> if r = r' then v else s r' /// updating a register state `s` at `r` with `s' r` [@@qattr] let update_state (r:reg) (s' s:state) : state = update_reg s r (s' r) // We don't have an "ok" flag, so errors just result an arbitrary state: assume val unknown_state (s:state) : state (*** A basic semantics using a big-step interpreter ***) /// Instruction evaluation: /// only some operands are valid let eval_ins (ins:ins) (s:state) : state = match ins with | Mov64 (OConst _) _ -> unknown_state s | Mov64 (OReg dst) src -> update_reg s dst (eval_operand src s) | Add64 (OConst _) _ -> unknown_state s | Add64 (OReg dst) src -> update_reg s dst ((s dst + eval_operand src s) % 0x10000000000000000) /// eval_code: /// A fueled big-step interpreter /// While lops return None when we're out of fuel let rec eval_code (c:code) (f:fuel) (s:state) : option state = match c with | Ins ins -> Some (eval_ins ins s) | Block cs -> eval_codes cs f s | WhileLessThan src1 src2 body -> if f = 0 then None else if eval_operand src1 s < eval_operand src2 s then match eval_code body f s with | None -> None | Some s -> eval_code c (f - 1) s else Some s and eval_codes (cs:list code) (f:fuel) (s:state) : option state = match cs with | [] -> Some s | c::cs -> match eval_code c f s with | None -> None | Some s -> eval_codes cs f s (*** END OF TRUSTED SEMANTICS ***) //////////////////////////////////////////////////////////////////////////////// /// 1. We prove that increasing the fuel is irrelevant to terminating executions val increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code c f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code c fN s0 == Some sN) (decreases %[f0; c]) val increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code (Block c) f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code (Block c) fN s0 == Some sN) (decreases %[f0; c]) let rec increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | Ins ins -> () | Block l -> increase_fuels l s0 f0 sN fN | WhileLessThan src1 src2 body -> if eval_operand src1 s0 < eval_operand src2 s0 then match eval_code body f0 s0 with | None -> () | Some s1 -> increase_fuel body s0 f0 s1 fN; increase_fuel c s1 (f0 - 1) sN (fN - 1) else () and increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | [] -> () | h::t -> let Some s1 = eval_code h f0 s0 in increase_fuel h s0 f0 s1 fN; increase_fuels t s1 f0 sN fN /// 2. We can compute the fuel needed to run a sequential composition /// as the max of the fuel to compute each piece of code in it let lemma_merge (c:code) (cs:list code) (s0:state) (f0:fuel) (sM:state) (fM:fuel) (sN:state) : Ghost fuel (requires eval_code c f0 s0 == Some sM /\ eval_code (Block cs) fM sM == Some sN) (ensures fun fN -> eval_code (Block (c::cs)) fN s0 == Some sN) = let f = if f0 > fM then f0 else fM in increase_fuel c s0 f0 sM f; increase_fuel (Block cs) sM fM sN f; f ///////////////////////////////////////////////////////////////// // Now, we're going to define a verification-condition generator // // The main idea is that we're going to: // // 1. define a kind of typeclass, that associates with a // piece of code a weakest-precondition rule for it // // 2. Define a WP-generator that computes WPs for each of the // control constructs of the language, given a program // represented as the raw code packaged with their typeclass // instances for computing their WPs ///////////////////////////////////////////////////////////////// [@@qattr] let t_post = state -> Type0 [@@qattr] let t_pre = state -> Type0 /// t_wp: The type of weakest preconditions let t_wp = t_post -> t_pre /// c `has_wp` wp: The main judgment in our program logic let has_wp (c:code) (wp:t_wp) : Type = k:t_post -> //for any post-condition s0:state -> //and initial state Ghost (state * fuel) (requires wp k s0) //Given the precondition (ensures fun (sM, f0) -> //we can compute the fuel f0 needed so that eval_code c f0 s0 == Some sM /\ //eval_code with that fuel returns sM k sM) //and the post-condition is true on sM /// An abbreviation for a thunked lemma let t_lemma (pre:Type0) (post:Type0) = unit -> Lemma (requires pre) (ensures post) /// `with_wp` : A typeclass for code packaged with its wp [@@qattr] noeq type with_wp : code -> Type = | QProc: c:code -> wp:t_wp -> hasWp:has_wp c wp -> with_wp c /// `with_wps`: A typclass for lists of code values packages with their wps noeq type with_wps : list code -> Type = | QEmpty: //empty list with_wps [] | QSeq: //cons #c:code -> #cs:list code -> hd:with_wp c -> tl:with_wps cs -> with_wps (c::cs) | QLemma: //augmenting an instruction sequence with a lemma #cs:list code -> pre:Type0 -> post:Type0 -> t_lemma pre post -> with_wps cs -> with_wps cs [@@qattr] let rec vc_gen (cs:list code) (qcs:with_wps cs) (k:t_post) : Tot (state -> Tot Type0 (decreases qcs)) = fun s0 -> match qcs with | QEmpty -> k s0 //no instructions; prove the postcondition right away | QSeq qc qcs -> // let pre_tl = //compute the VC generator for the tail, a precondition qc.wp (vc_gen (Cons?.tl cs) qcs k) s0 // in // qc.wp pre_tl s0 //apply the wp-generator to the precondition for the tail | QLemma pre post _ qcs -> pre /\ //prove the precondition of the lemma (post ==> vc_gen cs qcs k s0) //and assume its postcondition to verify the program /// The vc-generator is sound let rec vc_sound (cs:list code) (qcs:with_wps cs) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires vc_gen cs qcs k s0) (ensures fun (sN, fN) -> eval_code (Block cs) fN s0 == Some sN /\ k sN) = match qcs with | QEmpty -> (s0, 0) | QSeq qc qcs -> let Cons c cs' = cs in let (sM, fM) = qc.hasWp (vc_gen cs' qcs k) s0 in let (sN, fN) = vc_sound cs' qcs k sM in let fN' = lemma_merge c cs' s0 fM sM fN sN in (sN, fN') | QLemma pre post lem qcs' -> lem (); vc_sound cs qcs' k s0 let vc_sound' (cs:list code) (qcs:with_wps cs) : has_wp (Block cs) (vc_gen cs qcs) = vc_sound cs qcs (*** Instances of with_wp ***) //////////////////////////////////////////////////////////////////////////////// //Instance for Mov //////////////////////////////////////////////////////////////////////////////// let lemma_Move (s0:state) (dst:operand) (src:operand) : Ghost (state * fuel) (requires OReg? dst) (ensures fun (sM, fM) -> eval_code (Ins (Mov64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0 ) = let Some sM = eval_code (Ins (Mov64 dst src)) 0 s0 in (sM, 0) [@@qattr] let wp_Move (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Type0 = OReg? dst /\ (forall (x:nat64). let sM = update_reg s0 (OReg?.r dst) x in eval_operand dst sM == eval_operand src s0 ==> k sM ) let hasWp_Move (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires wp_Move dst src k s0) (ensures fun (sM, f0) -> eval_code (Ins (Mov64 dst src)) f0 s0 == Some sM /\ k sM) = lemma_Move s0 dst src [@@qattr] let inst_Move (dst:operand) (src:operand) : with_wp (Ins (Mov64 dst src)) = QProc (Ins (Mov64 dst src)) (wp_Move dst src) (hasWp_Move dst src) //////////////////////////////////////////////////////////////////////////////// //Instance for Add //////////////////////////////////////////////////////////////////////////////// let lemma_Add (s0:state) (dst:operand) (src:operand) : Ghost (state * fuel) (requires OReg? dst /\ eval_operand dst s0 + eval_operand src s0 < pow2_64) (ensures fun (sM, fM) -> eval_code (Ins (Add64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand dst s0 + eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0 ) = let Some sM = eval_code (Ins (Add64 dst src)) 0 s0 in (sM, 0) [@@qattr] let wp_Add (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Type0 = OReg? dst /\ eval_operand dst s0 + eval_operand src s0 < pow2_64 /\ (forall (x:nat64). let sM = update_reg s0 (OReg?.r dst) x in eval_operand dst sM == eval_operand dst s0 + eval_operand src s0 ==> k sM ) let hasWp_Add (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires wp_Add dst src k s0) (ensures fun (sM, f0) -> eval_code (Ins (Add64 dst src)) f0 s0 == Some sM /\ k sM) = lemma_Add s0 dst src [@@qattr] let inst_Add (dst:operand) (src:operand) : with_wp (Ins (Add64 dst src)) = QProc (Ins (Add64 dst src)) (wp_Add dst src) (hasWp_Add dst src) //////////////////////////////////////////////////////////////////////////////// //Running the VC generator using the F* normalizer //////////////////////////////////////////////////////////////////////////////// unfold let normal_steps : list string = [ `%OReg?; `%OReg?.r; `%QProc?.wp; ] unfold let normal (x:Type0) : Type0 = norm [nbe; iota; zeta; simplify; primops; delta_attr [`%qattr]; delta_only normal_steps] x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "MiniValeSemantics.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
cs: Prims.list MiniValeSemantics.code -> qcs: MiniValeSemantics.with_wps cs -> k: (_: MiniValeSemantics.state -> Type0) -> s0: MiniValeSemantics.state -> Prims.Ghost (MiniValeSemantics.state * MiniValeSemantics.fuel)
Prims.Ghost
[]
[]
[ "Prims.list", "MiniValeSemantics.code", "MiniValeSemantics.with_wps", "MiniValeSemantics.state", "MiniValeSemantics.vc_sound", "FStar.Pervasives.Native.tuple2", "MiniValeSemantics.fuel", "MiniValeSemantics.normal", "MiniValeSemantics.vc_gen", "Prims.l_and", "Prims.eq2", "FStar.Pervasives.Native.option", "MiniValeSemantics.eval_code", "MiniValeSemantics.Block", "FStar.Pervasives.Native.Some" ]
[]
false
false
false
false
false
let vc_sound_norm (cs: list code) (qcs: with_wps cs) (k: (state -> Type0)) (s0: state) : Ghost (state * fuel) (requires normal (vc_gen cs qcs k s0)) (ensures fun (sN, fN) -> eval_code (Block cs) fN s0 == Some sN /\ k sN) =
vc_sound cs qcs k s0
false
FStar.Reflection.V2.Derived.Lemmas.fst
FStar.Reflection.V2.Derived.Lemmas.list_ref
val list_ref : (#a:Type) -> (#p:(a -> Type)) -> (l:list a) -> Pure (list (x:a{p x})) (requires (forallP p l)) (ensures (fun _ -> True))
val list_ref : (#a:Type) -> (#p:(a -> Type)) -> (l:list a) -> Pure (list (x:a{p x})) (requires (forallP p l)) (ensures (fun _ -> True))
let rec list_ref #a #p l = match l with | [] -> [] | x::xs -> x :: list_ref #a #p xs
{ "file_name": "ulib/FStar.Reflection.V2.Derived.Lemmas.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 37, "end_line": 43, "start_col": 0, "start_line": 40 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Derived.Lemmas open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Builtins open FStar.Stubs.Reflection.V2.Data open FStar.Reflection.V2.Derived open FStar.List.Tot let rec forall_list (p:'a -> Type) (l:list 'a) : Type = match l with | [] -> True | x::xs -> p x /\ forall_list p xs let forallP (p: 'a -> Type) (l: list 'a): Type = forall (x: 'a). memP x l ==> p x // Precedence relation on the element of a list unfold let (<<:) (l: list 'a) (r: 'r) = forallP (fun x -> x << r) l // A glorified `id` val list_ref : (#a:Type) -> (#p:(a -> Type)) -> (l:list a) -> Pure (list (x:a{p x})) (requires (forallP p l))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.V2.Derived.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Derived.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
l: Prims.list a -> Prims.Pure (Prims.list (x: a{p x}))
Prims.Pure
[]
[]
[ "Prims.list", "Prims.Nil", "Prims.Cons", "FStar.Reflection.V2.Derived.Lemmas.list_ref" ]
[ "recursion" ]
false
false
false
false
false
let rec list_ref #a #p l =
match l with | [] -> [] | x :: xs -> x :: list_ref #a #p xs
false
MiniValeSemantics.fst
MiniValeSemantics.lemma_Add
val lemma_Add (s0: state) (dst src: operand) : Ghost (state * fuel) (requires OReg? dst /\ eval_operand dst s0 + eval_operand src s0 < pow2_64) (ensures fun (sM, fM) -> eval_code (Ins (Add64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand dst s0 + eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0)
val lemma_Add (s0: state) (dst src: operand) : Ghost (state * fuel) (requires OReg? dst /\ eval_operand dst s0 + eval_operand src s0 < pow2_64) (ensures fun (sM, fM) -> eval_code (Ins (Add64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand dst s0 + eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0)
let lemma_Add (s0:state) (dst:operand) (src:operand) : Ghost (state * fuel) (requires OReg? dst /\ eval_operand dst s0 + eval_operand src s0 < pow2_64) (ensures fun (sM, fM) -> eval_code (Ins (Add64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand dst s0 + eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0 ) = let Some sM = eval_code (Ins (Add64 dst src)) 0 s0 in (sM, 0)
{ "file_name": "examples/metatheory/MiniValeSemantics.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 9, "end_line": 354, "start_col": 0, "start_line": 345 }
(* 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. Authors: C. Hawblitzel, N. Swamy *) module MiniValeSemantics (* This is a highly-simplified model of Vale/F*, based on Section 3.1-3.3 of the paper of the POPL '19 paper. It is derived from the QuickRegs1 code in the popl-artifact-submit branch of Vale. *) /// We use this tag to mark certain definitions /// and control normalization based on it irreducible let qattr = () /// 2^64 let pow2_64 = 0x10000000000000000 /// Natural numbers representable in 64 bits type nat64 = i:int{0 <= i /\ i < pow2_64} /// We have 4 registers type reg = | Rax | Rbx | Rcx | Rdx /// An operand is either a register or a constant type operand = | OReg: r:reg -> operand | OConst: n:nat64 -> operand /// Only 2 instructions here: /// A move or an add type ins = | Mov64: dst:operand -> src:operand -> ins | Add64: dst:operand -> src:operand -> ins /// A program is /// - a single instruction /// - a block of instructions /// - or a while loop type code = | Ins: ins:ins -> code | Block: block:list code -> code | WhileLessThan: src1:operand -> src2:operand -> whileBody:code -> code /// The state of a program is the register file /// holiding a 64-bit value for each register type state = reg -> nat64 /// fuel: To prove the termination of while loops, we're going to /// instrument while loops with fuel type fuel = nat /// Evaluating an operand: /// -- marked for reduction /// -- Registers evaluated by state lookup [@@qattr] let eval_operand (o:operand) (s:state) : nat64 = match o with | OReg r -> s r | OConst n -> n /// updating a register state `s` at `r` with `v` [@@qattr] let update_reg (s:state) (r:reg) (v:nat64) : state = fun r' -> if r = r' then v else s r' /// updating a register state `s` at `r` with `s' r` [@@qattr] let update_state (r:reg) (s' s:state) : state = update_reg s r (s' r) // We don't have an "ok" flag, so errors just result an arbitrary state: assume val unknown_state (s:state) : state (*** A basic semantics using a big-step interpreter ***) /// Instruction evaluation: /// only some operands are valid let eval_ins (ins:ins) (s:state) : state = match ins with | Mov64 (OConst _) _ -> unknown_state s | Mov64 (OReg dst) src -> update_reg s dst (eval_operand src s) | Add64 (OConst _) _ -> unknown_state s | Add64 (OReg dst) src -> update_reg s dst ((s dst + eval_operand src s) % 0x10000000000000000) /// eval_code: /// A fueled big-step interpreter /// While lops return None when we're out of fuel let rec eval_code (c:code) (f:fuel) (s:state) : option state = match c with | Ins ins -> Some (eval_ins ins s) | Block cs -> eval_codes cs f s | WhileLessThan src1 src2 body -> if f = 0 then None else if eval_operand src1 s < eval_operand src2 s then match eval_code body f s with | None -> None | Some s -> eval_code c (f - 1) s else Some s and eval_codes (cs:list code) (f:fuel) (s:state) : option state = match cs with | [] -> Some s | c::cs -> match eval_code c f s with | None -> None | Some s -> eval_codes cs f s (*** END OF TRUSTED SEMANTICS ***) //////////////////////////////////////////////////////////////////////////////// /// 1. We prove that increasing the fuel is irrelevant to terminating executions val increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code c f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code c fN s0 == Some sN) (decreases %[f0; c]) val increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code (Block c) f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code (Block c) fN s0 == Some sN) (decreases %[f0; c]) let rec increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | Ins ins -> () | Block l -> increase_fuels l s0 f0 sN fN | WhileLessThan src1 src2 body -> if eval_operand src1 s0 < eval_operand src2 s0 then match eval_code body f0 s0 with | None -> () | Some s1 -> increase_fuel body s0 f0 s1 fN; increase_fuel c s1 (f0 - 1) sN (fN - 1) else () and increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | [] -> () | h::t -> let Some s1 = eval_code h f0 s0 in increase_fuel h s0 f0 s1 fN; increase_fuels t s1 f0 sN fN /// 2. We can compute the fuel needed to run a sequential composition /// as the max of the fuel to compute each piece of code in it let lemma_merge (c:code) (cs:list code) (s0:state) (f0:fuel) (sM:state) (fM:fuel) (sN:state) : Ghost fuel (requires eval_code c f0 s0 == Some sM /\ eval_code (Block cs) fM sM == Some sN) (ensures fun fN -> eval_code (Block (c::cs)) fN s0 == Some sN) = let f = if f0 > fM then f0 else fM in increase_fuel c s0 f0 sM f; increase_fuel (Block cs) sM fM sN f; f ///////////////////////////////////////////////////////////////// // Now, we're going to define a verification-condition generator // // The main idea is that we're going to: // // 1. define a kind of typeclass, that associates with a // piece of code a weakest-precondition rule for it // // 2. Define a WP-generator that computes WPs for each of the // control constructs of the language, given a program // represented as the raw code packaged with their typeclass // instances for computing their WPs ///////////////////////////////////////////////////////////////// [@@qattr] let t_post = state -> Type0 [@@qattr] let t_pre = state -> Type0 /// t_wp: The type of weakest preconditions let t_wp = t_post -> t_pre /// c `has_wp` wp: The main judgment in our program logic let has_wp (c:code) (wp:t_wp) : Type = k:t_post -> //for any post-condition s0:state -> //and initial state Ghost (state * fuel) (requires wp k s0) //Given the precondition (ensures fun (sM, f0) -> //we can compute the fuel f0 needed so that eval_code c f0 s0 == Some sM /\ //eval_code with that fuel returns sM k sM) //and the post-condition is true on sM /// An abbreviation for a thunked lemma let t_lemma (pre:Type0) (post:Type0) = unit -> Lemma (requires pre) (ensures post) /// `with_wp` : A typeclass for code packaged with its wp [@@qattr] noeq type with_wp : code -> Type = | QProc: c:code -> wp:t_wp -> hasWp:has_wp c wp -> with_wp c /// `with_wps`: A typclass for lists of code values packages with their wps noeq type with_wps : list code -> Type = | QEmpty: //empty list with_wps [] | QSeq: //cons #c:code -> #cs:list code -> hd:with_wp c -> tl:with_wps cs -> with_wps (c::cs) | QLemma: //augmenting an instruction sequence with a lemma #cs:list code -> pre:Type0 -> post:Type0 -> t_lemma pre post -> with_wps cs -> with_wps cs [@@qattr] let rec vc_gen (cs:list code) (qcs:with_wps cs) (k:t_post) : Tot (state -> Tot Type0 (decreases qcs)) = fun s0 -> match qcs with | QEmpty -> k s0 //no instructions; prove the postcondition right away | QSeq qc qcs -> // let pre_tl = //compute the VC generator for the tail, a precondition qc.wp (vc_gen (Cons?.tl cs) qcs k) s0 // in // qc.wp pre_tl s0 //apply the wp-generator to the precondition for the tail | QLemma pre post _ qcs -> pre /\ //prove the precondition of the lemma (post ==> vc_gen cs qcs k s0) //and assume its postcondition to verify the program /// The vc-generator is sound let rec vc_sound (cs:list code) (qcs:with_wps cs) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires vc_gen cs qcs k s0) (ensures fun (sN, fN) -> eval_code (Block cs) fN s0 == Some sN /\ k sN) = match qcs with | QEmpty -> (s0, 0) | QSeq qc qcs -> let Cons c cs' = cs in let (sM, fM) = qc.hasWp (vc_gen cs' qcs k) s0 in let (sN, fN) = vc_sound cs' qcs k sM in let fN' = lemma_merge c cs' s0 fM sM fN sN in (sN, fN') | QLemma pre post lem qcs' -> lem (); vc_sound cs qcs' k s0 let vc_sound' (cs:list code) (qcs:with_wps cs) : has_wp (Block cs) (vc_gen cs qcs) = vc_sound cs qcs (*** Instances of with_wp ***) //////////////////////////////////////////////////////////////////////////////// //Instance for Mov //////////////////////////////////////////////////////////////////////////////// let lemma_Move (s0:state) (dst:operand) (src:operand) : Ghost (state * fuel) (requires OReg? dst) (ensures fun (sM, fM) -> eval_code (Ins (Mov64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0 ) = let Some sM = eval_code (Ins (Mov64 dst src)) 0 s0 in (sM, 0) [@@qattr] let wp_Move (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Type0 = OReg? dst /\ (forall (x:nat64). let sM = update_reg s0 (OReg?.r dst) x in eval_operand dst sM == eval_operand src s0 ==> k sM ) let hasWp_Move (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires wp_Move dst src k s0) (ensures fun (sM, f0) -> eval_code (Ins (Mov64 dst src)) f0 s0 == Some sM /\ k sM) = lemma_Move s0 dst src [@@qattr] let inst_Move (dst:operand) (src:operand) : with_wp (Ins (Mov64 dst src)) = QProc (Ins (Mov64 dst src)) (wp_Move dst src) (hasWp_Move dst src) //////////////////////////////////////////////////////////////////////////////// //Instance for Add
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "MiniValeSemantics.fst" }
[ { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s0: MiniValeSemantics.state -> dst: MiniValeSemantics.operand -> src: MiniValeSemantics.operand -> Prims.Ghost (MiniValeSemantics.state * MiniValeSemantics.fuel)
Prims.Ghost
[]
[]
[ "MiniValeSemantics.state", "MiniValeSemantics.operand", "FStar.Pervasives.Native.Mktuple2", "MiniValeSemantics.fuel", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.option", "MiniValeSemantics.eval_code", "MiniValeSemantics.Ins", "MiniValeSemantics.Add64", "Prims.l_and", "Prims.b2t", "MiniValeSemantics.uu___is_OReg", "Prims.op_LessThan", "Prims.op_Addition", "MiniValeSemantics.eval_operand", "MiniValeSemantics.pow2_64", "Prims.eq2", "FStar.Pervasives.Native.Some", "Prims.int", "MiniValeSemantics.update_state", "MiniValeSemantics.__proj__OReg__item__r" ]
[]
false
false
false
false
false
let lemma_Add (s0: state) (dst src: operand) : Ghost (state * fuel) (requires OReg? dst /\ eval_operand dst s0 + eval_operand src s0 < pow2_64) (ensures fun (sM, fM) -> eval_code (Ins (Add64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand dst s0 + eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0) =
let Some sM = eval_code (Ins (Add64 dst src)) 0 s0 in (sM, 0)
false
FStar.Reflection.V2.Derived.Lemmas.fst
FStar.Reflection.V2.Derived.Lemmas.collect_app_ref
val collect_app_ref : (t:term) -> (h:term{h == t \/ h << t}) * list (a:argv{fst a << t})
val collect_app_ref : (t:term) -> (h:term{h == t \/ h << t}) * list (a:argv{fst a << t})
let collect_app_ref t = let h, a = collect_app_ln t in collect_app_order t; h, list_ref a
{ "file_name": "ulib/FStar.Reflection.V2.Derived.Lemmas.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 17, "end_line": 68, "start_col": 0, "start_line": 65 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Derived.Lemmas open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Builtins open FStar.Stubs.Reflection.V2.Data open FStar.Reflection.V2.Derived open FStar.List.Tot let rec forall_list (p:'a -> Type) (l:list 'a) : Type = match l with | [] -> True | x::xs -> p x /\ forall_list p xs let forallP (p: 'a -> Type) (l: list 'a): Type = forall (x: 'a). memP x l ==> p x // Precedence relation on the element of a list unfold let (<<:) (l: list 'a) (r: 'r) = forallP (fun x -> x << r) l // A glorified `id` val list_ref : (#a:Type) -> (#p:(a -> Type)) -> (l:list a) -> Pure (list (x:a{p x})) (requires (forallP p l)) (ensures (fun _ -> True)) let rec list_ref #a #p l = match l with | [] -> [] | x::xs -> x :: list_ref #a #p xs val collect_app_order' : (args:list argv) -> (tt:term) -> (t:term) -> Lemma (requires args <<: tt /\ t << tt) (ensures (let fn, args' = collect_app_ln' args t in args' <<: tt /\ fn << tt)) (decreases t) let rec collect_app_order' args tt t = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_order' (r::args) tt l | _ -> () val collect_app_order : (t:term) -> Lemma (ensures (forall (f:term). forall (s:list argv). (f,s) == collect_app_ln t ==> (f << t /\ s <<: t) \/ (f == t /\ s == []))) let collect_app_order t = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_order' [r] t l | _ -> ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.V2.Derived.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Derived.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: FStar.Stubs.Reflection.Types.term -> h: FStar.Stubs.Reflection.Types.term{h == t \/ h << t} * Prims.list (a: FStar.Stubs.Reflection.V2.Data.argv{FStar.Pervasives.Native.fst a << t})
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "Prims.list", "FStar.Stubs.Reflection.V2.Data.argv", "FStar.Pervasives.Native.Mktuple2", "Prims.l_or", "Prims.eq2", "Prims.precedes", "FStar.Pervasives.Native.fst", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Reflection.V2.Derived.Lemmas.list_ref", "Prims.unit", "FStar.Reflection.V2.Derived.Lemmas.collect_app_order", "FStar.Pervasives.Native.tuple2", "FStar.Reflection.V2.Derived.collect_app_ln" ]
[]
false
false
false
false
false
let collect_app_ref t =
let h, a = collect_app_ln t in collect_app_order t; h, list_ref a
false
FStar.Reflection.V2.Derived.Lemmas.fst
FStar.Reflection.V2.Derived.Lemmas.collect_app_order'
val collect_app_order' : (args:list argv) -> (tt:term) -> (t:term) -> Lemma (requires args <<: tt /\ t << tt) (ensures (let fn, args' = collect_app_ln' args t in args' <<: tt /\ fn << tt)) (decreases t)
val collect_app_order' : (args:list argv) -> (tt:term) -> (t:term) -> Lemma (requires args <<: tt /\ t << tt) (ensures (let fn, args' = collect_app_ln' args t in args' <<: tt /\ fn << tt)) (decreases t)
let rec collect_app_order' args tt t = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_order' (r::args) tt l | _ -> ()
{ "file_name": "ulib/FStar.Reflection.V2.Derived.Lemmas.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 13, "end_line": 53, "start_col": 0, "start_line": 50 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Derived.Lemmas open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Builtins open FStar.Stubs.Reflection.V2.Data open FStar.Reflection.V2.Derived open FStar.List.Tot let rec forall_list (p:'a -> Type) (l:list 'a) : Type = match l with | [] -> True | x::xs -> p x /\ forall_list p xs let forallP (p: 'a -> Type) (l: list 'a): Type = forall (x: 'a). memP x l ==> p x // Precedence relation on the element of a list unfold let (<<:) (l: list 'a) (r: 'r) = forallP (fun x -> x << r) l // A glorified `id` val list_ref : (#a:Type) -> (#p:(a -> Type)) -> (l:list a) -> Pure (list (x:a{p x})) (requires (forallP p l)) (ensures (fun _ -> True)) let rec list_ref #a #p l = match l with | [] -> [] | x::xs -> x :: list_ref #a #p xs val collect_app_order' : (args:list argv) -> (tt:term) -> (t:term) -> Lemma (requires args <<: tt /\ t << tt) (ensures (let fn, args' = collect_app_ln' args t in args' <<: tt /\ fn << tt))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.V2.Derived.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Derived.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
args: Prims.list FStar.Stubs.Reflection.V2.Data.argv -> tt: FStar.Stubs.Reflection.Types.term -> t: FStar.Stubs.Reflection.Types.term -> FStar.Pervasives.Lemma (requires args <<: tt /\ t << tt) (ensures (let _ = FStar.Reflection.V2.Derived.collect_app_ln' args t in (let FStar.Pervasives.Native.Mktuple2 #_ #_ fn args' = _ in args' <<: tt /\ fn << tt) <: Type0)) (decreases t)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "Prims.list", "FStar.Stubs.Reflection.V2.Data.argv", "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.V2.Derived.inspect_ln_unascribe", "FStar.Reflection.V2.Derived.Lemmas.collect_app_order'", "Prims.Cons", "FStar.Stubs.Reflection.V2.Data.term_view", "Prims.unit" ]
[ "recursion" ]
false
false
true
false
false
let rec collect_app_order' args tt t =
match inspect_ln_unascribe t with | Tv_App l r -> collect_app_order' (r :: args) tt l | _ -> ()
false
FStar.Reflection.V2.Derived.Lemmas.fst
FStar.Reflection.V2.Derived.Lemmas.collect_app_order
val collect_app_order : (t:term) -> Lemma (ensures (forall (f:term). forall (s:list argv). (f,s) == collect_app_ln t ==> (f << t /\ s <<: t) \/ (f == t /\ s == [])))
val collect_app_order : (t:term) -> Lemma (ensures (forall (f:term). forall (s:list argv). (f,s) == collect_app_ln t ==> (f << t /\ s <<: t) \/ (f == t /\ s == [])))
let collect_app_order t = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_order' [r] t l | _ -> ()
{ "file_name": "ulib/FStar.Reflection.V2.Derived.Lemmas.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 13, "end_line": 62, "start_col": 0, "start_line": 59 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Derived.Lemmas open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Builtins open FStar.Stubs.Reflection.V2.Data open FStar.Reflection.V2.Derived open FStar.List.Tot let rec forall_list (p:'a -> Type) (l:list 'a) : Type = match l with | [] -> True | x::xs -> p x /\ forall_list p xs let forallP (p: 'a -> Type) (l: list 'a): Type = forall (x: 'a). memP x l ==> p x // Precedence relation on the element of a list unfold let (<<:) (l: list 'a) (r: 'r) = forallP (fun x -> x << r) l // A glorified `id` val list_ref : (#a:Type) -> (#p:(a -> Type)) -> (l:list a) -> Pure (list (x:a{p x})) (requires (forallP p l)) (ensures (fun _ -> True)) let rec list_ref #a #p l = match l with | [] -> [] | x::xs -> x :: list_ref #a #p xs val collect_app_order' : (args:list argv) -> (tt:term) -> (t:term) -> Lemma (requires args <<: tt /\ t << tt) (ensures (let fn, args' = collect_app_ln' args t in args' <<: tt /\ fn << tt)) (decreases t) let rec collect_app_order' args tt t = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_order' (r::args) tt l | _ -> () val collect_app_order : (t:term) -> Lemma (ensures (forall (f:term). forall (s:list argv). (f,s) == collect_app_ln t ==> (f << t /\ s <<: t)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.V2.Derived.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Derived.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: FStar.Stubs.Reflection.Types.term -> FStar.Pervasives.Lemma (ensures forall (f: FStar.Stubs.Reflection.Types.term) (s: Prims.list FStar.Stubs.Reflection.V2.Data.argv). (f, s) == FStar.Reflection.V2.Derived.collect_app_ln t ==> f << t /\ s <<: t \/ f == t /\ s == [])
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.V2.Derived.inspect_ln_unascribe", "FStar.Stubs.Reflection.V2.Data.argv", "FStar.Reflection.V2.Derived.Lemmas.collect_app_order'", "Prims.Cons", "Prims.Nil", "FStar.Stubs.Reflection.V2.Data.term_view", "Prims.unit" ]
[]
false
false
true
false
false
let collect_app_order t =
match inspect_ln_unascribe t with | Tv_App l r -> collect_app_order' [r] t l | _ -> ()
false
FStar.DM4F.OTP.Heap.fsti
FStar.DM4F.OTP.Heap.elem
val elem : Type0
let elem = bv_t q
{ "file_name": "examples/dm4free/FStar.DM4F.OTP.Heap.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 17, "end_line": 27, "start_col": 0, "start_line": 27 }
(* 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.DM4F.OTP.Heap open FStar.BitVector open FStar.Seq (***** Random tape *****) let size = 10 val q: pos
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.DM4F.OTP.Heap.fsti" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.OTP", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.BitVector.bv_t", "FStar.DM4F.OTP.Heap.q" ]
[]
false
false
false
true
true
let elem =
bv_t q
false
FStar.Reflection.V2.Derived.Lemmas.fst
FStar.Reflection.V2.Derived.Lemmas.collect_abs_order'
val collect_abs_order' (bds: binders) (tt t: term) : Lemma (requires t << tt /\ bds <<: tt) (ensures (let bds', body = collect_abs' bds t in (bds' <<: tt /\ body << tt))) (decreases t)
val collect_abs_order' (bds: binders) (tt t: term) : Lemma (requires t << tt /\ bds <<: tt) (ensures (let bds', body = collect_abs' bds t in (bds' <<: tt /\ body << tt))) (decreases t)
let rec collect_abs_order' (bds: binders) (tt t: term) : Lemma (requires t << tt /\ bds <<: tt) (ensures (let bds', body = collect_abs' bds t in (bds' <<: tt /\ body << tt))) (decreases t) = match inspect_ln_unascribe t with | Tv_Abs b body -> collect_abs_order' (b::bds) tt body | _ -> ()
{ "file_name": "ulib/FStar.Reflection.V2.Derived.Lemmas.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 13, "end_line": 78, "start_col": 0, "start_line": 71 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Derived.Lemmas open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Builtins open FStar.Stubs.Reflection.V2.Data open FStar.Reflection.V2.Derived open FStar.List.Tot let rec forall_list (p:'a -> Type) (l:list 'a) : Type = match l with | [] -> True | x::xs -> p x /\ forall_list p xs let forallP (p: 'a -> Type) (l: list 'a): Type = forall (x: 'a). memP x l ==> p x // Precedence relation on the element of a list unfold let (<<:) (l: list 'a) (r: 'r) = forallP (fun x -> x << r) l // A glorified `id` val list_ref : (#a:Type) -> (#p:(a -> Type)) -> (l:list a) -> Pure (list (x:a{p x})) (requires (forallP p l)) (ensures (fun _ -> True)) let rec list_ref #a #p l = match l with | [] -> [] | x::xs -> x :: list_ref #a #p xs val collect_app_order' : (args:list argv) -> (tt:term) -> (t:term) -> Lemma (requires args <<: tt /\ t << tt) (ensures (let fn, args' = collect_app_ln' args t in args' <<: tt /\ fn << tt)) (decreases t) let rec collect_app_order' args tt t = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_order' (r::args) tt l | _ -> () val collect_app_order : (t:term) -> Lemma (ensures (forall (f:term). forall (s:list argv). (f,s) == collect_app_ln t ==> (f << t /\ s <<: t) \/ (f == t /\ s == []))) let collect_app_order t = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_order' [r] t l | _ -> () val collect_app_ref : (t:term) -> (h:term{h == t \/ h << t}) * list (a:argv{fst a << t}) let collect_app_ref t = let h, a = collect_app_ln t in collect_app_order t; h, list_ref a
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.V2.Derived.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Derived.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
bds: FStar.Stubs.Reflection.Types.binders -> tt: FStar.Stubs.Reflection.Types.term -> t: FStar.Stubs.Reflection.Types.term -> FStar.Pervasives.Lemma (requires t << tt /\ bds <<: tt) (ensures (let _ = FStar.Reflection.V2.Derived.collect_abs' bds t in (let FStar.Pervasives.Native.Mktuple2 #_ #_ bds' body = _ in bds' <<: tt /\ body << tt) <: Type0)) (decreases t)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "FStar.Stubs.Reflection.Types.binders", "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.V2.Derived.inspect_ln_unascribe", "FStar.Stubs.Reflection.Types.binder", "FStar.Reflection.V2.Derived.Lemmas.collect_abs_order'", "Prims.Cons", "FStar.Stubs.Reflection.V2.Data.term_view", "Prims.unit", "Prims.l_and", "Prims.precedes", "FStar.Reflection.V2.Derived.Lemmas.op_Less_Less_Colon", "Prims.squash", "Prims.list", "FStar.Pervasives.Native.tuple2", "FStar.Reflection.V2.Derived.collect_abs'", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec collect_abs_order' (bds: binders) (tt t: term) : Lemma (requires t << tt /\ bds <<: tt) (ensures (let bds', body = collect_abs' bds t in (bds' <<: tt /\ body << tt))) (decreases t) =
match inspect_ln_unascribe t with | Tv_Abs b body -> collect_abs_order' (b :: bds) tt body | _ -> ()
false
FStar.Reflection.V2.Derived.Lemmas.fst
FStar.Reflection.V2.Derived.Lemmas.collect_arr_order'
val collect_arr_order' (bds: binders) (tt: term) (c: comp) : Lemma (requires c << tt /\ bds <<: tt) (ensures (let bds', c' = collect_arr' bds c in bds' <<: tt /\ c' << tt)) (decreases c)
val collect_arr_order' (bds: binders) (tt: term) (c: comp) : Lemma (requires c << tt /\ bds <<: tt) (ensures (let bds', c' = collect_arr' bds c in bds' <<: tt /\ c' << tt)) (decreases c)
let rec collect_arr_order' (bds: binders) (tt: term) (c: comp) : Lemma (requires c << tt /\ bds <<: tt) (ensures (let bds', c' = collect_arr' bds c in bds' <<: tt /\ c' << tt)) (decreases c) = match inspect_comp c with | C_Total ret -> ( match inspect_ln_unascribe ret with | Tv_Arrow b c -> collect_arr_order' (b::bds) tt c | _ -> ()) | _ -> ()
{ "file_name": "ulib/FStar.Reflection.V2.Derived.Lemmas.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 13, "end_line": 112, "start_col": 0, "start_line": 102 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Derived.Lemmas open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Builtins open FStar.Stubs.Reflection.V2.Data open FStar.Reflection.V2.Derived open FStar.List.Tot let rec forall_list (p:'a -> Type) (l:list 'a) : Type = match l with | [] -> True | x::xs -> p x /\ forall_list p xs let forallP (p: 'a -> Type) (l: list 'a): Type = forall (x: 'a). memP x l ==> p x // Precedence relation on the element of a list unfold let (<<:) (l: list 'a) (r: 'r) = forallP (fun x -> x << r) l // A glorified `id` val list_ref : (#a:Type) -> (#p:(a -> Type)) -> (l:list a) -> Pure (list (x:a{p x})) (requires (forallP p l)) (ensures (fun _ -> True)) let rec list_ref #a #p l = match l with | [] -> [] | x::xs -> x :: list_ref #a #p xs val collect_app_order' : (args:list argv) -> (tt:term) -> (t:term) -> Lemma (requires args <<: tt /\ t << tt) (ensures (let fn, args' = collect_app_ln' args t in args' <<: tt /\ fn << tt)) (decreases t) let rec collect_app_order' args tt t = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_order' (r::args) tt l | _ -> () val collect_app_order : (t:term) -> Lemma (ensures (forall (f:term). forall (s:list argv). (f,s) == collect_app_ln t ==> (f << t /\ s <<: t) \/ (f == t /\ s == []))) let collect_app_order t = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_order' [r] t l | _ -> () val collect_app_ref : (t:term) -> (h:term{h == t \/ h << t}) * list (a:argv{fst a << t}) let collect_app_ref t = let h, a = collect_app_ln t in collect_app_order t; h, list_ref a (**** [collect_abs_ln t] is smaller than [t] *) let rec collect_abs_order' (bds: binders) (tt t: term) : Lemma (requires t << tt /\ bds <<: tt) (ensures (let bds', body = collect_abs' bds t in (bds' <<: tt /\ body << tt))) (decreases t) = match inspect_ln_unascribe t with | Tv_Abs b body -> collect_abs_order' (b::bds) tt body | _ -> () val collect_abs_ln_order : (t:term) -> Lemma (ensures forall bds body. (bds, body) == collect_abs_ln t ==> (body << t /\ bds <<: t) \/ (body == t /\ bds == []) ) let collect_abs_ln_order t = match inspect_ln_unascribe t with | Tv_Abs b body -> collect_abs_order' [b] t body; let bds, body = collect_abs' [] t in Classical.forall_intro (rev_memP bds) | _ -> () val collect_abs_ln_ref : (t:term) -> list (bd:binder{bd << t}) * (body:term{body == t \/ body << t}) let collect_abs_ln_ref t = let bds, body = collect_abs_ln t in collect_abs_ln_order t; list_ref bds, body
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.V2.Derived.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Derived.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
bds: FStar.Stubs.Reflection.Types.binders -> tt: FStar.Stubs.Reflection.Types.term -> c: FStar.Stubs.Reflection.Types.comp -> FStar.Pervasives.Lemma (requires c << tt /\ bds <<: tt) (ensures (let _ = FStar.Reflection.V2.Derived.collect_arr' bds c in (let FStar.Pervasives.Native.Mktuple2 #_ #_ bds' c' = _ in bds' <<: tt /\ c' << tt) <: Type0)) (decreases c)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "FStar.Stubs.Reflection.Types.binders", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.Types.comp", "FStar.Stubs.Reflection.V2.Builtins.inspect_comp", "FStar.Stubs.Reflection.Types.typ", "FStar.Reflection.V2.Derived.inspect_ln_unascribe", "FStar.Stubs.Reflection.Types.binder", "FStar.Reflection.V2.Derived.Lemmas.collect_arr_order'", "Prims.Cons", "FStar.Stubs.Reflection.V2.Data.term_view", "Prims.unit", "FStar.Stubs.Reflection.V2.Data.comp_view", "Prims.l_and", "Prims.precedes", "FStar.Reflection.V2.Derived.Lemmas.op_Less_Less_Colon", "Prims.squash", "Prims.list", "FStar.Pervasives.Native.tuple2", "FStar.Reflection.V2.Derived.collect_arr'", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec collect_arr_order' (bds: binders) (tt: term) (c: comp) : Lemma (requires c << tt /\ bds <<: tt) (ensures (let bds', c' = collect_arr' bds c in bds' <<: tt /\ c' << tt)) (decreases c) =
match inspect_comp c with | C_Total ret -> (match inspect_ln_unascribe ret with | Tv_Arrow b c -> collect_arr_order' (b :: bds) tt c | _ -> ()) | _ -> ()
false
FStar.Reflection.V2.Derived.Lemmas.fst
FStar.Reflection.V2.Derived.Lemmas.collect_arr_ln_bs_order
val collect_arr_ln_bs_order : (t:term) -> Lemma (ensures forall bds c. (bds, c) == collect_arr_ln_bs t ==> (c << t /\ bds <<: t) \/ (c == pack_comp (C_Total t) /\ bds == []) )
val collect_arr_ln_bs_order : (t:term) -> Lemma (ensures forall bds c. (bds, c) == collect_arr_ln_bs t ==> (c << t /\ bds <<: t) \/ (c == pack_comp (C_Total t) /\ bds == []) )
let collect_arr_ln_bs_order t = match inspect_ln_unascribe t with | Tv_Arrow b c -> collect_arr_order' [b] t c; Classical.forall_intro_2 (rev_memP #binder); inspect_pack_comp_inv (C_Total t) | _ -> inspect_pack_comp_inv (C_Total t)
{ "file_name": "ulib/FStar.Reflection.V2.Derived.Lemmas.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 42, "end_line": 125, "start_col": 0, "start_line": 120 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Derived.Lemmas open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Builtins open FStar.Stubs.Reflection.V2.Data open FStar.Reflection.V2.Derived open FStar.List.Tot let rec forall_list (p:'a -> Type) (l:list 'a) : Type = match l with | [] -> True | x::xs -> p x /\ forall_list p xs let forallP (p: 'a -> Type) (l: list 'a): Type = forall (x: 'a). memP x l ==> p x // Precedence relation on the element of a list unfold let (<<:) (l: list 'a) (r: 'r) = forallP (fun x -> x << r) l // A glorified `id` val list_ref : (#a:Type) -> (#p:(a -> Type)) -> (l:list a) -> Pure (list (x:a{p x})) (requires (forallP p l)) (ensures (fun _ -> True)) let rec list_ref #a #p l = match l with | [] -> [] | x::xs -> x :: list_ref #a #p xs val collect_app_order' : (args:list argv) -> (tt:term) -> (t:term) -> Lemma (requires args <<: tt /\ t << tt) (ensures (let fn, args' = collect_app_ln' args t in args' <<: tt /\ fn << tt)) (decreases t) let rec collect_app_order' args tt t = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_order' (r::args) tt l | _ -> () val collect_app_order : (t:term) -> Lemma (ensures (forall (f:term). forall (s:list argv). (f,s) == collect_app_ln t ==> (f << t /\ s <<: t) \/ (f == t /\ s == []))) let collect_app_order t = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_order' [r] t l | _ -> () val collect_app_ref : (t:term) -> (h:term{h == t \/ h << t}) * list (a:argv{fst a << t}) let collect_app_ref t = let h, a = collect_app_ln t in collect_app_order t; h, list_ref a (**** [collect_abs_ln t] is smaller than [t] *) let rec collect_abs_order' (bds: binders) (tt t: term) : Lemma (requires t << tt /\ bds <<: tt) (ensures (let bds', body = collect_abs' bds t in (bds' <<: tt /\ body << tt))) (decreases t) = match inspect_ln_unascribe t with | Tv_Abs b body -> collect_abs_order' (b::bds) tt body | _ -> () val collect_abs_ln_order : (t:term) -> Lemma (ensures forall bds body. (bds, body) == collect_abs_ln t ==> (body << t /\ bds <<: t) \/ (body == t /\ bds == []) ) let collect_abs_ln_order t = match inspect_ln_unascribe t with | Tv_Abs b body -> collect_abs_order' [b] t body; let bds, body = collect_abs' [] t in Classical.forall_intro (rev_memP bds) | _ -> () val collect_abs_ln_ref : (t:term) -> list (bd:binder{bd << t}) * (body:term{body == t \/ body << t}) let collect_abs_ln_ref t = let bds, body = collect_abs_ln t in collect_abs_ln_order t; list_ref bds, body (**** [collect_arr_ln_bs t] is smaller than [t] *) let rec collect_arr_order' (bds: binders) (tt: term) (c: comp) : Lemma (requires c << tt /\ bds <<: tt) (ensures (let bds', c' = collect_arr' bds c in bds' <<: tt /\ c' << tt)) (decreases c) = match inspect_comp c with | C_Total ret -> ( match inspect_ln_unascribe ret with | Tv_Arrow b c -> collect_arr_order' (b::bds) tt c | _ -> ()) | _ -> () val collect_arr_ln_bs_order : (t:term) -> Lemma (ensures forall bds c. (bds, c) == collect_arr_ln_bs t ==> (c << t /\ bds <<: t) \/ (c == pack_comp (C_Total t) /\ bds == [])
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.V2.Derived.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Derived.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: FStar.Stubs.Reflection.Types.term -> FStar.Pervasives.Lemma (ensures forall (bds: Prims.list FStar.Stubs.Reflection.Types.binder) (c: FStar.Stubs.Reflection.Types.comp). (bds, c) == FStar.Reflection.V2.Derived.collect_arr_ln_bs t ==> c << t /\ bds <<: t \/ c == FStar.Stubs.Reflection.V2.Builtins.pack_comp (FStar.Stubs.Reflection.V2.Data.C_Total t) /\ bds == [])
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.V2.Derived.inspect_ln_unascribe", "FStar.Stubs.Reflection.Types.binder", "FStar.Stubs.Reflection.Types.comp", "FStar.Stubs.Reflection.V2.Builtins.inspect_pack_comp_inv", "FStar.Stubs.Reflection.V2.Data.C_Total", "Prims.unit", "FStar.Classical.forall_intro_2", "Prims.list", "Prims.l_iff", "FStar.List.Tot.Base.memP", "FStar.List.Tot.Base.rev", "FStar.List.Tot.Properties.rev_memP", "FStar.Reflection.V2.Derived.Lemmas.collect_arr_order'", "Prims.Cons", "Prims.Nil", "FStar.Stubs.Reflection.V2.Data.term_view" ]
[]
false
false
true
false
false
let collect_arr_ln_bs_order t =
match inspect_ln_unascribe t with | Tv_Arrow b c -> collect_arr_order' [b] t c; Classical.forall_intro_2 (rev_memP #binder); inspect_pack_comp_inv (C_Total t) | _ -> inspect_pack_comp_inv (C_Total t)
false
FStar.Reflection.V2.Derived.Lemmas.fst
FStar.Reflection.V2.Derived.Lemmas.collect_abs_ln_order
val collect_abs_ln_order : (t:term) -> Lemma (ensures forall bds body. (bds, body) == collect_abs_ln t ==> (body << t /\ bds <<: t) \/ (body == t /\ bds == []) )
val collect_abs_ln_order : (t:term) -> Lemma (ensures forall bds body. (bds, body) == collect_abs_ln t ==> (body << t /\ bds <<: t) \/ (body == t /\ bds == []) )
let collect_abs_ln_order t = match inspect_ln_unascribe t with | Tv_Abs b body -> collect_abs_order' [b] t body; let bds, body = collect_abs' [] t in Classical.forall_intro (rev_memP bds) | _ -> ()
{ "file_name": "ulib/FStar.Reflection.V2.Derived.Lemmas.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 13, "end_line": 91, "start_col": 0, "start_line": 86 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Derived.Lemmas open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Builtins open FStar.Stubs.Reflection.V2.Data open FStar.Reflection.V2.Derived open FStar.List.Tot let rec forall_list (p:'a -> Type) (l:list 'a) : Type = match l with | [] -> True | x::xs -> p x /\ forall_list p xs let forallP (p: 'a -> Type) (l: list 'a): Type = forall (x: 'a). memP x l ==> p x // Precedence relation on the element of a list unfold let (<<:) (l: list 'a) (r: 'r) = forallP (fun x -> x << r) l // A glorified `id` val list_ref : (#a:Type) -> (#p:(a -> Type)) -> (l:list a) -> Pure (list (x:a{p x})) (requires (forallP p l)) (ensures (fun _ -> True)) let rec list_ref #a #p l = match l with | [] -> [] | x::xs -> x :: list_ref #a #p xs val collect_app_order' : (args:list argv) -> (tt:term) -> (t:term) -> Lemma (requires args <<: tt /\ t << tt) (ensures (let fn, args' = collect_app_ln' args t in args' <<: tt /\ fn << tt)) (decreases t) let rec collect_app_order' args tt t = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_order' (r::args) tt l | _ -> () val collect_app_order : (t:term) -> Lemma (ensures (forall (f:term). forall (s:list argv). (f,s) == collect_app_ln t ==> (f << t /\ s <<: t) \/ (f == t /\ s == []))) let collect_app_order t = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_order' [r] t l | _ -> () val collect_app_ref : (t:term) -> (h:term{h == t \/ h << t}) * list (a:argv{fst a << t}) let collect_app_ref t = let h, a = collect_app_ln t in collect_app_order t; h, list_ref a (**** [collect_abs_ln t] is smaller than [t] *) let rec collect_abs_order' (bds: binders) (tt t: term) : Lemma (requires t << tt /\ bds <<: tt) (ensures (let bds', body = collect_abs' bds t in (bds' <<: tt /\ body << tt))) (decreases t) = match inspect_ln_unascribe t with | Tv_Abs b body -> collect_abs_order' (b::bds) tt body | _ -> () val collect_abs_ln_order : (t:term) -> Lemma (ensures forall bds body. (bds, body) == collect_abs_ln t ==> (body << t /\ bds <<: t) \/ (body == t /\ bds == [])
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.V2.Derived.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Derived.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: FStar.Stubs.Reflection.Types.term -> FStar.Pervasives.Lemma (ensures forall (bds: Prims.list FStar.Stubs.Reflection.Types.binder) (body: FStar.Stubs.Reflection.Types.term). (bds, body) == FStar.Reflection.V2.Derived.collect_abs_ln t ==> body << t /\ bds <<: t \/ body == t /\ bds == [])
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.V2.Derived.inspect_ln_unascribe", "FStar.Stubs.Reflection.Types.binder", "Prims.list", "FStar.Classical.forall_intro", "Prims.l_iff", "FStar.List.Tot.Base.memP", "FStar.List.Tot.Base.rev", "FStar.List.Tot.Properties.rev_memP", "Prims.unit", "FStar.Pervasives.Native.tuple2", "FStar.Reflection.V2.Derived.collect_abs'", "Prims.Nil", "FStar.Reflection.V2.Derived.Lemmas.collect_abs_order'", "Prims.Cons", "FStar.Stubs.Reflection.V2.Data.term_view" ]
[]
false
false
true
false
false
let collect_abs_ln_order t =
match inspect_ln_unascribe t with | Tv_Abs b body -> collect_abs_order' [b] t body; let bds, body = collect_abs' [] t in Classical.forall_intro (rev_memP bds) | _ -> ()
false
FStar.Reflection.V2.Derived.Lemmas.fst
FStar.Reflection.V2.Derived.Lemmas.collect_arr_ln_bs_ref
val collect_arr_ln_bs_ref : (t:term) -> list (bd:binder{bd << t}) * (c:comp{ c == pack_comp (C_Total t) \/ c << t})
val collect_arr_ln_bs_ref : (t:term) -> list (bd:binder{bd << t}) * (c:comp{ c == pack_comp (C_Total t) \/ c << t})
let collect_arr_ln_bs_ref t = let bds, c = collect_arr_ln_bs t in collect_arr_ln_bs_order t; list_ref bds, c
{ "file_name": "ulib/FStar.Reflection.V2.Derived.Lemmas.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 19, "end_line": 132, "start_col": 0, "start_line": 129 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Derived.Lemmas open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Builtins open FStar.Stubs.Reflection.V2.Data open FStar.Reflection.V2.Derived open FStar.List.Tot let rec forall_list (p:'a -> Type) (l:list 'a) : Type = match l with | [] -> True | x::xs -> p x /\ forall_list p xs let forallP (p: 'a -> Type) (l: list 'a): Type = forall (x: 'a). memP x l ==> p x // Precedence relation on the element of a list unfold let (<<:) (l: list 'a) (r: 'r) = forallP (fun x -> x << r) l // A glorified `id` val list_ref : (#a:Type) -> (#p:(a -> Type)) -> (l:list a) -> Pure (list (x:a{p x})) (requires (forallP p l)) (ensures (fun _ -> True)) let rec list_ref #a #p l = match l with | [] -> [] | x::xs -> x :: list_ref #a #p xs val collect_app_order' : (args:list argv) -> (tt:term) -> (t:term) -> Lemma (requires args <<: tt /\ t << tt) (ensures (let fn, args' = collect_app_ln' args t in args' <<: tt /\ fn << tt)) (decreases t) let rec collect_app_order' args tt t = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_order' (r::args) tt l | _ -> () val collect_app_order : (t:term) -> Lemma (ensures (forall (f:term). forall (s:list argv). (f,s) == collect_app_ln t ==> (f << t /\ s <<: t) \/ (f == t /\ s == []))) let collect_app_order t = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_order' [r] t l | _ -> () val collect_app_ref : (t:term) -> (h:term{h == t \/ h << t}) * list (a:argv{fst a << t}) let collect_app_ref t = let h, a = collect_app_ln t in collect_app_order t; h, list_ref a (**** [collect_abs_ln t] is smaller than [t] *) let rec collect_abs_order' (bds: binders) (tt t: term) : Lemma (requires t << tt /\ bds <<: tt) (ensures (let bds', body = collect_abs' bds t in (bds' <<: tt /\ body << tt))) (decreases t) = match inspect_ln_unascribe t with | Tv_Abs b body -> collect_abs_order' (b::bds) tt body | _ -> () val collect_abs_ln_order : (t:term) -> Lemma (ensures forall bds body. (bds, body) == collect_abs_ln t ==> (body << t /\ bds <<: t) \/ (body == t /\ bds == []) ) let collect_abs_ln_order t = match inspect_ln_unascribe t with | Tv_Abs b body -> collect_abs_order' [b] t body; let bds, body = collect_abs' [] t in Classical.forall_intro (rev_memP bds) | _ -> () val collect_abs_ln_ref : (t:term) -> list (bd:binder{bd << t}) * (body:term{body == t \/ body << t}) let collect_abs_ln_ref t = let bds, body = collect_abs_ln t in collect_abs_ln_order t; list_ref bds, body (**** [collect_arr_ln_bs t] is smaller than [t] *) let rec collect_arr_order' (bds: binders) (tt: term) (c: comp) : Lemma (requires c << tt /\ bds <<: tt) (ensures (let bds', c' = collect_arr' bds c in bds' <<: tt /\ c' << tt)) (decreases c) = match inspect_comp c with | C_Total ret -> ( match inspect_ln_unascribe ret with | Tv_Arrow b c -> collect_arr_order' (b::bds) tt c | _ -> ()) | _ -> () val collect_arr_ln_bs_order : (t:term) -> Lemma (ensures forall bds c. (bds, c) == collect_arr_ln_bs t ==> (c << t /\ bds <<: t) \/ (c == pack_comp (C_Total t) /\ bds == []) ) let collect_arr_ln_bs_order t = match inspect_ln_unascribe t with | Tv_Arrow b c -> collect_arr_order' [b] t c; Classical.forall_intro_2 (rev_memP #binder); inspect_pack_comp_inv (C_Total t) | _ -> inspect_pack_comp_inv (C_Total t) val collect_arr_ln_bs_ref : (t:term) -> list (bd:binder{bd << t})
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.V2.Derived.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Derived.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: FStar.Stubs.Reflection.Types.term -> Prims.list (bd: FStar.Stubs.Reflection.Types.binder{bd << t}) * c: FStar.Stubs.Reflection.Types.comp { c == FStar.Stubs.Reflection.V2.Builtins.pack_comp (FStar.Stubs.Reflection.V2.Data.C_Total t) \/ c << t }
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "Prims.list", "FStar.Stubs.Reflection.Types.binder", "FStar.Stubs.Reflection.Types.comp", "FStar.Pervasives.Native.Mktuple2", "Prims.precedes", "Prims.l_or", "Prims.eq2", "FStar.Stubs.Reflection.V2.Builtins.pack_comp", "FStar.Stubs.Reflection.V2.Data.C_Total", "FStar.Reflection.V2.Derived.Lemmas.list_ref", "Prims.unit", "FStar.Reflection.V2.Derived.Lemmas.collect_arr_ln_bs_order", "FStar.Pervasives.Native.tuple2", "FStar.Reflection.V2.Derived.collect_arr_ln_bs" ]
[]
false
false
false
false
false
let collect_arr_ln_bs_ref t =
let bds, c = collect_arr_ln_bs t in collect_arr_ln_bs_order t; list_ref bds, c
false
FStar.Reflection.V2.Derived.Lemmas.fst
FStar.Reflection.V2.Derived.Lemmas.collect_abs_ln_ref
val collect_abs_ln_ref : (t:term) -> list (bd:binder{bd << t}) * (body:term{body == t \/ body << t})
val collect_abs_ln_ref : (t:term) -> list (bd:binder{bd << t}) * (body:term{body == t \/ body << t})
let collect_abs_ln_ref t = let bds, body = collect_abs_ln t in collect_abs_ln_order t; list_ref bds, body
{ "file_name": "ulib/FStar.Reflection.V2.Derived.Lemmas.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 22, "end_line": 97, "start_col": 0, "start_line": 94 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Reflection.V2.Derived.Lemmas open FStar.Stubs.Reflection.Types open FStar.Stubs.Reflection.V2.Builtins open FStar.Stubs.Reflection.V2.Data open FStar.Reflection.V2.Derived open FStar.List.Tot let rec forall_list (p:'a -> Type) (l:list 'a) : Type = match l with | [] -> True | x::xs -> p x /\ forall_list p xs let forallP (p: 'a -> Type) (l: list 'a): Type = forall (x: 'a). memP x l ==> p x // Precedence relation on the element of a list unfold let (<<:) (l: list 'a) (r: 'r) = forallP (fun x -> x << r) l // A glorified `id` val list_ref : (#a:Type) -> (#p:(a -> Type)) -> (l:list a) -> Pure (list (x:a{p x})) (requires (forallP p l)) (ensures (fun _ -> True)) let rec list_ref #a #p l = match l with | [] -> [] | x::xs -> x :: list_ref #a #p xs val collect_app_order' : (args:list argv) -> (tt:term) -> (t:term) -> Lemma (requires args <<: tt /\ t << tt) (ensures (let fn, args' = collect_app_ln' args t in args' <<: tt /\ fn << tt)) (decreases t) let rec collect_app_order' args tt t = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_order' (r::args) tt l | _ -> () val collect_app_order : (t:term) -> Lemma (ensures (forall (f:term). forall (s:list argv). (f,s) == collect_app_ln t ==> (f << t /\ s <<: t) \/ (f == t /\ s == []))) let collect_app_order t = match inspect_ln_unascribe t with | Tv_App l r -> collect_app_order' [r] t l | _ -> () val collect_app_ref : (t:term) -> (h:term{h == t \/ h << t}) * list (a:argv{fst a << t}) let collect_app_ref t = let h, a = collect_app_ln t in collect_app_order t; h, list_ref a (**** [collect_abs_ln t] is smaller than [t] *) let rec collect_abs_order' (bds: binders) (tt t: term) : Lemma (requires t << tt /\ bds <<: tt) (ensures (let bds', body = collect_abs' bds t in (bds' <<: tt /\ body << tt))) (decreases t) = match inspect_ln_unascribe t with | Tv_Abs b body -> collect_abs_order' (b::bds) tt body | _ -> () val collect_abs_ln_order : (t:term) -> Lemma (ensures forall bds body. (bds, body) == collect_abs_ln t ==> (body << t /\ bds <<: t) \/ (body == t /\ bds == []) ) let collect_abs_ln_order t = match inspect_ln_unascribe t with | Tv_Abs b body -> collect_abs_order' [b] t body; let bds, body = collect_abs' [] t in Classical.forall_intro (rev_memP bds) | _ -> ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Stubs.Reflection.V2.Data.fsti.checked", "FStar.Stubs.Reflection.V2.Builtins.fsti.checked", "FStar.Stubs.Reflection.Types.fsti.checked", "FStar.Reflection.V2.Derived.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Reflection.V2.Derived.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Data", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.V2.Builtins", "short_module": null }, { "abbrev": false, "full_module": "FStar.Stubs.Reflection.Types", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Reflection.V2.Derived", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: FStar.Stubs.Reflection.Types.term -> Prims.list (bd: FStar.Stubs.Reflection.Types.binder{bd << t}) * body: FStar.Stubs.Reflection.Types.term{body == t \/ body << t}
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "Prims.list", "FStar.Stubs.Reflection.Types.binder", "FStar.Pervasives.Native.Mktuple2", "Prims.precedes", "Prims.l_or", "Prims.eq2", "FStar.Reflection.V2.Derived.Lemmas.list_ref", "Prims.unit", "FStar.Reflection.V2.Derived.Lemmas.collect_abs_ln_order", "FStar.Pervasives.Native.tuple2", "FStar.Reflection.V2.Derived.collect_abs_ln" ]
[]
false
false
false
false
false
let collect_abs_ln_ref t =
let bds, body = collect_abs_ln t in collect_abs_ln_order t; list_ref bds, body
false
Vale.Curve25519.X64.FastUtil.fst
Vale.Curve25519.X64.FastUtil.va_lemma_Cswap2_stdcall
val va_lemma_Cswap2_stdcall : va_b0:va_code -> va_s0:va_state -> win:bool -> bit_in:nat64 -> p0_b:buffer64 -> p1_b:buffer64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Cswap2_stdcall win) va_s0 /\ va_get_ok va_s0 /\ (let (p0_in:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let (p1_in:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else va_get_reg64 rRdx va_s0) in let (old_p0_0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 0 (va_get_mem va_s0) in let (old_p0_1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 1 (va_get_mem va_s0) in let (old_p0_2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 2 (va_get_mem va_s0) in let (old_p0_3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 3 (va_get_mem va_s0) in let (old_p0_4:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 4 (va_get_mem va_s0) in let (old_p0_5:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 5 (va_get_mem va_s0) in let (old_p0_6:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 6 (va_get_mem va_s0) in let (old_p0_7:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 7 (va_get_mem va_s0) in let (old_p1_0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 0 (va_get_mem va_s0) in let (old_p1_1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 1 (va_get_mem va_s0) in let (old_p1_2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 2 (va_get_mem va_s0) in let (old_p1_3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 3 (va_get_mem va_s0) in let (old_p1_4:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 4 (va_get_mem va_s0) in let (old_p1_5:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 5 (va_get_mem va_s0) in let (old_p1_6:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 6 (va_get_mem va_s0) in let (old_p1_7:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 7 (va_get_mem va_s0) in va_get_reg64 rRsp va_s0 == Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\ Vale.X64.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ bit_in <= 1 /\ bit_in = (if win then va_get_reg64 rRcx va_s0 else va_get_reg64 rRdi va_s0) /\ (Vale.X64.Decls.buffers_disjoint p0_b p1_b \/ p1_b == p0_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem va_s0) p0_in p0_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem va_s0) p1_in p1_b 8 (va_get_mem_layout va_s0) Secret))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (p0_in:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let (p1_in:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else va_get_reg64 rRdx va_s0) in let (old_p0_0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 0 (va_get_mem va_s0) in let (old_p0_1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 1 (va_get_mem va_s0) in let (old_p0_2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 2 (va_get_mem va_s0) in let (old_p0_3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 3 (va_get_mem va_s0) in let (old_p0_4:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 4 (va_get_mem va_s0) in let (old_p0_5:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 5 (va_get_mem va_s0) in let (old_p0_6:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 6 (va_get_mem va_s0) in let (old_p0_7:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 7 (va_get_mem va_s0) in let (old_p1_0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 0 (va_get_mem va_s0) in let (old_p1_1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 1 (va_get_mem va_s0) in let (old_p1_2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 2 (va_get_mem va_s0) in let (old_p1_3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 3 (va_get_mem va_s0) in let (old_p1_4:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 4 (va_get_mem va_s0) in let (old_p1_5:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 5 (va_get_mem va_s0) in let (old_p1_6:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 6 (va_get_mem va_s0) in let (old_p1_7:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 7 (va_get_mem va_s0) in let p0_0 = Vale.X64.Decls.buffer64_read p0_b 0 (va_get_mem va_sM) in let p0_1 = Vale.X64.Decls.buffer64_read p0_b 1 (va_get_mem va_sM) in let p0_2 = Vale.X64.Decls.buffer64_read p0_b 2 (va_get_mem va_sM) in let p0_3 = Vale.X64.Decls.buffer64_read p0_b 3 (va_get_mem va_sM) in let p0_4 = Vale.X64.Decls.buffer64_read p0_b 4 (va_get_mem va_sM) in let p0_5 = Vale.X64.Decls.buffer64_read p0_b 5 (va_get_mem va_sM) in let p0_6 = Vale.X64.Decls.buffer64_read p0_b 6 (va_get_mem va_sM) in let p0_7 = Vale.X64.Decls.buffer64_read p0_b 7 (va_get_mem va_sM) in let p1_0 = Vale.X64.Decls.buffer64_read p1_b 0 (va_get_mem va_sM) in let p1_1 = Vale.X64.Decls.buffer64_read p1_b 1 (va_get_mem va_sM) in let p1_2 = Vale.X64.Decls.buffer64_read p1_b 2 (va_get_mem va_sM) in let p1_3 = Vale.X64.Decls.buffer64_read p1_b 3 (va_get_mem va_sM) in let p1_4 = Vale.X64.Decls.buffer64_read p1_b 4 (va_get_mem va_sM) in let p1_5 = Vale.X64.Decls.buffer64_read p1_b 5 (va_get_mem va_sM) in let p1_6 = Vale.X64.Decls.buffer64_read p1_b 6 (va_get_mem va_sM) in let p1_7 = Vale.X64.Decls.buffer64_read p1_b 7 (va_get_mem va_sM) in p0_0 == (if (bit_in = 1) then old_p1_0 else old_p0_0) /\ p0_1 == (if (bit_in = 1) then old_p1_1 else old_p0_1) /\ p0_2 == (if (bit_in = 1) then old_p1_2 else old_p0_2) /\ p0_3 == (if (bit_in = 1) then old_p1_3 else old_p0_3) /\ p0_4 == (if (bit_in = 1) then old_p1_4 else old_p0_4) /\ p0_5 == (if (bit_in = 1) then old_p1_5 else old_p0_5) /\ p0_6 == (if (bit_in = 1) then old_p1_6 else old_p0_6) /\ p0_7 == (if (bit_in = 1) then old_p1_7 else old_p0_7) /\ p1_0 == (if (bit_in = 1) then old_p0_0 else old_p1_0) /\ p1_1 == (if (bit_in = 1) then old_p0_1 else old_p1_1) /\ p1_2 == (if (bit_in = 1) then old_p0_2 else old_p1_2) /\ p1_3 == (if (bit_in = 1) then old_p0_3 else old_p1_3) /\ p1_4 == (if (bit_in = 1) then old_p0_4 else old_p1_4) /\ p1_5 == (if (bit_in = 1) then old_p0_5 else old_p1_5) /\ p1_6 == (if (bit_in = 1) then old_p0_6 else old_p1_6) /\ p1_7 == (if (bit_in = 1) then old_p0_7 else old_p1_7) /\ Vale.X64.Decls.modifies_buffer_2 p0_b p1_b (va_get_mem va_s0) (va_get_mem va_sM) /\ (win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_s0) /\ (win ==> va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0) /\ va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 0 va_sM (va_update_flags va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRsp va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))))
val va_lemma_Cswap2_stdcall : va_b0:va_code -> va_s0:va_state -> win:bool -> bit_in:nat64 -> p0_b:buffer64 -> p1_b:buffer64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Cswap2_stdcall win) va_s0 /\ va_get_ok va_s0 /\ (let (p0_in:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let (p1_in:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else va_get_reg64 rRdx va_s0) in let (old_p0_0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 0 (va_get_mem va_s0) in let (old_p0_1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 1 (va_get_mem va_s0) in let (old_p0_2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 2 (va_get_mem va_s0) in let (old_p0_3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 3 (va_get_mem va_s0) in let (old_p0_4:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 4 (va_get_mem va_s0) in let (old_p0_5:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 5 (va_get_mem va_s0) in let (old_p0_6:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 6 (va_get_mem va_s0) in let (old_p0_7:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 7 (va_get_mem va_s0) in let (old_p1_0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 0 (va_get_mem va_s0) in let (old_p1_1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 1 (va_get_mem va_s0) in let (old_p1_2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 2 (va_get_mem va_s0) in let (old_p1_3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 3 (va_get_mem va_s0) in let (old_p1_4:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 4 (va_get_mem va_s0) in let (old_p1_5:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 5 (va_get_mem va_s0) in let (old_p1_6:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 6 (va_get_mem va_s0) in let (old_p1_7:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 7 (va_get_mem va_s0) in va_get_reg64 rRsp va_s0 == Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\ Vale.X64.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ bit_in <= 1 /\ bit_in = (if win then va_get_reg64 rRcx va_s0 else va_get_reg64 rRdi va_s0) /\ (Vale.X64.Decls.buffers_disjoint p0_b p1_b \/ p1_b == p0_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem va_s0) p0_in p0_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem va_s0) p1_in p1_b 8 (va_get_mem_layout va_s0) Secret))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (p0_in:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let (p1_in:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else va_get_reg64 rRdx va_s0) in let (old_p0_0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 0 (va_get_mem va_s0) in let (old_p0_1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 1 (va_get_mem va_s0) in let (old_p0_2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 2 (va_get_mem va_s0) in let (old_p0_3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 3 (va_get_mem va_s0) in let (old_p0_4:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 4 (va_get_mem va_s0) in let (old_p0_5:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 5 (va_get_mem va_s0) in let (old_p0_6:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 6 (va_get_mem va_s0) in let (old_p0_7:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 7 (va_get_mem va_s0) in let (old_p1_0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 0 (va_get_mem va_s0) in let (old_p1_1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 1 (va_get_mem va_s0) in let (old_p1_2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 2 (va_get_mem va_s0) in let (old_p1_3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 3 (va_get_mem va_s0) in let (old_p1_4:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 4 (va_get_mem va_s0) in let (old_p1_5:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 5 (va_get_mem va_s0) in let (old_p1_6:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 6 (va_get_mem va_s0) in let (old_p1_7:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 7 (va_get_mem va_s0) in let p0_0 = Vale.X64.Decls.buffer64_read p0_b 0 (va_get_mem va_sM) in let p0_1 = Vale.X64.Decls.buffer64_read p0_b 1 (va_get_mem va_sM) in let p0_2 = Vale.X64.Decls.buffer64_read p0_b 2 (va_get_mem va_sM) in let p0_3 = Vale.X64.Decls.buffer64_read p0_b 3 (va_get_mem va_sM) in let p0_4 = Vale.X64.Decls.buffer64_read p0_b 4 (va_get_mem va_sM) in let p0_5 = Vale.X64.Decls.buffer64_read p0_b 5 (va_get_mem va_sM) in let p0_6 = Vale.X64.Decls.buffer64_read p0_b 6 (va_get_mem va_sM) in let p0_7 = Vale.X64.Decls.buffer64_read p0_b 7 (va_get_mem va_sM) in let p1_0 = Vale.X64.Decls.buffer64_read p1_b 0 (va_get_mem va_sM) in let p1_1 = Vale.X64.Decls.buffer64_read p1_b 1 (va_get_mem va_sM) in let p1_2 = Vale.X64.Decls.buffer64_read p1_b 2 (va_get_mem va_sM) in let p1_3 = Vale.X64.Decls.buffer64_read p1_b 3 (va_get_mem va_sM) in let p1_4 = Vale.X64.Decls.buffer64_read p1_b 4 (va_get_mem va_sM) in let p1_5 = Vale.X64.Decls.buffer64_read p1_b 5 (va_get_mem va_sM) in let p1_6 = Vale.X64.Decls.buffer64_read p1_b 6 (va_get_mem va_sM) in let p1_7 = Vale.X64.Decls.buffer64_read p1_b 7 (va_get_mem va_sM) in p0_0 == (if (bit_in = 1) then old_p1_0 else old_p0_0) /\ p0_1 == (if (bit_in = 1) then old_p1_1 else old_p0_1) /\ p0_2 == (if (bit_in = 1) then old_p1_2 else old_p0_2) /\ p0_3 == (if (bit_in = 1) then old_p1_3 else old_p0_3) /\ p0_4 == (if (bit_in = 1) then old_p1_4 else old_p0_4) /\ p0_5 == (if (bit_in = 1) then old_p1_5 else old_p0_5) /\ p0_6 == (if (bit_in = 1) then old_p1_6 else old_p0_6) /\ p0_7 == (if (bit_in = 1) then old_p1_7 else old_p0_7) /\ p1_0 == (if (bit_in = 1) then old_p0_0 else old_p1_0) /\ p1_1 == (if (bit_in = 1) then old_p0_1 else old_p1_1) /\ p1_2 == (if (bit_in = 1) then old_p0_2 else old_p1_2) /\ p1_3 == (if (bit_in = 1) then old_p0_3 else old_p1_3) /\ p1_4 == (if (bit_in = 1) then old_p0_4 else old_p1_4) /\ p1_5 == (if (bit_in = 1) then old_p0_5 else old_p1_5) /\ p1_6 == (if (bit_in = 1) then old_p0_6 else old_p1_6) /\ p1_7 == (if (bit_in = 1) then old_p0_7 else old_p1_7) /\ Vale.X64.Decls.modifies_buffer_2 p0_b p1_b (va_get_mem va_s0) (va_get_mem va_sM) /\ (win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_s0) /\ (win ==> va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0) /\ va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 0 va_sM (va_update_flags va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRsp va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))))
let va_lemma_Cswap2_stdcall va_b0 va_s0 win bit_in p0_b p1_b = let (va_mods:va_mods_t) = [va_Mod_stackTaint; va_Mod_stack; va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRsp; va_Mod_reg64 rRdi; va_Mod_reg64 rRsi; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Cswap2_stdcall va_mods win bit_in p0_b p1_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Cswap2_stdcall win) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 974 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_ok va_sM) /\ (let (p0_in:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (p1_in:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rR8 va_s0) (fun _ -> va_get_reg64 rRdx va_s0) in let (old_p0_0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 0 (va_get_mem va_s0) in let (old_p0_1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 1 (va_get_mem va_s0) in let (old_p0_2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 2 (va_get_mem va_s0) in let (old_p0_3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 3 (va_get_mem va_s0) in let (old_p0_4:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 4 (va_get_mem va_s0) in let (old_p0_5:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 5 (va_get_mem va_s0) in let (old_p0_6:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 6 (va_get_mem va_s0) in let (old_p0_7:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 7 (va_get_mem va_s0) in let (old_p1_0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 0 (va_get_mem va_s0) in let (old_p1_1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 1 (va_get_mem va_s0) in let (old_p1_2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 2 (va_get_mem va_s0) in let (old_p1_3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 3 (va_get_mem va_s0) in let (old_p1_4:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 4 (va_get_mem va_s0) in let (old_p1_5:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 5 (va_get_mem va_s0) in let (old_p1_6:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 6 (va_get_mem va_s0) in let (old_p1_7:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 7 (va_get_mem va_s0) in label va_range1 "***** POSTCONDITION NOT MET AT line 1021 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_0 = Vale.X64.Decls.buffer64_read p0_b 0 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1022 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_1 = Vale.X64.Decls.buffer64_read p0_b 1 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1023 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_2 = Vale.X64.Decls.buffer64_read p0_b 2 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1024 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_3 = Vale.X64.Decls.buffer64_read p0_b 3 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1025 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_4 = Vale.X64.Decls.buffer64_read p0_b 4 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1026 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_5 = Vale.X64.Decls.buffer64_read p0_b 5 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1027 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_6 = Vale.X64.Decls.buffer64_read p0_b 6 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1028 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_7 = Vale.X64.Decls.buffer64_read p0_b 7 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1030 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_0 = Vale.X64.Decls.buffer64_read p1_b 0 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1031 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_1 = Vale.X64.Decls.buffer64_read p1_b 1 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1032 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_2 = Vale.X64.Decls.buffer64_read p1_b 2 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1033 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_3 = Vale.X64.Decls.buffer64_read p1_b 3 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1034 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_4 = Vale.X64.Decls.buffer64_read p1_b 4 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1035 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_5 = Vale.X64.Decls.buffer64_read p1_b 5 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1036 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_6 = Vale.X64.Decls.buffer64_read p1_b 6 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1037 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_7 = Vale.X64.Decls.buffer64_read p1_b 7 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1039 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_0 == va_if (bit_in = 1) (fun _ -> old_p1_0) (fun _ -> old_p0_0)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1040 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_1 == va_if (bit_in = 1) (fun _ -> old_p1_1) (fun _ -> old_p0_1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1041 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_2 == va_if (bit_in = 1) (fun _ -> old_p1_2) (fun _ -> old_p0_2)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1042 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_3 == va_if (bit_in = 1) (fun _ -> old_p1_3) (fun _ -> old_p0_3)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1043 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_4 == va_if (bit_in = 1) (fun _ -> old_p1_4) (fun _ -> old_p0_4)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1044 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_5 == va_if (bit_in = 1) (fun _ -> old_p1_5) (fun _ -> old_p0_5)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1045 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_6 == va_if (bit_in = 1) (fun _ -> old_p1_6) (fun _ -> old_p0_6)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1046 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_7 == va_if (bit_in = 1) (fun _ -> old_p1_7) (fun _ -> old_p0_7)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1048 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_0 == va_if (bit_in = 1) (fun _ -> old_p0_0) (fun _ -> old_p1_0)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1049 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_1 == va_if (bit_in = 1) (fun _ -> old_p0_1) (fun _ -> old_p1_1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1050 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_2 == va_if (bit_in = 1) (fun _ -> old_p0_2) (fun _ -> old_p1_2)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1051 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_3 == va_if (bit_in = 1) (fun _ -> old_p0_3) (fun _ -> old_p1_3)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1052 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_4 == va_if (bit_in = 1) (fun _ -> old_p0_4) (fun _ -> old_p1_4)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1053 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_5 == va_if (bit_in = 1) (fun _ -> old_p0_5) (fun _ -> old_p1_5)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1054 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_6 == va_if (bit_in = 1) (fun _ -> old_p0_6) (fun _ -> old_p1_6)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1055 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_7 == va_if (bit_in = 1) (fun _ -> old_p0_7) (fun _ -> old_p1_7)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1060 column 53 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.modifies_buffer_2 p0_b p1_b (va_get_mem va_s0) (va_get_mem va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1062 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1063 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (win ==> va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1064 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0))))))))))))))))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRsp; va_Mod_reg64 rRdi; va_Mod_reg64 rRsi; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM)
{ "file_name": "obj/Vale.Curve25519.X64.FastUtil.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 16, "end_line": 2182, "start_col": 0, "start_line": 2075 }
module Vale.Curve25519.X64.FastUtil open Vale.Def.Types_s open Vale.Arch.Types open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsStack open Vale.X64.QuickCode open Vale.X64.QuickCodes open FStar.Tactics open Vale.Curve25519.Fast_defs open Vale.Curve25519.Fast_lemmas_external open Vale.Curve25519.FastUtil_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 60" //-- Fast_mul1 #push-options "--z3rlimit 600" val va_code_Fast_mul1 : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Fast_mul1 () = (va_Block (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Mulx64 (va_op_dst_opr64_reg64 rR9) (va_op_dst_opr64_reg64 rR8) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR8)) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Mulx64 (va_op_dst_opr64_reg64 rR11) (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_CCons (va_code_Add64Wrap (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR9)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 8 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Mulx64 (va_op_dst_opr64_reg64 rR13) (va_op_dst_opr64_reg64 rRbx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 Secret)) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR11)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRbx) 16 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Mulx64 (va_op_dst_opr64_reg64 rRax) (va_op_dst_opr64_reg64 rR14) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 Secret)) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rR13)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR14) 24 Secret) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR8)) (va_CNil ()))))))))))))))))))) val va_codegen_success_Fast_mul1 : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Fast_mul1 () = (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Mulx64 (va_op_dst_opr64_reg64 rR9) (va_op_dst_opr64_reg64 rR8) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR8)) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Mulx64 (va_op_dst_opr64_reg64 rR11) (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_pbool_and (va_codegen_success_Add64Wrap (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR9)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 8 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Mulx64 (va_op_dst_opr64_reg64 rR13) (va_op_dst_opr64_reg64 rRbx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 Secret)) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR11)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRbx) 16 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Mulx64 (va_op_dst_opr64_reg64 rRax) (va_op_dst_opr64_reg64 rR14) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 Secret)) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR14) 24 Secret) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR8)) (va_ttrue ())))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Fast_mul1 (va_mods:va_mods_t) (dst_b:buffer64) (inA_b:buffer64) : (va_quickCode unit (va_code_Fast_mul1 ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 91 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Arch.Types.xor_lemmas ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 93 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 inA_b 0 Secret) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 93 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mulx64 (va_op_dst_opr64_reg64 rR9) (va_op_dst_opr64_reg64 rR8) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (fun (va_s:va_state) _ -> let (va_arg48:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in let (va_arg47:Vale.Def.Types_s.nat64) = va_get_reg64 rR8 va_s in let (va_arg46:Vale.Def.Types_s.nat64) = va_get_reg64 rR9 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 93 column 99 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Curve25519.Fast_lemmas_external.lemma_prod_bounds va_arg46 va_arg47 va_arg48 a0) (let (old_r8:nat64) = va_get_reg64 rR8 va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 94 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 0 Secret dst_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 95 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR8)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 96 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 inA_b 1 Secret) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 96 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mulx64 (va_op_dst_opr64_reg64 rR11) (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (fun (va_s:va_state) _ -> let (va_arg45:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in let (va_arg44:Vale.Def.Types_s.nat64) = va_get_reg64 rR10 va_s in let (va_arg43:Vale.Def.Types_s.nat64) = va_get_reg64 rR11 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 96 column 99 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Curve25519.Fast_lemmas_external.lemma_prod_bounds va_arg43 va_arg44 va_arg45 a1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 97 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Add64Wrap (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR9)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 98 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 8 Secret dst_b 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 99 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 inA_b 2 Secret) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 99 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mulx64 (va_op_dst_opr64_reg64 rR13) (va_op_dst_opr64_reg64 rRbx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 Secret)) (fun (va_s:va_state) _ -> let (va_arg42:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in let (va_arg41:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in let (va_arg40:Vale.Def.Types_s.nat64) = va_get_reg64 rR13 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 99 column 99 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Curve25519.Fast_lemmas_external.lemma_prod_bounds va_arg40 va_arg41 va_arg42 a2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 100 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR11)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 101 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRbx) 16 Secret dst_b 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 102 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 inA_b 3 Secret) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 102 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mulx64 (va_op_dst_opr64_reg64 rRax) (va_op_dst_opr64_reg64 rR14) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 Secret)) (fun (va_s:va_state) _ -> let (va_arg39:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in let (va_arg38:Vale.Def.Types_s.nat64) = va_get_reg64 rR14 va_s in let (va_arg37:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 102 column 99 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Curve25519.Fast_lemmas_external.lemma_prod_bounds va_arg37 va_arg38 va_arg39 a3) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 103 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rR13)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 104 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR14) 24 Secret dst_b 3) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 105 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR8)) (fun (va_s:va_state) _ -> let (carry_bit:Vale.Curve25519.Fast_defs.bit) = Vale.Curve25519.Fast_defs.bool_bit (Vale.X64.Decls.cf (va_get_flags va_s)) in va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 108 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (carry_bit == 0) (let (va_arg36:prop) = va_mul_nat a (va_get_reg64 rRdx va_s) == 0 + Vale.Curve25519.Fast_defs.pow2_four (va_mul_nat (va_get_reg64 rRdx va_s) a0) (va_mul_nat (va_get_reg64 rRdx va_s) a1) (va_mul_nat (va_get_reg64 rRdx va_s) a2) (va_mul_nat (va_get_reg64 rRdx va_s) a3) in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 109 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> assert_by_tactic va_arg36 int_canon) (va_QEmpty (()))))))))))))))))))))))))))) val va_lemma_Fast_mul1 : va_b0:va_code -> va_s0:va_state -> dst_b:buffer64 -> inA_b:buffer64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Fast_mul1 ()) va_s0 /\ va_get_ok va_s0 /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in adx_enabled /\ bmi2_enabled /\ (Vale.X64.Decls.buffers_disjoint dst_b inA_b \/ inA_b == dst_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdi va_s0) dst_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) inA_b 4 (va_get_mem_layout va_s0) Secret))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in let d = Vale.Curve25519.Fast_defs.pow2_five d0 d1 d2 d3 (va_get_reg64 rRax va_sM) in d == va_mul_nat a (va_get_reg64 rRdx va_s0) /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM)) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))) [@"opaque_to_smt"] let va_lemma_Fast_mul1 va_b0 va_s0 dst_b inA_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Fast_mul1 va_mods dst_b inA_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Fast_mul1 ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 52 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_ok va_sM) /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in label va_range1 "***** POSTCONDITION NOT MET AT line 81 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 82 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 83 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 84 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 85 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d = Vale.Curve25519.Fast_defs.pow2_five d0 d1 d2 d3 (va_get_reg64 rRax va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 86 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (d == va_mul_nat a (va_get_reg64 rRdx va_s0)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 88 column 69 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 89 column 50 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM))))))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Fast_mul1 (dst_b:buffer64) (inA_b:buffer64) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in adx_enabled /\ bmi2_enabled /\ (Vale.X64.Decls.buffers_disjoint dst_b inA_b \/ inA_b == dst_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdi va_s0) dst_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) inA_b 4 (va_get_mem_layout va_s0) Secret) /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64) (va_x_r11:nat64) (va_x_rbx:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_heap0:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 0 va_x_heap0 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13 (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10 (va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem va_s0)))))))))) in va_get_ok va_sM /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in let d = Vale.Curve25519.Fast_defs.pow2_five d0 d1 d2 d3 (va_get_reg64 rRax va_sM) in d == va_mul_nat a (va_get_reg64 rRdx va_s0) /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM)) ==> va_k va_sM (()))) val va_wpProof_Fast_mul1 : dst_b:buffer64 -> inA_b:buffer64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Fast_mul1 dst_b inA_b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Fast_mul1 ()) ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Fast_mul1 dst_b inA_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_Fast_mul1 (va_code_Fast_mul1 ()) va_s0 dst_b inA_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Fast_mul1 (dst_b:buffer64) (inA_b:buffer64) : (va_quickCode unit (va_code_Fast_mul1 ())) = (va_QProc (va_code_Fast_mul1 ()) ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_Fast_mul1 dst_b inA_b) (va_wpProof_Fast_mul1 dst_b inA_b)) #pop-options //-- //-- Fast_add1 #push-options "--z3rlimit 600" [@ "opaque_to_smt" va_qattr] let va_code_Fast_add1 () = (va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (va_code_Comment "Clear registers to propagate the carry bit" ) (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR8)) (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9)) (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR10)) (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR11)) (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Newline ()) (va_CCons (va_code_Comment "Begin addition chain" ) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Add64Wrap (va_op_dst_opr64_reg64 rRdx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRdx) 0 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rR8) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 8 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rR9) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 16 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 24 Secret) (va_CCons (va_code_Newline ()) (va_CCons (va_code_Comment "Return the carry bit in a register" ) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_CCons (va_code_DestroyHeaplets ()) (va_CNil ()))))))))))))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Fast_add1 () = (va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and (va_codegen_success_Comment "Clear registers to propagate the carry bit" ) (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR8)) (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9)) (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR10)) (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR11)) (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_Newline ()) (va_pbool_and (va_codegen_success_Comment "Begin addition chain" ) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Add64Wrap (va_op_dst_opr64_reg64 rRdx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRdx) 0 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rR8) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 8 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rR9) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 16 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 24 Secret) (va_pbool_and (va_codegen_success_Newline ()) (va_pbool_and (va_codegen_success_Comment "Return the carry bit in a register" ) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_pbool_and (va_codegen_success_DestroyHeaplets ()) (va_ttrue ())))))))))))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Fast_add1 (va_mods:va_mods_t) (dst_b:buffer64) (inA_b:buffer64) (inB:nat64) : (va_quickCode unit (va_code_Fast_add1 ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem va_s) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem va_s) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem va_s) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem va_s) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 224 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_CreateHeaplets ([declare_buffer64 inA_b 0 Secret Immutable; declare_buffer64 dst_b 0 Secret Mutable])) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 228 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Arch.Types.xor_lemmas ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 229 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Comment "Clear registers to propagate the carry bit" ) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 230 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR8)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 231 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 232 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR10)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 233 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR11)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 234 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 236 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Newline ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 237 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Comment "Begin addition chain" ) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 238 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 inA_b 0 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 238 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Add64Wrap (va_op_dst_opr64_reg64 rRdx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 239 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRdx) 0 Secret dst_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 241 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 inA_b 1 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 241 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rR8) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 242 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 8 Secret dst_b 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 244 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 inA_b 2 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 244 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rR9) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 245 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 16 Secret dst_b 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 247 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 inA_b 3 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 247 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 248 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 24 Secret dst_b 3) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 250 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Newline ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 251 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Comment "Return the carry bit in a register" ) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 252 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 254 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_DestroyHeaplets ()) (va_QEmpty (()))))))))))))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Fast_add1 va_b0 va_s0 dst_b inA_b inB = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Fast_add1 va_mods dst_b inA_b inB in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Fast_add1 ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 182 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_ok va_sM) /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in label va_range1 "***** POSTCONDITION NOT MET AT line 215 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 216 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 217 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 218 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 219 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d = Vale.Curve25519.Fast_defs.pow2_five d0 d1 d2 d3 (va_get_reg64 rRax va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 220 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (d == a + va_get_reg64 rRdx va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 222 column 46 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.modifies_buffer dst_b (va_get_mem va_s0) (va_get_mem va_sM))))))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Fast_add1 dst_b inA_b inB va_s0 va_k = let (va_sM, va_f0) = va_lemma_Fast_add1 (va_code_Fast_add1 ()) va_s0 dst_b inA_b inB in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) #pop-options //-- //-- Fast_add1_stdcall #push-options "--z3rlimit 600" [@ "opaque_to_smt" va_qattr] let va_code_Fast_add1_stdcall win = (va_Block (va_CCons (va_code_Push_Secret (va_op_reg_opr64_reg64 rRdi)) (va_CCons (va_code_Push_Secret (va_op_reg_opr64_reg64 rRsi)) (va_CCons (if win then va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRsi) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR8)) (va_CNil ())))) else va_Block (va_CNil ())) (va_CCons (va_code_Fast_add1 ()) (va_CCons (va_code_Pop_Secret (va_op_dst_opr64_reg64 rRsi)) (va_CCons (va_code_Pop_Secret (va_op_dst_opr64_reg64 rRdi)) (va_CNil ())))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Fast_add1_stdcall win = (va_pbool_and (va_codegen_success_Push_Secret (va_op_reg_opr64_reg64 rRdi)) (va_pbool_and (va_codegen_success_Push_Secret (va_op_reg_opr64_reg64 rRsi)) (va_pbool_and (if win then va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRsi) (va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR8)) (va_ttrue ()))) else va_ttrue ()) (va_pbool_and (va_codegen_success_Fast_add1 ()) (va_pbool_and (va_codegen_success_Pop_Secret (va_op_dst_opr64_reg64 rRsi)) (va_pbool_and (va_codegen_success_Pop_Secret (va_op_dst_opr64_reg64 rRdi)) (va_ttrue ()))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Fast_add1_stdcall (va_mods:va_mods_t) (win:bool) (dst_b:buffer64) (inA_b:buffer64) (inB_in:nat64) : (va_quickCode unit (va_code_Fast_add1_stdcall win)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (dst_in:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s) in let (inA_in:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 323 column 16 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Push_Secret (va_op_reg_opr64_reg64 rRdi)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 324 column 16 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Push_Secret (va_op_reg_opr64_reg64 rRsi)) (fun (va_s:va_state) _ -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 327 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 328 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 329 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRsi) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 330 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR8)) (va_QEmpty (())))))) (qblock va_mods (fun (va_s:va_state) -> va_QEmpty (())))) (fun (va_s:va_state) va_g -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 333 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Fast_add1 dst_b inA_b inB_in) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 335 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Pop_Secret (va_op_dst_opr64_reg64 rRsi)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 336 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Pop_Secret (va_op_dst_opr64_reg64 rRdi)) (va_QEmpty (()))))))))) [@"opaque_to_smt"] let va_lemma_Fast_add1_stdcall va_b0 va_s0 win dst_b inA_b inB_in = let (va_mods:va_mods_t) = [va_Mod_stackTaint; va_Mod_stack; va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRsp; va_Mod_reg64 rRbp; va_Mod_reg64 rRdi; va_Mod_reg64 rRsi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Fast_add1_stdcall va_mods win dst_b inA_b inB_in in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Fast_add1_stdcall win) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 257 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_ok va_sM) /\ (let (dst_in:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (inA_in:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in label va_range1 "***** POSTCONDITION NOT MET AT line 284 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let a0 = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem va_s0) in label va_range1 "***** POSTCONDITION NOT MET AT line 285 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let a1 = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem va_s0) in label va_range1 "***** POSTCONDITION NOT MET AT line 286 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let a2 = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem va_s0) in label va_range1 "***** POSTCONDITION NOT MET AT line 287 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let a3 = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem va_s0) in label va_range1 "***** POSTCONDITION NOT MET AT line 289 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 290 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 291 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 292 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 294 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let a = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in label va_range1 "***** POSTCONDITION NOT MET AT line 295 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d = Vale.Curve25519.Fast_defs.pow2_five d0 d1 d2 d3 (va_get_reg64 rRax va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 297 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (d == a + inB_in) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 303 column 46 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.modifies_buffer dst_b (va_get_mem va_s0) (va_get_mem va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 306 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 307 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 308 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 309 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (win ==> va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 310 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (win ==> va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 311 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 312 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 313 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (win ==> va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 314 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (~win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 315 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (~win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 316 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (~win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 317 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (~win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 318 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (~win ==> va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 320 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0))))))))))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRsp; va_Mod_reg64 rRbp; va_Mod_reg64 rRdi; va_Mod_reg64 rRsi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Fast_add1_stdcall win dst_b inA_b inB_in va_s0 va_k = let (va_sM, va_f0) = va_lemma_Fast_add1_stdcall (va_code_Fast_add1_stdcall win) va_s0 win dst_b inA_b inB_in in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 0 va_sM (va_update_flags va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRsp va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))))))))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRsp; va_Mod_reg64 rRbp; va_Mod_reg64 rRdi; va_Mod_reg64 rRsi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) #pop-options //-- //-- Fast_sub1 #push-options "--z3rlimit 1200" val va_code_Fast_sub1 : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Fast_sub1 () = (va_Block (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsi) 0 Secret) (va_CCons (va_code_Sub64Wrap (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRsi) 8 Secret) (va_CCons (va_code_Sbb64 (va_op_dst_opr64_reg64 rR9) (va_const_opr64 0)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 8 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR10) (va_op_reg_opr64_reg64 rRsi) 16 Secret) (va_CCons (va_code_Sbb64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 0)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 16 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRsi) 24 Secret) (va_CCons (va_code_Sbb64 (va_op_dst_opr64_reg64 rR11) (va_const_opr64 0)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 24 Secret) (va_CCons (va_code_Adc64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_CNil ())))))))))))))))) val va_codegen_success_Fast_sub1 : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Fast_sub1 () = (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsi) 0 Secret) (va_pbool_and (va_codegen_success_Sub64Wrap (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRsi) 8 Secret) (va_pbool_and (va_codegen_success_Sbb64 (va_op_dst_opr64_reg64 rR9) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 8 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR10) (va_op_reg_opr64_reg64 rRsi) 16 Secret) (va_pbool_and (va_codegen_success_Sbb64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 16 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRsi) 24 Secret) (va_pbool_and (va_codegen_success_Sbb64 (va_op_dst_opr64_reg64 rR11) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 24 Secret) (va_pbool_and (va_codegen_success_Adc64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_ttrue ()))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Fast_sub1 (va_mods:va_mods_t) (dst_b:buffer64) (inA_b:buffer64) : (va_quickCode unit (va_code_Fast_sub1 ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 378 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Arch.Types.xor_lemmas ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 379 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 381 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsi) 0 Secret inA_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 382 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Sub64Wrap (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 383 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 0 Secret dst_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 385 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRsi) 8 Secret inA_b 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 386 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Sbb64 (va_op_dst_opr64_reg64 rR9) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 387 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 8 Secret dst_b 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 389 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR10) (va_op_reg_opr64_reg64 rRsi) 16 Secret inA_b 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 390 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Sbb64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 391 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 16 Secret dst_b 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 393 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRsi) 24 Secret inA_b 3) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 394 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Sbb64 (va_op_dst_opr64_reg64 rR11) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 395 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 24 Secret dst_b 3) (fun (va_s:va_state) _ -> let (c:bool) = Vale.X64.Decls.cf (va_get_flags va_s) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 398 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adc64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (fun (va_s:va_state) _ -> va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 399 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_reg64 rRax va_s == Vale.Curve25519.Fast_defs.bool_bit c) (va_QEmpty (()))))))))))))))))))) val va_lemma_Fast_sub1 : va_b0:va_code -> va_s0:va_state -> dst_b:buffer64 -> inA_b:buffer64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Fast_sub1 ()) va_s0 /\ va_get_ok va_s0 /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in (Vale.X64.Decls.buffers_disjoint dst_b inA_b \/ dst_b == inA_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdi va_s0) dst_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) inA_b 4 (va_get_mem_layout va_s0) Secret))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in let d = Vale.Curve25519.Fast_defs.pow2_four d0 d1 d2 d3 in d - va_mul_nat (va_get_reg64 rRax va_sM) pow2_256 == a - va_get_reg64 rRcx va_s0 /\ (va_get_reg64 rRax va_sM == 0 \/ va_get_reg64 rRax va_sM == 1) /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM)) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))) [@"opaque_to_smt"] let va_lemma_Fast_sub1 va_b0 va_s0 dst_b inA_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Fast_sub1 va_mods dst_b inA_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Fast_sub1 ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 339 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_ok va_sM) /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in label va_range1 "***** POSTCONDITION NOT MET AT line 367 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 368 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 369 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 370 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 371 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d = Vale.Curve25519.Fast_defs.pow2_four d0 d1 d2 d3 in label va_range1 "***** POSTCONDITION NOT MET AT line 372 column 41 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (d - va_mul_nat (va_get_reg64 rRax va_sM) pow2_256 == a - va_get_reg64 rRcx va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 373 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_reg64 rRax va_sM == 0 \/ va_get_reg64 rRax va_sM == 1) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 375 column 69 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 376 column 50 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM))))))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Fast_sub1 (dst_b:buffer64) (inA_b:buffer64) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in (Vale.X64.Decls.buffers_disjoint dst_b inA_b \/ dst_b == inA_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdi va_s0) dst_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) inA_b 4 (va_get_mem_layout va_s0) Secret) /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64) (va_x_r11:nat64) (va_x_heap0:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 0 va_x_heap0 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10 (va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem va_s0))))))) in va_get_ok va_sM /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in let d = Vale.Curve25519.Fast_defs.pow2_four d0 d1 d2 d3 in d - va_mul_nat (va_get_reg64 rRax va_sM) pow2_256 == a - va_get_reg64 rRcx va_s0 /\ (va_get_reg64 rRax va_sM == 0 \/ va_get_reg64 rRax va_sM == 1) /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM)) ==> va_k va_sM (()))) val va_wpProof_Fast_sub1 : dst_b:buffer64 -> inA_b:buffer64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Fast_sub1 dst_b inA_b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Fast_sub1 ()) ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Fast_sub1 dst_b inA_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_Fast_sub1 (va_code_Fast_sub1 ()) va_s0 dst_b inA_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Fast_sub1 (dst_b:buffer64) (inA_b:buffer64) : (va_quickCode unit (va_code_Fast_sub1 ())) = (va_QProc (va_code_Fast_sub1 ()) ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_Fast_sub1 dst_b inA_b) (va_wpProof_Fast_sub1 dst_b inA_b)) #pop-options //-- //-- Fast_add #push-options "--z3rlimit 600" val va_code_Fast_add : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Fast_add () = (va_Block (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR8)) (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Add64Wrap (va_op_dst_opr64_reg64 rR9) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 0 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR10) (va_op_reg_opr64_reg64 rRcx) 8 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 8 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRcx) 16 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rR11) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 16 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRcx) 24 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rRbx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRbx) 24 Secret) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR8)) (va_CNil ()))))))))))))))))))))) val va_codegen_success_Fast_add : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Fast_add () = (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR8)) (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Add64Wrap (va_op_dst_opr64_reg64 rR9) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 0 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR10) (va_op_reg_opr64_reg64 rRcx) 8 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 8 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRcx) 16 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rR11) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 16 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRcx) 24 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rRbx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRbx) 24 Secret) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR8)) (va_ttrue ())))))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Fast_add (va_mods:va_mods_t) (dst_b:buffer64) (inA_b:buffer64) (inB_b:buffer64) : (va_quickCode unit (va_code_Fast_add ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 521 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Arch.Types.xor_lemmas ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 522 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR8)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 523 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 525 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRcx) 0 Secret inB_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 526 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 inA_b 0 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 526 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Add64Wrap (va_op_dst_opr64_reg64 rR9) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 527 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 0 Secret dst_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 529 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR10) (va_op_reg_opr64_reg64 rRcx) 8 Secret inB_b 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 530 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 inA_b 1 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 530 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 531 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 8 Secret dst_b 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 533 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRcx) 16 Secret inB_b 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 534 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 inA_b 2 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 534 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rR11) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 535 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 16 Secret dst_b 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 537 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRcx) 24 Secret inB_b 3) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 538 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 inA_b 3 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 538 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rRbx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 539 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRbx) 24 Secret dst_b 3) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 541 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR8)) (va_QEmpty (()))))))))))))))))))))))) val va_lemma_Fast_add : va_b0:va_code -> va_s0:va_state -> dst_b:buffer64 -> inA_b:buffer64 -> inB_b:buffer64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Fast_add ()) va_s0 /\ va_get_ok va_s0 /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in adx_enabled /\ bmi2_enabled /\ (Vale.X64.Decls.buffers_disjoint dst_b inA_b \/ dst_b == inA_b) /\ (Vale.X64.Decls.buffers_disjoint dst_b inB_b \/ dst_b == inB_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdi va_s0) dst_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) inA_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRcx va_s0) inB_b 4 (va_get_mem_layout va_s0) Secret))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in let d = Vale.Curve25519.Fast_defs.pow2_five d0 d1 d2 d3 (va_get_reg64 rRax va_sM) in d == a + b /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM)) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))) [@"opaque_to_smt"] let va_lemma_Fast_add va_b0 va_s0 dst_b inA_b inB_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Fast_add va_mods dst_b inA_b inB_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Fast_add ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 474 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_ok va_sM) /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in label va_range1 "***** POSTCONDITION NOT MET AT line 511 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 512 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 513 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 514 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 515 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d = Vale.Curve25519.Fast_defs.pow2_five d0 d1 d2 d3 (va_get_reg64 rRax va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 516 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (d == a + b) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 518 column 69 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 519 column 50 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM))))))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Fast_add (dst_b:buffer64) (inA_b:buffer64) (inB_b:buffer64) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in adx_enabled /\ bmi2_enabled /\ (Vale.X64.Decls.buffers_disjoint dst_b inA_b \/ dst_b == inA_b) /\ (Vale.X64.Decls.buffers_disjoint dst_b inB_b \/ dst_b == inB_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdi va_s0) dst_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) inA_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRcx va_s0) inB_b 4 (va_get_mem_layout va_s0) Secret) /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64) (va_x_r11:nat64) (va_x_rbx:nat64) (va_x_heap0:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 0 va_x_heap0 (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10 (va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem va_s0)))))))) in va_get_ok va_sM /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in let d = Vale.Curve25519.Fast_defs.pow2_five d0 d1 d2 d3 (va_get_reg64 rRax va_sM) in d == a + b /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM)) ==> va_k va_sM (()))) val va_wpProof_Fast_add : dst_b:buffer64 -> inA_b:buffer64 -> inB_b:buffer64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Fast_add dst_b inA_b inB_b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Fast_add ()) ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Fast_add dst_b inA_b inB_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_Fast_add (va_code_Fast_add ()) va_s0 dst_b inA_b inB_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Fast_add (dst_b:buffer64) (inA_b:buffer64) (inB_b:buffer64) : (va_quickCode unit (va_code_Fast_add ())) = (va_QProc (va_code_Fast_add ()) ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_Fast_add dst_b inA_b inB_b) (va_wpProof_Fast_add dst_b inA_b inB_b)) #pop-options //-- //-- Fast_sub #push-options "--z3rlimit 600" val va_code_Fast_sub : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Fast_sub () = (va_Block (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsi) 0 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Sub64Wrap (va_op_dst_opr64_reg64 rR8) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 0 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRsi) 8 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Sbb64 (va_op_dst_opr64_reg64 rR9) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 8 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 8 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR10) (va_op_reg_opr64_reg64 rRsi) 16 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Sbb64 (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 16 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 16 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRsi) 24 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Sbb64 (va_op_dst_opr64_reg64 rR11) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 24 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 24 Secret) (va_CCons (va_code_Adc64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_CNil ())))))))))))))))))))) val va_codegen_success_Fast_sub : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Fast_sub () = (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsi) 0 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Sub64Wrap (va_op_dst_opr64_reg64 rR8) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 0 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRsi) 8 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Sbb64 (va_op_dst_opr64_reg64 rR9) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 8 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 8 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR10) (va_op_reg_opr64_reg64 rRsi) 16 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Sbb64 (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 16 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 16 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRsi) 24 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Sbb64 (va_op_dst_opr64_reg64 rR11) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 24 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 24 Secret) (va_pbool_and (va_codegen_success_Adc64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_ttrue ()))))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Fast_sub (va_mods:va_mods_t) (dst_b:buffer64) (inA_b:buffer64) (inB_b:buffer64) : (va_quickCode unit (va_code_Fast_sub ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 674 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Arch.Types.xor_lemmas ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 677 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 679 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsi) 0 Secret inA_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 680 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 0 inB_b 0 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 680 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Sub64Wrap (va_op_dst_opr64_reg64 rR8) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 0 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 681 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 0 Secret dst_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 685 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRsi) 8 Secret inA_b 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 686 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 8 inB_b 1 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 686 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Sbb64 (va_op_dst_opr64_reg64 rR9) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 8 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 687 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 8 Secret dst_b 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 691 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR10) (va_op_reg_opr64_reg64 rRsi) 16 Secret inA_b 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 692 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 16 inB_b 2 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 692 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Sbb64 (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 16 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 694 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 16 Secret dst_b 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 696 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRsi) 24 Secret inA_b 3) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 697 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 24 inB_b 3 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 697 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Sbb64 (va_op_dst_opr64_reg64 rR11) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 24 Secret)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 698 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 24 Secret dst_b 3) (fun (va_s:va_state) _ -> let (c:bool) = Vale.X64.Decls.cf (va_get_flags va_s) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 701 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adc64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (fun (va_s:va_state) _ -> va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 702 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_reg64 rRax va_s == Vale.Curve25519.Fast_defs.bool_bit c) (let (va_arg41:Vale.Curve25519.Fast_defs.bit) = Vale.Curve25519.Fast_defs.bool_bit c in let (va_arg40:Vale.Def.Types_s.nat64) = va_get_reg64 rR11 va_s in let (va_arg39:Vale.Def.Types_s.nat64) = va_get_reg64 rR10 va_s in let (va_arg38:Vale.Def.Types_s.nat64) = va_get_reg64 rR9 va_s in let (va_arg37:Vale.Def.Types_s.nat64) = va_get_reg64 rR8 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 704 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Curve25519.FastUtil_helpers.lemma_sub a a0 a1 a2 a3 b b0 b1 b2 b3 va_arg37 va_arg38 va_arg39 va_arg40 va_arg41) (va_QEmpty (())))))))))))))))))))))))) val va_lemma_Fast_sub : va_b0:va_code -> va_s0:va_state -> dst_b:buffer64 -> inA_b:buffer64 -> inB_b:buffer64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Fast_sub ()) va_s0 /\ va_get_ok va_s0 /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in (Vale.X64.Decls.buffers_disjoint dst_b inA_b \/ dst_b == inA_b) /\ (Vale.X64.Decls.buffers_disjoint dst_b inB_b \/ dst_b == inB_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdi va_s0) dst_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) inA_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRcx va_s0) inB_b 4 (va_get_mem_layout va_s0) Secret))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in let d = Vale.Curve25519.Fast_defs.pow2_four d0 d1 d2 d3 in d - va_mul_nat (va_get_reg64 rRax va_sM) pow2_256 == a - b /\ (va_get_reg64 rRax va_sM == 0 \/ va_get_reg64 rRax va_sM == 1) /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM)) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))) [@"opaque_to_smt"] let va_lemma_Fast_sub va_b0 va_s0 dst_b inA_b inB_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Fast_sub va_mods dst_b inA_b inB_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Fast_sub ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 627 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_ok va_sM) /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in label va_range1 "***** POSTCONDITION NOT MET AT line 663 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 664 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 665 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 666 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 667 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d = Vale.Curve25519.Fast_defs.pow2_four d0 d1 d2 d3 in label va_range1 "***** POSTCONDITION NOT MET AT line 668 column 41 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (d - va_mul_nat (va_get_reg64 rRax va_sM) pow2_256 == a - b) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 669 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_reg64 rRax va_sM == 0 \/ va_get_reg64 rRax va_sM == 1) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 671 column 69 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 672 column 50 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM))))))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Fast_sub (dst_b:buffer64) (inA_b:buffer64) (inB_b:buffer64) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in (Vale.X64.Decls.buffers_disjoint dst_b inA_b \/ dst_b == inA_b) /\ (Vale.X64.Decls.buffers_disjoint dst_b inB_b \/ dst_b == inB_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdi va_s0) dst_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) inA_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRcx va_s0) inB_b 4 (va_get_mem_layout va_s0) Secret) /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64) (va_x_r11:nat64) (va_x_heap0:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 0 va_x_heap0 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10 (va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem va_s0))))))) in va_get_ok va_sM /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in let d = Vale.Curve25519.Fast_defs.pow2_four d0 d1 d2 d3 in d - va_mul_nat (va_get_reg64 rRax va_sM) pow2_256 == a - b /\ (va_get_reg64 rRax va_sM == 0 \/ va_get_reg64 rRax va_sM == 1) /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM)) ==> va_k va_sM (()))) val va_wpProof_Fast_sub : dst_b:buffer64 -> inA_b:buffer64 -> inB_b:buffer64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Fast_sub dst_b inA_b inB_b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Fast_sub ()) ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Fast_sub dst_b inA_b inB_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_Fast_sub (va_code_Fast_sub ()) va_s0 dst_b inA_b inB_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Fast_sub (dst_b:buffer64) (inA_b:buffer64) (inB_b:buffer64) : (va_quickCode unit (va_code_Fast_sub ())) = (va_QProc (va_code_Fast_sub ()) ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_Fast_sub dst_b inA_b inB_b) (va_wpProof_Fast_sub dst_b inA_b inB_b)) #pop-options //-- //-- Cswap_single val va_code_Cswap_single : offset:nat -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Cswap_single offset = (va_Block (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsi) (0 + offset `op_Multiply` 8) Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRdx) (0 + offset `op_Multiply` 8) Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR8)) (va_CCons (va_code_Cmovc64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR9)) (va_CCons (va_code_Cmovc64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR10)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rR8) (0 + offset `op_Multiply` 8) Secret) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rR9) (0 + offset `op_Multiply` 8) Secret) (va_CNil ()))))))))) val va_codegen_success_Cswap_single : offset:nat -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Cswap_single offset = (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsi) (0 + offset `op_Multiply` 8) Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRdx) (0 + offset `op_Multiply` 8) Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR8)) (va_pbool_and (va_codegen_success_Cmovc64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR9)) (va_pbool_and (va_codegen_success_Cmovc64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR10)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rR8) (0 + offset `op_Multiply` 8) Secret) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rR9) (0 + offset `op_Multiply` 8) Secret) (va_ttrue ())))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Cswap_single (va_mods:va_mods_t) (offset:nat) (p0_b:buffer64) (p1_b:buffer64) : (va_quickCode unit (va_code_Cswap_single offset)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (old_p0_val:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b (0 + offset) (va_get_mem_heaplet 0 va_s) in let (old_p1_val:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b (0 + offset) (va_get_mem_heaplet 0 va_s) in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 839 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsi) (0 + offset `op_Multiply` 8) Secret p0_b (0 + offset)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 840 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRdx) (0 + offset `op_Multiply` 8) Secret p1_b (0 + offset)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 841 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR8)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 842 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Cmovc64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR9)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 843 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Cmovc64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR10)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 844 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rR8) (0 + offset `op_Multiply` 8) Secret p0_b (0 + offset)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 845 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rR9) (0 + offset `op_Multiply` 8) Secret p1_b (0 + offset)) (va_QEmpty (())))))))))) val va_lemma_Cswap_single : va_b0:va_code -> va_s0:va_state -> offset:nat -> p0_b:buffer64 -> p1_b:buffer64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Cswap_single offset) va_s0 /\ va_get_ok va_s0 /\ (let (old_p0_val:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b (0 + offset) (va_get_mem_heaplet 0 va_s0) in let (old_p1_val:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b (0 + offset) (va_get_mem_heaplet 0 va_s0) in offset < 8 /\ (Vale.X64.Decls.buffers_disjoint p1_b p0_b \/ p1_b == p0_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) p0_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdx va_s0) p1_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.valid_cf (va_get_flags va_s0)))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (old_p0_val:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b (0 + offset) (va_get_mem_heaplet 0 va_s0) in let (old_p1_val:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b (0 + offset) (va_get_mem_heaplet 0 va_s0) in Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRsi va_sM) p0_b 8 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdx va_sM) p1_b 8 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer_2 p0_b p1_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM) /\ (forall (i:nat) . 0 <= i /\ i < 8 /\ i =!= offset ==> Vale.X64.Decls.buffer64_read p0_b i (va_get_mem_heaplet 0 va_sM) == Vale.X64.Decls.buffer64_read p0_b i (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.buffer64_read p1_b i (va_get_mem_heaplet 0 va_sM) == Vale.X64.Decls.buffer64_read p1_b i (va_get_mem_heaplet 0 va_s0)) /\ (let p0_val = Vale.X64.Decls.buffer64_read p0_b (0 + offset) (va_get_mem_heaplet 0 va_sM) in let p1_val = Vale.X64.Decls.buffer64_read p1_b (0 + offset) (va_get_mem_heaplet 0 va_sM) in p0_val == (if Vale.X64.Decls.cf (va_get_flags va_sM) then old_p1_val else old_p0_val) /\ p1_val == (if Vale.X64.Decls.cf (va_get_flags va_sM) then old_p0_val else old_p1_val))) /\ va_state_eq va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))) [@"opaque_to_smt"] let va_lemma_Cswap_single va_b0 va_s0 offset p0_b p1_b = let (va_mods:va_mods_t) = [va_Mod_mem_heaplet 0; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Cswap_single va_mods offset p0_b p1_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Cswap_single offset) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 792 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_ok va_sM) /\ (let (old_p0_val:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b (0 + offset) (va_get_mem_heaplet 0 va_s0) in let (old_p1_val:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b (0 + offset) (va_get_mem_heaplet 0 va_s0) in label va_range1 "***** POSTCONDITION NOT MET AT line 821 column 67 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRsi va_sM) p0_b 8 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 822 column 67 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdx va_sM) p1_b 8 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 824 column 57 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.modifies_buffer_2 p0_b p1_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 832 column 59 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (forall (i:nat) . 0 <= i /\ i < 8 /\ i =!= offset ==> Vale.X64.Decls.buffer64_read p0_b i (va_get_mem_heaplet 0 va_sM) == Vale.X64.Decls.buffer64_read p0_b i (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.buffer64_read p1_b i (va_get_mem_heaplet 0 va_sM) == Vale.X64.Decls.buffer64_read p1_b i (va_get_mem_heaplet 0 va_s0)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 834 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_val = Vale.X64.Decls.buffer64_read p0_b (0 + offset) (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 835 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_val = Vale.X64.Decls.buffer64_read p1_b (0 + offset) (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 836 column 63 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_val == va_if (Vale.X64.Decls.cf (va_get_flags va_sM)) (fun _ -> old_p1_val) (fun _ -> old_p0_val)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 837 column 63 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_val == va_if (Vale.X64.Decls.cf (va_get_flags va_sM)) (fun _ -> old_p0_val) (fun _ -> old_p1_val)))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_mem_heaplet 0; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Cswap_single (offset:nat) (p0_b:buffer64) (p1_b:buffer64) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (let (old_p0_val:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b (0 + offset) (va_get_mem_heaplet 0 va_s0) in let (old_p1_val:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b (0 + offset) (va_get_mem_heaplet 0 va_s0) in offset < 8 /\ (Vale.X64.Decls.buffers_disjoint p1_b p0_b \/ p1_b == p0_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) p0_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdx va_s0) p1_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.valid_cf (va_get_flags va_s0)) /\ (forall (va_x_mem:vale_heap) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64) (va_x_heap0:vale_heap) . let va_sM = va_upd_mem_heaplet 0 va_x_heap0 (va_upd_reg64 rR10 va_x_r10 (va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_mem va_x_mem va_s0)))) in va_get_ok va_sM /\ (let (old_p0_val:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b (0 + offset) (va_get_mem_heaplet 0 va_s0) in let (old_p1_val:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b (0 + offset) (va_get_mem_heaplet 0 va_s0) in Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRsi va_sM) p0_b 8 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdx va_sM) p1_b 8 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer_2 p0_b p1_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM) /\ (forall (i:nat) . 0 <= i /\ i < 8 /\ i =!= offset ==> Vale.X64.Decls.buffer64_read p0_b i (va_get_mem_heaplet 0 va_sM) == Vale.X64.Decls.buffer64_read p0_b i (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.buffer64_read p1_b i (va_get_mem_heaplet 0 va_sM) == Vale.X64.Decls.buffer64_read p1_b i (va_get_mem_heaplet 0 va_s0)) /\ (let p0_val = Vale.X64.Decls.buffer64_read p0_b (0 + offset) (va_get_mem_heaplet 0 va_sM) in let p1_val = Vale.X64.Decls.buffer64_read p1_b (0 + offset) (va_get_mem_heaplet 0 va_sM) in p0_val == va_if (Vale.X64.Decls.cf (va_get_flags va_sM)) (fun _ -> old_p1_val) (fun _ -> old_p0_val) /\ p1_val == va_if (Vale.X64.Decls.cf (va_get_flags va_sM)) (fun _ -> old_p0_val) (fun _ -> old_p1_val))) ==> va_k va_sM (()))) val va_wpProof_Cswap_single : offset:nat -> p0_b:buffer64 -> p1_b:buffer64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Cswap_single offset p0_b p1_b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Cswap_single offset) ([va_Mod_mem_heaplet 0; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Cswap_single offset p0_b p1_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_Cswap_single (va_code_Cswap_single offset) va_s0 offset p0_b p1_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))); va_lemma_norm_mods ([va_Mod_mem_heaplet 0; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Cswap_single (offset:nat) (p0_b:buffer64) (p1_b:buffer64) : (va_quickCode unit (va_code_Cswap_single offset)) = (va_QProc (va_code_Cswap_single offset) ([va_Mod_mem_heaplet 0; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_mem]) (va_wp_Cswap_single offset p0_b p1_b) (va_wpProof_Cswap_single offset p0_b p1_b)) //-- //-- Cswap2 [@ "opaque_to_smt" va_qattr] let va_code_Cswap2 () = (va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (va_code_Comment "Transfer bit into CF flag" ) (va_CCons (va_code_Add64Wrap (va_op_dst_opr64_reg64 rRdi) (va_const_opr64 18446744073709551615)) (va_CCons (va_code_Newline ()) (va_CCons (va_code_Comment "cswap p1[0], p2[0]" ) (va_CCons (va_code_Cswap_single 0) (va_CCons (va_code_Newline ()) (va_CCons (va_code_Comment "cswap p1[1], p2[1]" ) (va_CCons (va_code_Cswap_single 1) (va_CCons (va_code_Newline ()) (va_CCons (va_code_Comment "cswap p1[2], p2[2]" ) (va_CCons (va_code_Cswap_single 2) (va_CCons (va_code_Newline ()) (va_CCons (va_code_Comment "cswap p1[3], p2[3]" ) (va_CCons (va_code_Cswap_single 3) (va_CCons (va_code_Newline ()) (va_CCons (va_code_Comment "cswap p1[4], p2[4]" ) (va_CCons (va_code_Cswap_single 4) (va_CCons (va_code_Newline ()) (va_CCons (va_code_Comment "cswap p1[5], p2[5]" ) (va_CCons (va_code_Cswap_single 5) (va_CCons (va_code_Newline ()) (va_CCons (va_code_Comment "cswap p1[6], p2[6]" ) (va_CCons (va_code_Cswap_single 6) (va_CCons (va_code_Newline ()) (va_CCons (va_code_Comment "cswap p1[7], p2[7]" ) (va_CCons (va_code_Cswap_single 7) (va_CCons (va_code_DestroyHeaplets ()) (va_CNil ())))))))))))))))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Cswap2 () = (va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and (va_codegen_success_Comment "Transfer bit into CF flag" ) (va_pbool_and (va_codegen_success_Add64Wrap (va_op_dst_opr64_reg64 rRdi) (va_const_opr64 18446744073709551615)) (va_pbool_and (va_codegen_success_Newline ()) (va_pbool_and (va_codegen_success_Comment "cswap p1[0], p2[0]" ) (va_pbool_and (va_codegen_success_Cswap_single 0) (va_pbool_and (va_codegen_success_Newline ()) (va_pbool_and (va_codegen_success_Comment "cswap p1[1], p2[1]" ) (va_pbool_and (va_codegen_success_Cswap_single 1) (va_pbool_and (va_codegen_success_Newline ()) (va_pbool_and (va_codegen_success_Comment "cswap p1[2], p2[2]" ) (va_pbool_and (va_codegen_success_Cswap_single 2) (va_pbool_and (va_codegen_success_Newline ()) (va_pbool_and (va_codegen_success_Comment "cswap p1[3], p2[3]" ) (va_pbool_and (va_codegen_success_Cswap_single 3) (va_pbool_and (va_codegen_success_Newline ()) (va_pbool_and (va_codegen_success_Comment "cswap p1[4], p2[4]" ) (va_pbool_and (va_codegen_success_Cswap_single 4) (va_pbool_and (va_codegen_success_Newline ()) (va_pbool_and (va_codegen_success_Comment "cswap p1[5], p2[5]" ) (va_pbool_and (va_codegen_success_Cswap_single 5) (va_pbool_and (va_codegen_success_Newline ()) (va_pbool_and (va_codegen_success_Comment "cswap p1[6], p2[6]" ) (va_pbool_and (va_codegen_success_Cswap_single 6) (va_pbool_and (va_codegen_success_Newline ()) (va_pbool_and (va_codegen_success_Comment "cswap p1[7], p2[7]" ) (va_pbool_and (va_codegen_success_Cswap_single 7) (va_pbool_and (va_codegen_success_DestroyHeaplets ()) (va_ttrue ()))))))))))))))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Cswap2 (va_mods:va_mods_t) (bit_in:nat64) (p0_b:buffer64) (p1_b:buffer64) : (va_quickCode unit (va_code_Cswap2 ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (old_p0_0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 0 (va_get_mem va_s) in let (old_p0_1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 1 (va_get_mem va_s) in let (old_p0_2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 2 (va_get_mem va_s) in let (old_p0_3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 3 (va_get_mem va_s) in let (old_p0_4:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 4 (va_get_mem va_s) in let (old_p0_5:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 5 (va_get_mem va_s) in let (old_p0_6:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 6 (va_get_mem va_s) in let (old_p0_7:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 7 (va_get_mem va_s) in let (old_p1_0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 0 (va_get_mem va_s) in let (old_p1_1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 1 (va_get_mem va_s) in let (old_p1_2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 2 (va_get_mem va_s) in let (old_p1_3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 3 (va_get_mem va_s) in let (old_p1_4:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 4 (va_get_mem va_s) in let (old_p1_5:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 5 (va_get_mem va_s) in let (old_p1_6:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 6 (va_get_mem va_s) in let (old_p1_7:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 7 (va_get_mem va_s) in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 932 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_CreateHeaplets ([declare_buffer64 p0_b 0 Secret Mutable; declare_buffer64 p1_b 0 Secret Mutable])) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 936 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Comment "Transfer bit into CF flag" ) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 937 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Add64Wrap (va_op_dst_opr64_reg64 rRdi) (va_const_opr64 18446744073709551615)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 939 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Newline ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 940 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Comment "cswap p1[0], p2[0]" ) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 941 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Cswap_single 0 p0_b p1_b) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 943 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Newline ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 944 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Comment "cswap p1[1], p2[1]" ) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 945 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Cswap_single 1 p0_b p1_b) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 947 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Newline ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 948 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Comment "cswap p1[2], p2[2]" ) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 949 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Cswap_single 2 p0_b p1_b) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 951 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Newline ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 952 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Comment "cswap p1[3], p2[3]" ) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 953 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Cswap_single 3 p0_b p1_b) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 955 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Newline ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 956 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Comment "cswap p1[4], p2[4]" ) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 957 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Cswap_single 4 p0_b p1_b) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 959 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Newline ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 960 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Comment "cswap p1[5], p2[5]" ) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 961 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Cswap_single 5 p0_b p1_b) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 963 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Newline ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 964 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Comment "cswap p1[6], p2[6]" ) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 965 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Cswap_single 6 p0_b p1_b) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 967 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Newline ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 968 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Comment "cswap p1[7], p2[7]" ) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 969 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Cswap_single 7 p0_b p1_b) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 971 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_DestroyHeaplets ()) (va_QEmpty (()))))))))))))))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Cswap2 va_b0 va_s0 bit_in p0_b p1_b = let (va_mods:va_mods_t) = [va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdi; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Cswap2 va_mods bit_in p0_b p1_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Cswap2 ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 848 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_ok va_sM) /\ (let (old_p0_0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 0 (va_get_mem va_s0) in let (old_p0_1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 1 (va_get_mem va_s0) in let (old_p0_2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 2 (va_get_mem va_s0) in let (old_p0_3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 3 (va_get_mem va_s0) in let (old_p0_4:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 4 (va_get_mem va_s0) in let (old_p0_5:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 5 (va_get_mem va_s0) in let (old_p0_6:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 6 (va_get_mem va_s0) in let (old_p0_7:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 7 (va_get_mem va_s0) in let (old_p1_0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 0 (va_get_mem va_s0) in let (old_p1_1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 1 (va_get_mem va_s0) in let (old_p1_2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 2 (va_get_mem va_s0) in let (old_p1_3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 3 (va_get_mem va_s0) in let (old_p1_4:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 4 (va_get_mem va_s0) in let (old_p1_5:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 5 (va_get_mem va_s0) in let (old_p1_6:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 6 (va_get_mem va_s0) in let (old_p1_7:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 7 (va_get_mem va_s0) in label va_range1 "***** POSTCONDITION NOT MET AT line 894 column 53 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.modifies_buffer_2 p0_b p1_b (va_get_mem va_s0) (va_get_mem va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 896 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_0 = Vale.X64.Decls.buffer64_read p0_b 0 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 897 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_1 = Vale.X64.Decls.buffer64_read p0_b 1 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 898 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_2 = Vale.X64.Decls.buffer64_read p0_b 2 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 899 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_3 = Vale.X64.Decls.buffer64_read p0_b 3 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 900 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_4 = Vale.X64.Decls.buffer64_read p0_b 4 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 901 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_5 = Vale.X64.Decls.buffer64_read p0_b 5 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 902 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_6 = Vale.X64.Decls.buffer64_read p0_b 6 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 903 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_7 = Vale.X64.Decls.buffer64_read p0_b 7 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 905 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_0 = Vale.X64.Decls.buffer64_read p1_b 0 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 906 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_1 = Vale.X64.Decls.buffer64_read p1_b 1 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 907 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_2 = Vale.X64.Decls.buffer64_read p1_b 2 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 908 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_3 = Vale.X64.Decls.buffer64_read p1_b 3 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 909 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_4 = Vale.X64.Decls.buffer64_read p1_b 4 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 910 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_5 = Vale.X64.Decls.buffer64_read p1_b 5 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 911 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_6 = Vale.X64.Decls.buffer64_read p1_b 6 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 912 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_7 = Vale.X64.Decls.buffer64_read p1_b 7 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 914 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_0 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p1_0) (fun _ -> old_p0_0)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 915 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_1 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p1_1) (fun _ -> old_p0_1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 916 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_2 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p1_2) (fun _ -> old_p0_2)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 917 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_3 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p1_3) (fun _ -> old_p0_3)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 918 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_4 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p1_4) (fun _ -> old_p0_4)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 919 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_5 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p1_5) (fun _ -> old_p0_5)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 920 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_6 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p1_6) (fun _ -> old_p0_6)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 921 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_7 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p1_7) (fun _ -> old_p0_7)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 923 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_0 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p0_0) (fun _ -> old_p1_0)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 924 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_1 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p0_1) (fun _ -> old_p1_1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 925 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_2 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p0_2) (fun _ -> old_p1_2)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 926 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_3 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p0_3) (fun _ -> old_p1_3)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 927 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_4 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p0_4) (fun _ -> old_p1_4)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 928 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_5 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p0_5) (fun _ -> old_p1_5)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 929 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_6 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p0_6) (fun _ -> old_p1_6)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 930 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_7 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p0_7) (fun _ -> old_p1_7)))))))))))))))))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdi; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Cswap2 bit_in p0_b p1_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_Cswap2 (va_code_Cswap2 ()) va_s0 bit_in p0_b p1_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 0 va_sM (va_update_flags va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRdi va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))); va_lemma_norm_mods ([va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdi; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Cswap2_stdcall [@ "opaque_to_smt" va_qattr] let va_code_Cswap2_stdcall win = (va_Block (va_CCons (if win then va_Block (va_CCons (va_code_Push_Secret (va_op_reg_opr64_reg64 rRdi)) (va_CCons (va_code_Push_Secret (va_op_reg_opr64_reg64 rRsi)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRsi) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR8)) (va_CNil ())))))) else va_Block (va_CNil ())) (va_CCons (va_code_Cswap2 ()) (va_CCons (if win then va_Block (va_CCons (va_code_Pop_Secret (va_op_dst_opr64_reg64 rRsi)) (va_CCons (va_code_Pop_Secret (va_op_dst_opr64_reg64 rRdi)) (va_CNil ()))) else va_Block (va_CNil ())) (va_CNil ()))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Cswap2_stdcall win = (va_pbool_and (if win then va_pbool_and (va_codegen_success_Push_Secret (va_op_reg_opr64_reg64 rRdi)) (va_pbool_and (va_codegen_success_Push_Secret (va_op_reg_opr64_reg64 rRsi)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRsi) (va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR8)) (va_ttrue ()))))) else va_ttrue ()) (va_pbool_and (va_codegen_success_Cswap2 ()) (va_pbool_and (if win then va_pbool_and (va_codegen_success_Pop_Secret (va_op_dst_opr64_reg64 rRsi)) (va_pbool_and (va_codegen_success_Pop_Secret (va_op_dst_opr64_reg64 rRdi)) (va_ttrue ())) else va_ttrue ()) (va_ttrue ())))) [@ "opaque_to_smt" va_qattr] let va_qcode_Cswap2_stdcall (va_mods:va_mods_t) (win:bool) (bit_in:nat64) (p0_b:buffer64) (p1_b:buffer64) : (va_quickCode unit (va_code_Cswap2_stdcall win)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (p0_in:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let (p1_in:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rR8 va_s) (fun _ -> va_get_reg64 rRdx va_s) in let (old_p0_0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 0 (va_get_mem va_s) in let (old_p0_1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 1 (va_get_mem va_s) in let (old_p0_2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 2 (va_get_mem va_s) in let (old_p0_3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 3 (va_get_mem va_s) in let (old_p0_4:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 4 (va_get_mem va_s) in let (old_p0_5:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 5 (va_get_mem va_s) in let (old_p0_6:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 6 (va_get_mem va_s) in let (old_p0_7:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 7 (va_get_mem va_s) in let (old_p1_0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 0 (va_get_mem va_s) in let (old_p1_1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 1 (va_get_mem va_s) in let (old_p1_2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 2 (va_get_mem va_s) in let (old_p1_3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 3 (va_get_mem va_s) in let (old_p1_4:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 4 (va_get_mem va_s) in let (old_p1_5:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 5 (va_get_mem va_s) in let (old_p1_6:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 6 (va_get_mem va_s) in let (old_p1_7:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 7 (va_get_mem va_s) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 1067 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 1070 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Push_Secret (va_op_reg_opr64_reg64 rRdi)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 1071 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Push_Secret (va_op_reg_opr64_reg64 rRsi)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 1072 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 1073 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRsi) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 1074 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR8)) (va_QEmpty (())))))))) (qblock va_mods (fun (va_s:va_state) -> va_QEmpty (())))) (fun (va_s:va_state) va_g -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 1077 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Cswap2 bit_in p0_b p1_b) (fun (va_s:va_state) _ -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 1079 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 1081 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Pop_Secret (va_op_dst_opr64_reg64 rRsi)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 1082 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Pop_Secret (va_op_dst_opr64_reg64 rRdi)) (va_QEmpty (()))))) (qblock va_mods (fun (va_s:va_state) -> va_QEmpty (())))) (fun (va_s:va_state) va_g -> va_QEmpty (()))))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsStack.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.FastUtil_helpers.fsti.checked", "Vale.Curve25519.Fast_lemmas_external.fsti.checked", "Vale.Curve25519.Fast_defs.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.Curve25519.X64.FastUtil.fst" }
[ { "abbrev": false, "full_module": "Vale.Curve25519.FastUtil_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_lemmas_external", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 60, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> win: Prims.bool -> bit_in: Vale.X64.Memory.nat64 -> p0_b: Vale.X64.Memory.buffer64 -> p1_b: Vale.X64.Memory.buffer64 -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
Prims.Ghost
[]
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Prims.bool", "Vale.X64.Memory.nat64", "Vale.X64.Memory.buffer64", "Vale.X64.QuickCodes.fuel", "Prims.unit", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_fuel", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_stackTaint", "Vale.X64.QuickCode.va_Mod_stack", "Vale.X64.QuickCode.va_Mod_mem_layout", "Vale.X64.QuickCode.va_Mod_mem_heaplet", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rR10", "Vale.X64.Machine_s.rR9", "Vale.X64.Machine_s.rR8", "Vale.X64.Machine_s.rRsp", "Vale.X64.Machine_s.rRdi", "Vale.X64.Machine_s.rRsi", "Vale.X64.Machine_s.rRdx", "Vale.X64.QuickCode.va_Mod_ok", "Vale.X64.QuickCode.va_Mod_mem", "Prims.Nil", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.list", "Vale.X64.QuickCode.__proj__QProc__item__mods", "Vale.Curve25519.X64.FastUtil.va_code_Cswap2_stdcall", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.tuple3", "Vale.X64.State.vale_state", "Vale.X64.QuickCodes.va_wp_sound_code_norm", "Prims.l_and", "Vale.X64.QuickCodes.label", "Vale.X64.QuickCodes.va_range1", "Prims.b2t", "Vale.X64.Decls.va_get_ok", "Vale.Def.Words_s.nat64", "Vale.X64.Decls.va_if", "Prims.op_Equality", "Prims.int", "Prims.l_not", "Vale.X64.Decls.modifies_buffer_2", "Vale.X64.Decls.va_get_mem", "Prims.l_imp", "Vale.Def.Types_s.nat64", "Vale.X64.Decls.va_get_reg64", "Vale.X64.Decls.buffer64_read", "Vale.X64.Decls.va_int_range", "Vale.X64.QuickCode.quickCode", "Vale.Curve25519.X64.FastUtil.va_qcode_Cswap2_stdcall" ]
[]
false
false
false
false
false
let va_lemma_Cswap2_stdcall va_b0 va_s0 win bit_in p0_b p1_b =
let va_mods:va_mods_t = [ va_Mod_stackTaint; va_Mod_stack; va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRsp; va_Mod_reg64 rRdi; va_Mod_reg64 rRsi; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem ] in let va_qc = va_qcode_Cswap2_stdcall va_mods win bit_in p0_b p1_b in let va_sM, va_fM, va_g = va_wp_sound_code_norm (va_code_Cswap2_stdcall win) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 974 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_ok va_sM) /\ (let p0_in:(va_int_range 0 18446744073709551615) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let p1_in:(va_int_range 0 18446744073709551615) = va_if win (fun _ -> va_get_reg64 rR8 va_s0) (fun _ -> va_get_reg64 rRdx va_s0) in let old_p0_0:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p0_b 0 (va_get_mem va_s0) in let old_p0_1:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p0_b 1 (va_get_mem va_s0) in let old_p0_2:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p0_b 2 (va_get_mem va_s0) in let old_p0_3:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p0_b 3 (va_get_mem va_s0) in let old_p0_4:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p0_b 4 (va_get_mem va_s0) in let old_p0_5:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p0_b 5 (va_get_mem va_s0) in let old_p0_6:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p0_b 6 (va_get_mem va_s0) in let old_p0_7:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p0_b 7 (va_get_mem va_s0) in let old_p1_0:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p1_b 0 (va_get_mem va_s0) in let old_p1_1:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p1_b 1 (va_get_mem va_s0) in let old_p1_2:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p1_b 2 (va_get_mem va_s0) in let old_p1_3:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p1_b 3 (va_get_mem va_s0) in let old_p1_4:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p1_b 4 (va_get_mem va_s0) in let old_p1_5:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p1_b 5 (va_get_mem va_s0) in let old_p1_6:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p1_b 6 (va_get_mem va_s0) in let old_p1_7:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p1_b 7 (va_get_mem va_s0) in label va_range1 "***** POSTCONDITION NOT MET AT line 1021 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_0 = Vale.X64.Decls.buffer64_read p0_b 0 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1022 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_1 = Vale.X64.Decls.buffer64_read p0_b 1 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1023 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_2 = Vale.X64.Decls.buffer64_read p0_b 2 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1024 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_3 = Vale.X64.Decls.buffer64_read p0_b 3 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1025 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_4 = Vale.X64.Decls.buffer64_read p0_b 4 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1026 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_5 = Vale.X64.Decls.buffer64_read p0_b 5 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1027 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_6 = Vale.X64.Decls.buffer64_read p0_b 6 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1028 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_7 = Vale.X64.Decls.buffer64_read p0_b 7 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1030 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_0 = Vale.X64.Decls.buffer64_read p1_b 0 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1031 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_1 = Vale.X64.Decls.buffer64_read p1_b 1 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1032 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_2 = Vale.X64.Decls.buffer64_read p1_b 2 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1033 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_3 = Vale.X64.Decls.buffer64_read p1_b 3 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1034 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_4 = Vale.X64.Decls.buffer64_read p1_b 4 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1035 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_5 = Vale.X64.Decls.buffer64_read p1_b 5 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1036 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_6 = Vale.X64.Decls.buffer64_read p1_b 6 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1037 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_7 = Vale.X64.Decls.buffer64_read p1_b 7 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 1039 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_0 == va_if (bit_in = 1) (fun _ -> old_p1_0) (fun _ -> old_p0_0)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1040 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_1 == va_if (bit_in = 1) (fun _ -> old_p1_1) (fun _ -> old_p0_1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1041 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_2 == va_if (bit_in = 1) (fun _ -> old_p1_2) (fun _ -> old_p0_2)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1042 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_3 == va_if (bit_in = 1) (fun _ -> old_p1_3) (fun _ -> old_p0_3)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1043 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_4 == va_if (bit_in = 1) (fun _ -> old_p1_4) (fun _ -> old_p0_4)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1044 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_5 == va_if (bit_in = 1) (fun _ -> old_p1_5) (fun _ -> old_p0_5)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1045 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_6 == va_if (bit_in = 1) (fun _ -> old_p1_6) (fun _ -> old_p0_6)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1046 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_7 == va_if (bit_in = 1) (fun _ -> old_p1_7) (fun _ -> old_p0_7)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1048 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_0 == va_if (bit_in = 1) (fun _ -> old_p0_0) (fun _ -> old_p1_0)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1049 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_1 == va_if (bit_in = 1) (fun _ -> old_p0_1) (fun _ -> old_p1_1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1050 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_2 == va_if (bit_in = 1) (fun _ -> old_p0_2) (fun _ -> old_p1_2)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1051 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_3 == va_if (bit_in = 1) (fun _ -> old_p0_3) (fun _ -> old_p1_3)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1052 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_4 == va_if (bit_in = 1) (fun _ -> old_p0_4) (fun _ -> old_p1_4)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1053 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_5 == va_if (bit_in = 1) (fun _ -> old_p0_5) (fun _ -> old_p1_5)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1054 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_6 == va_if (bit_in = 1) (fun _ -> old_p0_6) (fun _ -> old_p1_6)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1055 column 65 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_7 == va_if (bit_in = 1) (fun _ -> old_p0_7) (fun _ -> old_p1_7)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1060 column 53 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.modifies_buffer_2 p0_b p1_b (va_get_mem va_s0) (va_get_mem va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1062 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1063 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (win ==> va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 1064 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0))))))))))))))) )))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([ va_Mod_stackTaint; va_Mod_stack; va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRsp; va_Mod_reg64 rRdi; va_Mod_reg64 rRsi; va_Mod_reg64 rRdx; va_Mod_ok; va_Mod_mem ]) va_sM va_s0; (va_sM, va_fM)
false
Vale.Curve25519.X64.FastUtil.fst
Vale.Curve25519.X64.FastUtil.va_lemma_Cswap2
val va_lemma_Cswap2 : va_b0:va_code -> va_s0:va_state -> bit_in:nat64 -> p0_b:buffer64 -> p1_b:buffer64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Cswap2 ()) va_s0 /\ va_get_ok va_s0 /\ (let (old_p0_0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 0 (va_get_mem va_s0) in let (old_p0_1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 1 (va_get_mem va_s0) in let (old_p0_2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 2 (va_get_mem va_s0) in let (old_p0_3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 3 (va_get_mem va_s0) in let (old_p0_4:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 4 (va_get_mem va_s0) in let (old_p0_5:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 5 (va_get_mem va_s0) in let (old_p0_6:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 6 (va_get_mem va_s0) in let (old_p0_7:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 7 (va_get_mem va_s0) in let (old_p1_0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 0 (va_get_mem va_s0) in let (old_p1_1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 1 (va_get_mem va_s0) in let (old_p1_2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 2 (va_get_mem va_s0) in let (old_p1_3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 3 (va_get_mem va_s0) in let (old_p1_4:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 4 (va_get_mem va_s0) in let (old_p1_5:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 5 (va_get_mem va_s0) in let (old_p1_6:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 6 (va_get_mem va_s0) in let (old_p1_7:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 7 (va_get_mem va_s0) in Vale.X64.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ bit_in == va_get_reg64 rRdi va_s0 /\ va_get_reg64 rRdi va_s0 <= 1 /\ (Vale.X64.Decls.buffers_disjoint p1_b p0_b \/ p1_b == p0_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem va_s0) (va_get_reg64 rRsi va_s0) p0_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem va_s0) (va_get_reg64 rRdx va_s0) p1_b 8 (va_get_mem_layout va_s0) Secret))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (old_p0_0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 0 (va_get_mem va_s0) in let (old_p0_1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 1 (va_get_mem va_s0) in let (old_p0_2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 2 (va_get_mem va_s0) in let (old_p0_3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 3 (va_get_mem va_s0) in let (old_p0_4:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 4 (va_get_mem va_s0) in let (old_p0_5:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 5 (va_get_mem va_s0) in let (old_p0_6:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 6 (va_get_mem va_s0) in let (old_p0_7:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 7 (va_get_mem va_s0) in let (old_p1_0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 0 (va_get_mem va_s0) in let (old_p1_1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 1 (va_get_mem va_s0) in let (old_p1_2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 2 (va_get_mem va_s0) in let (old_p1_3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 3 (va_get_mem va_s0) in let (old_p1_4:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 4 (va_get_mem va_s0) in let (old_p1_5:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 5 (va_get_mem va_s0) in let (old_p1_6:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 6 (va_get_mem va_s0) in let (old_p1_7:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 7 (va_get_mem va_s0) in Vale.X64.Decls.modifies_buffer_2 p0_b p1_b (va_get_mem va_s0) (va_get_mem va_sM) /\ (let p0_0 = Vale.X64.Decls.buffer64_read p0_b 0 (va_get_mem va_sM) in let p0_1 = Vale.X64.Decls.buffer64_read p0_b 1 (va_get_mem va_sM) in let p0_2 = Vale.X64.Decls.buffer64_read p0_b 2 (va_get_mem va_sM) in let p0_3 = Vale.X64.Decls.buffer64_read p0_b 3 (va_get_mem va_sM) in let p0_4 = Vale.X64.Decls.buffer64_read p0_b 4 (va_get_mem va_sM) in let p0_5 = Vale.X64.Decls.buffer64_read p0_b 5 (va_get_mem va_sM) in let p0_6 = Vale.X64.Decls.buffer64_read p0_b 6 (va_get_mem va_sM) in let p0_7 = Vale.X64.Decls.buffer64_read p0_b 7 (va_get_mem va_sM) in let p1_0 = Vale.X64.Decls.buffer64_read p1_b 0 (va_get_mem va_sM) in let p1_1 = Vale.X64.Decls.buffer64_read p1_b 1 (va_get_mem va_sM) in let p1_2 = Vale.X64.Decls.buffer64_read p1_b 2 (va_get_mem va_sM) in let p1_3 = Vale.X64.Decls.buffer64_read p1_b 3 (va_get_mem va_sM) in let p1_4 = Vale.X64.Decls.buffer64_read p1_b 4 (va_get_mem va_sM) in let p1_5 = Vale.X64.Decls.buffer64_read p1_b 5 (va_get_mem va_sM) in let p1_6 = Vale.X64.Decls.buffer64_read p1_b 6 (va_get_mem va_sM) in let p1_7 = Vale.X64.Decls.buffer64_read p1_b 7 (va_get_mem va_sM) in p0_0 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p1_0 else old_p0_0) /\ p0_1 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p1_1 else old_p0_1) /\ p0_2 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p1_2 else old_p0_2) /\ p0_3 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p1_3 else old_p0_3) /\ p0_4 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p1_4 else old_p0_4) /\ p0_5 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p1_5 else old_p0_5) /\ p0_6 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p1_6 else old_p0_6) /\ p0_7 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p1_7 else old_p0_7) /\ p1_0 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p0_0 else old_p1_0) /\ p1_1 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p0_1 else old_p1_1) /\ p1_2 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p0_2 else old_p1_2) /\ p1_3 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p0_3 else old_p1_3) /\ p1_4 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p0_4 else old_p1_4) /\ p1_5 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p0_5 else old_p1_5) /\ p1_6 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p0_6 else old_p1_6) /\ p1_7 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p0_7 else old_p1_7))) /\ va_state_eq va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 0 va_sM (va_update_flags va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRdi va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))
val va_lemma_Cswap2 : va_b0:va_code -> va_s0:va_state -> bit_in:nat64 -> p0_b:buffer64 -> p1_b:buffer64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Cswap2 ()) va_s0 /\ va_get_ok va_s0 /\ (let (old_p0_0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 0 (va_get_mem va_s0) in let (old_p0_1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 1 (va_get_mem va_s0) in let (old_p0_2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 2 (va_get_mem va_s0) in let (old_p0_3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 3 (va_get_mem va_s0) in let (old_p0_4:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 4 (va_get_mem va_s0) in let (old_p0_5:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 5 (va_get_mem va_s0) in let (old_p0_6:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 6 (va_get_mem va_s0) in let (old_p0_7:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 7 (va_get_mem va_s0) in let (old_p1_0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 0 (va_get_mem va_s0) in let (old_p1_1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 1 (va_get_mem va_s0) in let (old_p1_2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 2 (va_get_mem va_s0) in let (old_p1_3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 3 (va_get_mem va_s0) in let (old_p1_4:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 4 (va_get_mem va_s0) in let (old_p1_5:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 5 (va_get_mem va_s0) in let (old_p1_6:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 6 (va_get_mem va_s0) in let (old_p1_7:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 7 (va_get_mem va_s0) in Vale.X64.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ bit_in == va_get_reg64 rRdi va_s0 /\ va_get_reg64 rRdi va_s0 <= 1 /\ (Vale.X64.Decls.buffers_disjoint p1_b p0_b \/ p1_b == p0_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem va_s0) (va_get_reg64 rRsi va_s0) p0_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem va_s0) (va_get_reg64 rRdx va_s0) p1_b 8 (va_get_mem_layout va_s0) Secret))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (old_p0_0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 0 (va_get_mem va_s0) in let (old_p0_1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 1 (va_get_mem va_s0) in let (old_p0_2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 2 (va_get_mem va_s0) in let (old_p0_3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 3 (va_get_mem va_s0) in let (old_p0_4:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 4 (va_get_mem va_s0) in let (old_p0_5:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 5 (va_get_mem va_s0) in let (old_p0_6:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 6 (va_get_mem va_s0) in let (old_p0_7:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 7 (va_get_mem va_s0) in let (old_p1_0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 0 (va_get_mem va_s0) in let (old_p1_1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 1 (va_get_mem va_s0) in let (old_p1_2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 2 (va_get_mem va_s0) in let (old_p1_3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 3 (va_get_mem va_s0) in let (old_p1_4:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 4 (va_get_mem va_s0) in let (old_p1_5:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 5 (va_get_mem va_s0) in let (old_p1_6:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 6 (va_get_mem va_s0) in let (old_p1_7:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 7 (va_get_mem va_s0) in Vale.X64.Decls.modifies_buffer_2 p0_b p1_b (va_get_mem va_s0) (va_get_mem va_sM) /\ (let p0_0 = Vale.X64.Decls.buffer64_read p0_b 0 (va_get_mem va_sM) in let p0_1 = Vale.X64.Decls.buffer64_read p0_b 1 (va_get_mem va_sM) in let p0_2 = Vale.X64.Decls.buffer64_read p0_b 2 (va_get_mem va_sM) in let p0_3 = Vale.X64.Decls.buffer64_read p0_b 3 (va_get_mem va_sM) in let p0_4 = Vale.X64.Decls.buffer64_read p0_b 4 (va_get_mem va_sM) in let p0_5 = Vale.X64.Decls.buffer64_read p0_b 5 (va_get_mem va_sM) in let p0_6 = Vale.X64.Decls.buffer64_read p0_b 6 (va_get_mem va_sM) in let p0_7 = Vale.X64.Decls.buffer64_read p0_b 7 (va_get_mem va_sM) in let p1_0 = Vale.X64.Decls.buffer64_read p1_b 0 (va_get_mem va_sM) in let p1_1 = Vale.X64.Decls.buffer64_read p1_b 1 (va_get_mem va_sM) in let p1_2 = Vale.X64.Decls.buffer64_read p1_b 2 (va_get_mem va_sM) in let p1_3 = Vale.X64.Decls.buffer64_read p1_b 3 (va_get_mem va_sM) in let p1_4 = Vale.X64.Decls.buffer64_read p1_b 4 (va_get_mem va_sM) in let p1_5 = Vale.X64.Decls.buffer64_read p1_b 5 (va_get_mem va_sM) in let p1_6 = Vale.X64.Decls.buffer64_read p1_b 6 (va_get_mem va_sM) in let p1_7 = Vale.X64.Decls.buffer64_read p1_b 7 (va_get_mem va_sM) in p0_0 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p1_0 else old_p0_0) /\ p0_1 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p1_1 else old_p0_1) /\ p0_2 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p1_2 else old_p0_2) /\ p0_3 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p1_3 else old_p0_3) /\ p0_4 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p1_4 else old_p0_4) /\ p0_5 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p1_5 else old_p0_5) /\ p0_6 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p1_6 else old_p0_6) /\ p0_7 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p1_7 else old_p0_7) /\ p1_0 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p0_0 else old_p1_0) /\ p1_1 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p0_1 else old_p1_1) /\ p1_2 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p0_2 else old_p1_2) /\ p1_3 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p0_3 else old_p1_3) /\ p1_4 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p0_4 else old_p1_4) /\ p1_5 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p0_5 else old_p1_5) /\ p1_6 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p0_6 else old_p1_6) /\ p1_7 == (if (va_get_reg64 rRdi va_s0 = 1) then old_p0_7 else old_p1_7))) /\ va_state_eq va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 0 va_sM (va_update_flags va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRdi va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))
let va_lemma_Cswap2 va_b0 va_s0 bit_in p0_b p1_b = let (va_mods:va_mods_t) = [va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdi; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Cswap2 va_mods bit_in p0_b p1_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Cswap2 ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 848 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_ok va_sM) /\ (let (old_p0_0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 0 (va_get_mem va_s0) in let (old_p0_1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 1 (va_get_mem va_s0) in let (old_p0_2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 2 (va_get_mem va_s0) in let (old_p0_3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 3 (va_get_mem va_s0) in let (old_p0_4:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 4 (va_get_mem va_s0) in let (old_p0_5:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 5 (va_get_mem va_s0) in let (old_p0_6:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 6 (va_get_mem va_s0) in let (old_p0_7:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 7 (va_get_mem va_s0) in let (old_p1_0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 0 (va_get_mem va_s0) in let (old_p1_1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 1 (va_get_mem va_s0) in let (old_p1_2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 2 (va_get_mem va_s0) in let (old_p1_3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 3 (va_get_mem va_s0) in let (old_p1_4:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 4 (va_get_mem va_s0) in let (old_p1_5:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 5 (va_get_mem va_s0) in let (old_p1_6:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 6 (va_get_mem va_s0) in let (old_p1_7:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 7 (va_get_mem va_s0) in label va_range1 "***** POSTCONDITION NOT MET AT line 894 column 53 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.modifies_buffer_2 p0_b p1_b (va_get_mem va_s0) (va_get_mem va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 896 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_0 = Vale.X64.Decls.buffer64_read p0_b 0 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 897 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_1 = Vale.X64.Decls.buffer64_read p0_b 1 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 898 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_2 = Vale.X64.Decls.buffer64_read p0_b 2 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 899 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_3 = Vale.X64.Decls.buffer64_read p0_b 3 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 900 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_4 = Vale.X64.Decls.buffer64_read p0_b 4 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 901 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_5 = Vale.X64.Decls.buffer64_read p0_b 5 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 902 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_6 = Vale.X64.Decls.buffer64_read p0_b 6 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 903 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_7 = Vale.X64.Decls.buffer64_read p0_b 7 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 905 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_0 = Vale.X64.Decls.buffer64_read p1_b 0 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 906 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_1 = Vale.X64.Decls.buffer64_read p1_b 1 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 907 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_2 = Vale.X64.Decls.buffer64_read p1_b 2 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 908 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_3 = Vale.X64.Decls.buffer64_read p1_b 3 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 909 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_4 = Vale.X64.Decls.buffer64_read p1_b 4 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 910 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_5 = Vale.X64.Decls.buffer64_read p1_b 5 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 911 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_6 = Vale.X64.Decls.buffer64_read p1_b 6 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 912 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_7 = Vale.X64.Decls.buffer64_read p1_b 7 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 914 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_0 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p1_0) (fun _ -> old_p0_0)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 915 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_1 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p1_1) (fun _ -> old_p0_1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 916 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_2 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p1_2) (fun _ -> old_p0_2)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 917 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_3 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p1_3) (fun _ -> old_p0_3)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 918 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_4 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p1_4) (fun _ -> old_p0_4)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 919 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_5 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p1_5) (fun _ -> old_p0_5)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 920 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_6 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p1_6) (fun _ -> old_p0_6)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 921 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_7 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p1_7) (fun _ -> old_p0_7)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 923 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_0 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p0_0) (fun _ -> old_p1_0)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 924 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_1 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p0_1) (fun _ -> old_p1_1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 925 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_2 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p0_2) (fun _ -> old_p1_2)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 926 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_3 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p0_3) (fun _ -> old_p1_3)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 927 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_4 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p0_4) (fun _ -> old_p1_4)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 928 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_5 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p0_5) (fun _ -> old_p1_5)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 929 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_6 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p0_6) (fun _ -> old_p1_6)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 930 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_7 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p0_7) (fun _ -> old_p1_7)))))))))))))))))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdi; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM)
{ "file_name": "obj/Vale.Curve25519.X64.FastUtil.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 16, "end_line": 1982, "start_col": 0, "start_line": 1870 }
module Vale.Curve25519.X64.FastUtil open Vale.Def.Types_s open Vale.Arch.Types open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsStack open Vale.X64.QuickCode open Vale.X64.QuickCodes open FStar.Tactics open Vale.Curve25519.Fast_defs open Vale.Curve25519.Fast_lemmas_external open Vale.Curve25519.FastUtil_helpers open Vale.X64.CPU_Features_s #reset-options "--z3rlimit 60" //-- Fast_mul1 #push-options "--z3rlimit 600" val va_code_Fast_mul1 : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Fast_mul1 () = (va_Block (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Mulx64 (va_op_dst_opr64_reg64 rR9) (va_op_dst_opr64_reg64 rR8) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR8)) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Mulx64 (va_op_dst_opr64_reg64 rR11) (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_CCons (va_code_Add64Wrap (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR9)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 8 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Mulx64 (va_op_dst_opr64_reg64 rR13) (va_op_dst_opr64_reg64 rRbx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 Secret)) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR11)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRbx) 16 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Mulx64 (va_op_dst_opr64_reg64 rRax) (va_op_dst_opr64_reg64 rR14) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 Secret)) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rR13)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR14) 24 Secret) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR8)) (va_CNil ()))))))))))))))))))) val va_codegen_success_Fast_mul1 : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Fast_mul1 () = (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Mulx64 (va_op_dst_opr64_reg64 rR9) (va_op_dst_opr64_reg64 rR8) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR8)) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Mulx64 (va_op_dst_opr64_reg64 rR11) (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_pbool_and (va_codegen_success_Add64Wrap (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR9)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 8 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Mulx64 (va_op_dst_opr64_reg64 rR13) (va_op_dst_opr64_reg64 rRbx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 Secret)) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR11)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRbx) 16 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Mulx64 (va_op_dst_opr64_reg64 rRax) (va_op_dst_opr64_reg64 rR14) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 Secret)) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR14) 24 Secret) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR8)) (va_ttrue ())))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Fast_mul1 (va_mods:va_mods_t) (dst_b:buffer64) (inA_b:buffer64) : (va_quickCode unit (va_code_Fast_mul1 ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 91 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Arch.Types.xor_lemmas ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 93 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 inA_b 0 Secret) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 93 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mulx64 (va_op_dst_opr64_reg64 rR9) (va_op_dst_opr64_reg64 rR8) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (fun (va_s:va_state) _ -> let (va_arg48:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in let (va_arg47:Vale.Def.Types_s.nat64) = va_get_reg64 rR8 va_s in let (va_arg46:Vale.Def.Types_s.nat64) = va_get_reg64 rR9 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 93 column 99 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Curve25519.Fast_lemmas_external.lemma_prod_bounds va_arg46 va_arg47 va_arg48 a0) (let (old_r8:nat64) = va_get_reg64 rR8 va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 94 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 0 Secret dst_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 95 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR8)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 96 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 inA_b 1 Secret) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 96 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mulx64 (va_op_dst_opr64_reg64 rR11) (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (fun (va_s:va_state) _ -> let (va_arg45:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in let (va_arg44:Vale.Def.Types_s.nat64) = va_get_reg64 rR10 va_s in let (va_arg43:Vale.Def.Types_s.nat64) = va_get_reg64 rR11 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 96 column 99 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Curve25519.Fast_lemmas_external.lemma_prod_bounds va_arg43 va_arg44 va_arg45 a1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 97 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Add64Wrap (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR9)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 98 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 8 Secret dst_b 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 99 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 inA_b 2 Secret) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 99 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mulx64 (va_op_dst_opr64_reg64 rR13) (va_op_dst_opr64_reg64 rRbx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 Secret)) (fun (va_s:va_state) _ -> let (va_arg42:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in let (va_arg41:Vale.Def.Types_s.nat64) = va_get_reg64 rRbx va_s in let (va_arg40:Vale.Def.Types_s.nat64) = va_get_reg64 rR13 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 99 column 99 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Curve25519.Fast_lemmas_external.lemma_prod_bounds va_arg40 va_arg41 va_arg42 a2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 100 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rR11)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 101 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRbx) 16 Secret dst_b 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 102 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 inA_b 3 Secret) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 102 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mulx64 (va_op_dst_opr64_reg64 rRax) (va_op_dst_opr64_reg64 rR14) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 Secret)) (fun (va_s:va_state) _ -> let (va_arg39:Vale.Def.Types_s.nat64) = va_get_reg64 rRdx va_s in let (va_arg38:Vale.Def.Types_s.nat64) = va_get_reg64 rR14 va_s in let (va_arg37:Vale.Def.Types_s.nat64) = va_get_reg64 rRax va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 102 column 99 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Curve25519.Fast_lemmas_external.lemma_prod_bounds va_arg37 va_arg38 va_arg39 a3) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 103 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rR13)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 104 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR14) 24 Secret dst_b 3) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 105 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR8)) (fun (va_s:va_state) _ -> let (carry_bit:Vale.Curve25519.Fast_defs.bit) = Vale.Curve25519.Fast_defs.bool_bit (Vale.X64.Decls.cf (va_get_flags va_s)) in va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 108 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (carry_bit == 0) (let (va_arg36:prop) = va_mul_nat a (va_get_reg64 rRdx va_s) == 0 + Vale.Curve25519.Fast_defs.pow2_four (va_mul_nat (va_get_reg64 rRdx va_s) a0) (va_mul_nat (va_get_reg64 rRdx va_s) a1) (va_mul_nat (va_get_reg64 rRdx va_s) a2) (va_mul_nat (va_get_reg64 rRdx va_s) a3) in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 109 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> assert_by_tactic va_arg36 int_canon) (va_QEmpty (()))))))))))))))))))))))))))) val va_lemma_Fast_mul1 : va_b0:va_code -> va_s0:va_state -> dst_b:buffer64 -> inA_b:buffer64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Fast_mul1 ()) va_s0 /\ va_get_ok va_s0 /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in adx_enabled /\ bmi2_enabled /\ (Vale.X64.Decls.buffers_disjoint dst_b inA_b \/ inA_b == dst_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdi va_s0) dst_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) inA_b 4 (va_get_mem_layout va_s0) Secret))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in let d = Vale.Curve25519.Fast_defs.pow2_five d0 d1 d2 d3 (va_get_reg64 rRax va_sM) in d == va_mul_nat a (va_get_reg64 rRdx va_s0) /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM)) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))) [@"opaque_to_smt"] let va_lemma_Fast_mul1 va_b0 va_s0 dst_b inA_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Fast_mul1 va_mods dst_b inA_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Fast_mul1 ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 52 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_ok va_sM) /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in label va_range1 "***** POSTCONDITION NOT MET AT line 81 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 82 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 83 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 84 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 85 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d = Vale.Curve25519.Fast_defs.pow2_five d0 d1 d2 d3 (va_get_reg64 rRax va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 86 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (d == va_mul_nat a (va_get_reg64 rRdx va_s0)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 88 column 69 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 89 column 50 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM))))))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Fast_mul1 (dst_b:buffer64) (inA_b:buffer64) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in adx_enabled /\ bmi2_enabled /\ (Vale.X64.Decls.buffers_disjoint dst_b inA_b \/ inA_b == dst_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdi va_s0) dst_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) inA_b 4 (va_get_mem_layout va_s0) Secret) /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64) (va_x_r11:nat64) (va_x_rbx:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_heap0:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 0 va_x_heap0 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13 (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10 (va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem va_s0)))))))))) in va_get_ok va_sM /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in let d = Vale.Curve25519.Fast_defs.pow2_five d0 d1 d2 d3 (va_get_reg64 rRax va_sM) in d == va_mul_nat a (va_get_reg64 rRdx va_s0) /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM)) ==> va_k va_sM (()))) val va_wpProof_Fast_mul1 : dst_b:buffer64 -> inA_b:buffer64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Fast_mul1 dst_b inA_b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Fast_mul1 ()) ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Fast_mul1 dst_b inA_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_Fast_mul1 (va_code_Fast_mul1 ()) va_s0 dst_b inA_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Fast_mul1 (dst_b:buffer64) (inA_b:buffer64) : (va_quickCode unit (va_code_Fast_mul1 ())) = (va_QProc (va_code_Fast_mul1 ()) ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_Fast_mul1 dst_b inA_b) (va_wpProof_Fast_mul1 dst_b inA_b)) #pop-options //-- //-- Fast_add1 #push-options "--z3rlimit 600" [@ "opaque_to_smt" va_qattr] let va_code_Fast_add1 () = (va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (va_code_Comment "Clear registers to propagate the carry bit" ) (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR8)) (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9)) (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR10)) (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR11)) (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Newline ()) (va_CCons (va_code_Comment "Begin addition chain" ) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Add64Wrap (va_op_dst_opr64_reg64 rRdx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRdx) 0 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rR8) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 8 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rR9) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 16 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 24 Secret) (va_CCons (va_code_Newline ()) (va_CCons (va_code_Comment "Return the carry bit in a register" ) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_CCons (va_code_DestroyHeaplets ()) (va_CNil ()))))))))))))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Fast_add1 () = (va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and (va_codegen_success_Comment "Clear registers to propagate the carry bit" ) (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR8)) (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9)) (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR10)) (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR11)) (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_Newline ()) (va_pbool_and (va_codegen_success_Comment "Begin addition chain" ) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Add64Wrap (va_op_dst_opr64_reg64 rRdx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRdx) 0 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rR8) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 8 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rR9) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 16 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 24 Secret) (va_pbool_and (va_codegen_success_Newline ()) (va_pbool_and (va_codegen_success_Comment "Return the carry bit in a register" ) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_pbool_and (va_codegen_success_DestroyHeaplets ()) (va_ttrue ())))))))))))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Fast_add1 (va_mods:va_mods_t) (dst_b:buffer64) (inA_b:buffer64) (inB:nat64) : (va_quickCode unit (va_code_Fast_add1 ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem va_s) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem va_s) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem va_s) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem va_s) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 224 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_CreateHeaplets ([declare_buffer64 inA_b 0 Secret Immutable; declare_buffer64 dst_b 0 Secret Mutable])) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 228 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Arch.Types.xor_lemmas ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 229 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Comment "Clear registers to propagate the carry bit" ) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 230 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR8)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 231 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 232 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR10)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 233 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR11)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 234 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 236 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Newline ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 237 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Comment "Begin addition chain" ) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 238 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 inA_b 0 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 238 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Add64Wrap (va_op_dst_opr64_reg64 rRdx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 239 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRdx) 0 Secret dst_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 241 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 inA_b 1 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 241 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rR8) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 242 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 8 Secret dst_b 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 244 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 inA_b 2 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 244 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rR9) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 245 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 16 Secret dst_b 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 247 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 inA_b 3 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 247 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 248 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 24 Secret dst_b 3) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 250 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Newline ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 251 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Comment "Return the carry bit in a register" ) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 252 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR11)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 254 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_DestroyHeaplets ()) (va_QEmpty (()))))))))))))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Fast_add1 va_b0 va_s0 dst_b inA_b inB = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Fast_add1 va_mods dst_b inA_b inB in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Fast_add1 ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 182 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_ok va_sM) /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in label va_range1 "***** POSTCONDITION NOT MET AT line 215 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 216 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 217 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 218 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 219 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d = Vale.Curve25519.Fast_defs.pow2_five d0 d1 d2 d3 (va_get_reg64 rRax va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 220 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (d == a + va_get_reg64 rRdx va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 222 column 46 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.modifies_buffer dst_b (va_get_mem va_s0) (va_get_mem va_sM))))))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Fast_add1 dst_b inA_b inB va_s0 va_k = let (va_sM, va_f0) = va_lemma_Fast_add1 (va_code_Fast_add1 ()) va_s0 dst_b inA_b inB in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdx; va_Mod_reg64 rRax; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) #pop-options //-- //-- Fast_add1_stdcall #push-options "--z3rlimit 600" [@ "opaque_to_smt" va_qattr] let va_code_Fast_add1_stdcall win = (va_Block (va_CCons (va_code_Push_Secret (va_op_reg_opr64_reg64 rRdi)) (va_CCons (va_code_Push_Secret (va_op_reg_opr64_reg64 rRsi)) (va_CCons (if win then va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRsi) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR8)) (va_CNil ())))) else va_Block (va_CNil ())) (va_CCons (va_code_Fast_add1 ()) (va_CCons (va_code_Pop_Secret (va_op_dst_opr64_reg64 rRsi)) (va_CCons (va_code_Pop_Secret (va_op_dst_opr64_reg64 rRdi)) (va_CNil ())))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Fast_add1_stdcall win = (va_pbool_and (va_codegen_success_Push_Secret (va_op_reg_opr64_reg64 rRdi)) (va_pbool_and (va_codegen_success_Push_Secret (va_op_reg_opr64_reg64 rRsi)) (va_pbool_and (if win then va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRsi) (va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR8)) (va_ttrue ()))) else va_ttrue ()) (va_pbool_and (va_codegen_success_Fast_add1 ()) (va_pbool_and (va_codegen_success_Pop_Secret (va_op_dst_opr64_reg64 rRsi)) (va_pbool_and (va_codegen_success_Pop_Secret (va_op_dst_opr64_reg64 rRdi)) (va_ttrue ()))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Fast_add1_stdcall (va_mods:va_mods_t) (win:bool) (dst_b:buffer64) (inA_b:buffer64) (inB_in:nat64) : (va_quickCode unit (va_code_Fast_add1_stdcall win)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (dst_in:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s) in let (inA_in:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 323 column 16 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Push_Secret (va_op_reg_opr64_reg64 rRdi)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 324 column 16 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Push_Secret (va_op_reg_opr64_reg64 rRsi)) (fun (va_s:va_state) _ -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 327 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 328 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 329 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRsi) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 330 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR8)) (va_QEmpty (())))))) (qblock va_mods (fun (va_s:va_state) -> va_QEmpty (())))) (fun (va_s:va_state) va_g -> va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 333 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Fast_add1 dst_b inA_b inB_in) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 335 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Pop_Secret (va_op_dst_opr64_reg64 rRsi)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 336 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Pop_Secret (va_op_dst_opr64_reg64 rRdi)) (va_QEmpty (()))))))))) [@"opaque_to_smt"] let va_lemma_Fast_add1_stdcall va_b0 va_s0 win dst_b inA_b inB_in = let (va_mods:va_mods_t) = [va_Mod_stackTaint; va_Mod_stack; va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRsp; va_Mod_reg64 rRbp; va_Mod_reg64 rRdi; va_Mod_reg64 rRsi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Fast_add1_stdcall va_mods win dst_b inA_b inB_in in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Fast_add1_stdcall win) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 257 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_ok va_sM) /\ (let (dst_in:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (inA_in:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in label va_range1 "***** POSTCONDITION NOT MET AT line 284 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let a0 = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem va_s0) in label va_range1 "***** POSTCONDITION NOT MET AT line 285 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let a1 = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem va_s0) in label va_range1 "***** POSTCONDITION NOT MET AT line 286 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let a2 = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem va_s0) in label va_range1 "***** POSTCONDITION NOT MET AT line 287 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let a3 = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem va_s0) in label va_range1 "***** POSTCONDITION NOT MET AT line 289 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 290 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 291 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 292 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 294 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let a = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in label va_range1 "***** POSTCONDITION NOT MET AT line 295 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d = Vale.Curve25519.Fast_defs.pow2_five d0 d1 d2 d3 (va_get_reg64 rRax va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 297 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (d == a + inB_in) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 303 column 46 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.modifies_buffer dst_b (va_get_mem va_s0) (va_get_mem va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 306 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 307 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 308 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 309 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (win ==> va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 310 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (win ==> va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 311 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 312 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 313 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (win ==> va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 314 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (~win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 315 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (~win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 316 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (~win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 317 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (~win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 318 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (~win ==> va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 320 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0))))))))))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRsp; va_Mod_reg64 rRbp; va_Mod_reg64 rRdi; va_Mod_reg64 rRsi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Fast_add1_stdcall win dst_b inA_b inB_in va_s0 va_k = let (va_sM, va_f0) = va_lemma_Fast_add1_stdcall (va_code_Fast_add1_stdcall win) va_s0 win dst_b inA_b inB_in in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 0 va_sM (va_update_flags va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRsp va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))))))))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRsp; va_Mod_reg64 rRbp; va_Mod_reg64 rRdi; va_Mod_reg64 rRsi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) #pop-options //-- //-- Fast_sub1 #push-options "--z3rlimit 1200" val va_code_Fast_sub1 : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Fast_sub1 () = (va_Block (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsi) 0 Secret) (va_CCons (va_code_Sub64Wrap (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRsi) 8 Secret) (va_CCons (va_code_Sbb64 (va_op_dst_opr64_reg64 rR9) (va_const_opr64 0)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 8 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR10) (va_op_reg_opr64_reg64 rRsi) 16 Secret) (va_CCons (va_code_Sbb64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 0)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 16 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRsi) 24 Secret) (va_CCons (va_code_Sbb64 (va_op_dst_opr64_reg64 rR11) (va_const_opr64 0)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 24 Secret) (va_CCons (va_code_Adc64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_CNil ())))))))))))))))) val va_codegen_success_Fast_sub1 : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Fast_sub1 () = (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsi) 0 Secret) (va_pbool_and (va_codegen_success_Sub64Wrap (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRsi) 8 Secret) (va_pbool_and (va_codegen_success_Sbb64 (va_op_dst_opr64_reg64 rR9) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 8 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR10) (va_op_reg_opr64_reg64 rRsi) 16 Secret) (va_pbool_and (va_codegen_success_Sbb64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 16 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRsi) 24 Secret) (va_pbool_and (va_codegen_success_Sbb64 (va_op_dst_opr64_reg64 rR11) (va_const_opr64 0)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 24 Secret) (va_pbool_and (va_codegen_success_Adc64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_ttrue ()))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Fast_sub1 (va_mods:va_mods_t) (dst_b:buffer64) (inA_b:buffer64) : (va_quickCode unit (va_code_Fast_sub1 ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 378 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Arch.Types.xor_lemmas ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 379 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 381 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsi) 0 Secret inA_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 382 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Sub64Wrap (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 383 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 0 Secret dst_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 385 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRsi) 8 Secret inA_b 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 386 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Sbb64 (va_op_dst_opr64_reg64 rR9) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 387 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 8 Secret dst_b 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 389 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR10) (va_op_reg_opr64_reg64 rRsi) 16 Secret inA_b 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 390 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Sbb64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 0)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 391 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 16 Secret dst_b 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 393 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRsi) 24 Secret inA_b 3) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 394 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Sbb64 (va_op_dst_opr64_reg64 rR11) (va_const_opr64 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 395 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 24 Secret dst_b 3) (fun (va_s:va_state) _ -> let (c:bool) = Vale.X64.Decls.cf (va_get_flags va_s) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 398 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adc64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (fun (va_s:va_state) _ -> va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 399 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_reg64 rRax va_s == Vale.Curve25519.Fast_defs.bool_bit c) (va_QEmpty (()))))))))))))))))))) val va_lemma_Fast_sub1 : va_b0:va_code -> va_s0:va_state -> dst_b:buffer64 -> inA_b:buffer64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Fast_sub1 ()) va_s0 /\ va_get_ok va_s0 /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in (Vale.X64.Decls.buffers_disjoint dst_b inA_b \/ dst_b == inA_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdi va_s0) dst_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) inA_b 4 (va_get_mem_layout va_s0) Secret))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in let d = Vale.Curve25519.Fast_defs.pow2_four d0 d1 d2 d3 in d - va_mul_nat (va_get_reg64 rRax va_sM) pow2_256 == a - va_get_reg64 rRcx va_s0 /\ (va_get_reg64 rRax va_sM == 0 \/ va_get_reg64 rRax va_sM == 1) /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM)) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))) [@"opaque_to_smt"] let va_lemma_Fast_sub1 va_b0 va_s0 dst_b inA_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Fast_sub1 va_mods dst_b inA_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Fast_sub1 ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 339 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_ok va_sM) /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in label va_range1 "***** POSTCONDITION NOT MET AT line 367 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 368 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 369 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 370 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 371 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d = Vale.Curve25519.Fast_defs.pow2_four d0 d1 d2 d3 in label va_range1 "***** POSTCONDITION NOT MET AT line 372 column 41 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (d - va_mul_nat (va_get_reg64 rRax va_sM) pow2_256 == a - va_get_reg64 rRcx va_s0) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 373 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_reg64 rRax va_sM == 0 \/ va_get_reg64 rRax va_sM == 1) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 375 column 69 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 376 column 50 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM))))))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Fast_sub1 (dst_b:buffer64) (inA_b:buffer64) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in (Vale.X64.Decls.buffers_disjoint dst_b inA_b \/ dst_b == inA_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdi va_s0) dst_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) inA_b 4 (va_get_mem_layout va_s0) Secret) /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64) (va_x_r11:nat64) (va_x_heap0:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 0 va_x_heap0 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10 (va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem va_s0))))))) in va_get_ok va_sM /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in let d = Vale.Curve25519.Fast_defs.pow2_four d0 d1 d2 d3 in d - va_mul_nat (va_get_reg64 rRax va_sM) pow2_256 == a - va_get_reg64 rRcx va_s0 /\ (va_get_reg64 rRax va_sM == 0 \/ va_get_reg64 rRax va_sM == 1) /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM)) ==> va_k va_sM (()))) val va_wpProof_Fast_sub1 : dst_b:buffer64 -> inA_b:buffer64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Fast_sub1 dst_b inA_b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Fast_sub1 ()) ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Fast_sub1 dst_b inA_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_Fast_sub1 (va_code_Fast_sub1 ()) va_s0 dst_b inA_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Fast_sub1 (dst_b:buffer64) (inA_b:buffer64) : (va_quickCode unit (va_code_Fast_sub1 ())) = (va_QProc (va_code_Fast_sub1 ()) ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_Fast_sub1 dst_b inA_b) (va_wpProof_Fast_sub1 dst_b inA_b)) #pop-options //-- //-- Fast_add #push-options "--z3rlimit 600" val va_code_Fast_add : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Fast_add () = (va_Block (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR8)) (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Add64Wrap (va_op_dst_opr64_reg64 rR9) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 0 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR10) (va_op_reg_opr64_reg64 rRcx) 8 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 8 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRcx) 16 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rR11) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 16 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRcx) 24 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rRbx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRbx) 24 Secret) (va_CCons (va_code_Adcx64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR8)) (va_CNil ()))))))))))))))))))))) val va_codegen_success_Fast_add : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Fast_add () = (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR8)) (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRcx) 0 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Add64Wrap (va_op_dst_opr64_reg64 rR9) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 0 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR10) (va_op_reg_opr64_reg64 rRcx) 8 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 8 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRcx) 16 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rR11) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 16 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRcx) 24 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rRbx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRbx) 24 Secret) (va_pbool_and (va_codegen_success_Adcx64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR8)) (va_ttrue ())))))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Fast_add (va_mods:va_mods_t) (dst_b:buffer64) (inA_b:buffer64) (inB_b:buffer64) : (va_quickCode unit (va_code_Fast_add ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 521 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Arch.Types.xor_lemmas ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 522 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR8)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 523 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 525 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRcx) 0 Secret inB_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 526 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 inA_b 0 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 526 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Add64Wrap (va_op_dst_opr64_reg64 rR9) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 0 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 527 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 0 Secret dst_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 529 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR10) (va_op_reg_opr64_reg64 rRcx) 8 Secret inB_b 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 530 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 inA_b 1 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 530 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 8 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 531 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 8 Secret dst_b 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 533 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRcx) 16 Secret inB_b 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 534 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 inA_b 2 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 534 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rR11) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 16 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 535 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 16 Secret dst_b 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 537 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRcx) 24 Secret inB_b 3) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 538 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 inA_b 3 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 538 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rRbx) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRsi) 24 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 539 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRbx) 24 Secret dst_b 3) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 541 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adcx64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rR8)) (va_QEmpty (()))))))))))))))))))))))) val va_lemma_Fast_add : va_b0:va_code -> va_s0:va_state -> dst_b:buffer64 -> inA_b:buffer64 -> inB_b:buffer64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Fast_add ()) va_s0 /\ va_get_ok va_s0 /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in adx_enabled /\ bmi2_enabled /\ (Vale.X64.Decls.buffers_disjoint dst_b inA_b \/ dst_b == inA_b) /\ (Vale.X64.Decls.buffers_disjoint dst_b inB_b \/ dst_b == inB_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdi va_s0) dst_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) inA_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRcx va_s0) inB_b 4 (va_get_mem_layout va_s0) Secret))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in let d = Vale.Curve25519.Fast_defs.pow2_five d0 d1 d2 d3 (va_get_reg64 rRax va_sM) in d == a + b /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM)) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))) [@"opaque_to_smt"] let va_lemma_Fast_add va_b0 va_s0 dst_b inA_b inB_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Fast_add va_mods dst_b inA_b inB_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Fast_add ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 474 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_ok va_sM) /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in label va_range1 "***** POSTCONDITION NOT MET AT line 511 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 512 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 513 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 514 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 515 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d = Vale.Curve25519.Fast_defs.pow2_five d0 d1 d2 d3 (va_get_reg64 rRax va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 516 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (d == a + b) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 518 column 69 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 519 column 50 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM))))))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Fast_add (dst_b:buffer64) (inA_b:buffer64) (inB_b:buffer64) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in adx_enabled /\ bmi2_enabled /\ (Vale.X64.Decls.buffers_disjoint dst_b inA_b \/ dst_b == inA_b) /\ (Vale.X64.Decls.buffers_disjoint dst_b inB_b \/ dst_b == inB_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdi va_s0) dst_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) inA_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRcx va_s0) inB_b 4 (va_get_mem_layout va_s0) Secret) /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64) (va_x_r11:nat64) (va_x_rbx:nat64) (va_x_heap0:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 0 va_x_heap0 (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10 (va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem va_s0)))))))) in va_get_ok va_sM /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in let d = Vale.Curve25519.Fast_defs.pow2_five d0 d1 d2 d3 (va_get_reg64 rRax va_sM) in d == a + b /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM)) ==> va_k va_sM (()))) val va_wpProof_Fast_add : dst_b:buffer64 -> inA_b:buffer64 -> inB_b:buffer64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Fast_add dst_b inA_b inB_b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Fast_add ()) ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Fast_add dst_b inA_b inB_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_Fast_add (va_code_Fast_add ()) va_s0 dst_b inA_b inB_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Fast_add (dst_b:buffer64) (inA_b:buffer64) (inB_b:buffer64) : (va_quickCode unit (va_code_Fast_add ())) = (va_QProc (va_code_Fast_add ()) ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rRbx; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_Fast_add dst_b inA_b inB_b) (va_wpProof_Fast_add dst_b inA_b inB_b)) #pop-options //-- //-- Fast_sub #push-options "--z3rlimit 600" val va_code_Fast_sub : va_dummy:unit -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Fast_sub () = (va_Block (va_CCons (va_code_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsi) 0 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Sub64Wrap (va_op_dst_opr64_reg64 rR8) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 0 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRsi) 8 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Sbb64 (va_op_dst_opr64_reg64 rR9) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 8 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 8 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR10) (va_op_reg_opr64_reg64 rRsi) 16 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Sbb64 (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 16 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 16 Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRsi) 24 Secret) (va_CCons (va_code_Mem64_lemma ()) (va_CCons (va_code_Sbb64 (va_op_dst_opr64_reg64 rR11) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 24 Secret)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 24 Secret) (va_CCons (va_code_Adc64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_CNil ())))))))))))))))))))) val va_codegen_success_Fast_sub : va_dummy:unit -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Fast_sub () = (va_pbool_and (va_codegen_success_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsi) 0 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Sub64Wrap (va_op_dst_opr64_reg64 rR8) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 0 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 0 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRsi) 8 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Sbb64 (va_op_dst_opr64_reg64 rR9) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 8 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 8 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR10) (va_op_reg_opr64_reg64 rRsi) 16 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Sbb64 (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 16 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 16 Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRsi) 24 Secret) (va_pbool_and (va_codegen_success_Mem64_lemma ()) (va_pbool_and (va_codegen_success_Sbb64 (va_op_dst_opr64_reg64 rR11) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 24 Secret)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 24 Secret) (va_pbool_and (va_codegen_success_Adc64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_ttrue ()))))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Fast_sub (va_mods:va_mods_t) (dst_b:buffer64) (inA_b:buffer64) (inB_b:buffer64) : (va_quickCode unit (va_code_Fast_sub ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 674 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Arch.Types.xor_lemmas ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 677 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Xor64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 679 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsi) 0 Secret inA_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 680 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 0 inB_b 0 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 680 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Sub64Wrap (va_op_dst_opr64_reg64 rR8) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 0 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 681 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR8) 0 Secret dst_b 0) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 685 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRsi) 8 Secret inA_b 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 686 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 8 inB_b 1 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 686 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Sbb64 (va_op_dst_opr64_reg64 rR9) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 8 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 687 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR9) 8 Secret dst_b 1) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 691 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR10) (va_op_reg_opr64_reg64 rRsi) 16 Secret inA_b 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 692 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 16 inB_b 2 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 692 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Sbb64 (va_op_dst_opr64_reg64 rR10) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 16 Secret)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 694 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR10) 16 Secret dst_b 2) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 696 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR11) (va_op_reg_opr64_reg64 rRsi) 24 Secret inA_b 3) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 697 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mem64_lemma (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 24 inB_b 3 Secret) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 697 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Sbb64 (va_op_dst_opr64_reg64 rR11) (va_opr_code_Mem64 (va_op_heaplet_mem_heaplet 0) (va_op_reg64_reg64 rRcx) 24 Secret)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 698 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rR11) 24 Secret dst_b 3) (fun (va_s:va_state) _ -> let (c:bool) = Vale.X64.Decls.cf (va_get_flags va_s) in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 701 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Adc64Wrap (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRax)) (fun (va_s:va_state) _ -> va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 702 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_reg64 rRax va_s == Vale.Curve25519.Fast_defs.bool_bit c) (let (va_arg41:Vale.Curve25519.Fast_defs.bit) = Vale.Curve25519.Fast_defs.bool_bit c in let (va_arg40:Vale.Def.Types_s.nat64) = va_get_reg64 rR11 va_s in let (va_arg39:Vale.Def.Types_s.nat64) = va_get_reg64 rR10 va_s in let (va_arg38:Vale.Def.Types_s.nat64) = va_get_reg64 rR9 va_s in let (va_arg37:Vale.Def.Types_s.nat64) = va_get_reg64 rR8 va_s in va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 704 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (fun (_:unit) -> Vale.Curve25519.FastUtil_helpers.lemma_sub a a0 a1 a2 a3 b b0 b1 b2 b3 va_arg37 va_arg38 va_arg39 va_arg40 va_arg41) (va_QEmpty (())))))))))))))))))))))))) val va_lemma_Fast_sub : va_b0:va_code -> va_s0:va_state -> dst_b:buffer64 -> inA_b:buffer64 -> inB_b:buffer64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Fast_sub ()) va_s0 /\ va_get_ok va_s0 /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in (Vale.X64.Decls.buffers_disjoint dst_b inA_b \/ dst_b == inA_b) /\ (Vale.X64.Decls.buffers_disjoint dst_b inB_b \/ dst_b == inB_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdi va_s0) dst_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) inA_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRcx va_s0) inB_b 4 (va_get_mem_layout va_s0) Secret))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in let d = Vale.Curve25519.Fast_defs.pow2_four d0 d1 d2 d3 in d - va_mul_nat (va_get_reg64 rRax va_sM) pow2_256 == a - b /\ (va_get_reg64 rRax va_sM == 0 \/ va_get_reg64 rRax va_sM == 1) /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM)) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))) [@"opaque_to_smt"] let va_lemma_Fast_sub va_b0 va_s0 dst_b inA_b inB_b = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Fast_sub va_mods dst_b inA_b inB_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Fast_sub ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 627 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_ok va_sM) /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in label va_range1 "***** POSTCONDITION NOT MET AT line 663 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 664 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 665 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 666 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 667 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let d = Vale.Curve25519.Fast_defs.pow2_four d0 d1 d2 d3 in label va_range1 "***** POSTCONDITION NOT MET AT line 668 column 41 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (d - va_mul_nat (va_get_reg64 rRax va_sM) pow2_256 == a - b) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 669 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_reg64 rRax va_sM == 0 \/ va_get_reg64 rRax va_sM == 1) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 671 column 69 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 672 column 50 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM))))))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Fast_sub (dst_b:buffer64) (inA_b:buffer64) (inB_b:buffer64) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in (Vale.X64.Decls.buffers_disjoint dst_b inA_b \/ dst_b == inA_b) /\ (Vale.X64.Decls.buffers_disjoint dst_b inB_b \/ dst_b == inB_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdi va_s0) dst_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) inA_b 4 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRcx va_s0) inB_b 4 (va_get_mem_layout va_s0) Secret) /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64) (va_x_r11:nat64) (va_x_heap0:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 0 va_x_heap0 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10 (va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem va_s0))))))) in va_get_ok va_sM /\ (let (a0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 0 (va_get_mem_heaplet 0 va_s0) in let (a1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 1 (va_get_mem_heaplet 0 va_s0) in let (a2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 2 (va_get_mem_heaplet 0 va_s0) in let (a3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inA_b 3 (va_get_mem_heaplet 0 va_s0) in let (b0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 0 (va_get_mem_heaplet 0 va_s0) in let (b1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 1 (va_get_mem_heaplet 0 va_s0) in let (b2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 2 (va_get_mem_heaplet 0 va_s0) in let (b3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read inB_b 3 (va_get_mem_heaplet 0 va_s0) in let (a:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four a0 a1 a2 a3 in let (b:Prims.nat) = Vale.Curve25519.Fast_defs.pow2_four b0 b1 b2 b3 in let d0 = Vale.X64.Decls.buffer64_read dst_b 0 (va_get_mem_heaplet 0 va_sM) in let d1 = Vale.X64.Decls.buffer64_read dst_b 1 (va_get_mem_heaplet 0 va_sM) in let d2 = Vale.X64.Decls.buffer64_read dst_b 2 (va_get_mem_heaplet 0 va_sM) in let d3 = Vale.X64.Decls.buffer64_read dst_b 3 (va_get_mem_heaplet 0 va_sM) in let d = Vale.Curve25519.Fast_defs.pow2_four d0 d1 d2 d3 in d - va_mul_nat (va_get_reg64 rRax va_sM) pow2_256 == a - b /\ (va_get_reg64 rRax va_sM == 0 \/ va_get_reg64 rRax va_sM == 1) /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdi va_sM) dst_b 4 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer dst_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM)) ==> va_k va_sM (()))) val va_wpProof_Fast_sub : dst_b:buffer64 -> inA_b:buffer64 -> inB_b:buffer64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Fast_sub dst_b inA_b inB_b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Fast_sub ()) ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Fast_sub dst_b inA_b inB_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_Fast_sub (va_code_Fast_sub ()) va_s0 dst_b inA_b inB_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Fast_sub (dst_b:buffer64) (inA_b:buffer64) (inB_b:buffer64) : (va_quickCode unit (va_code_Fast_sub ())) = (va_QProc (va_code_Fast_sub ()) ([va_Mod_flags; va_Mod_mem_heaplet 0; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_Fast_sub dst_b inA_b inB_b) (va_wpProof_Fast_sub dst_b inA_b inB_b)) #pop-options //-- //-- Cswap_single val va_code_Cswap_single : offset:nat -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Cswap_single offset = (va_Block (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsi) (0 + offset `op_Multiply` 8) Secret) (va_CCons (va_code_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRdx) (0 + offset `op_Multiply` 8) Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR8)) (va_CCons (va_code_Cmovc64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR9)) (va_CCons (va_code_Cmovc64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR10)) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rR8) (0 + offset `op_Multiply` 8) Secret) (va_CCons (va_code_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rR9) (0 + offset `op_Multiply` 8) Secret) (va_CNil ()))))))))) val va_codegen_success_Cswap_single : offset:nat -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Cswap_single offset = (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsi) (0 + offset `op_Multiply` 8) Secret) (va_pbool_and (va_codegen_success_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRdx) (0 + offset `op_Multiply` 8) Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR8)) (va_pbool_and (va_codegen_success_Cmovc64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR9)) (va_pbool_and (va_codegen_success_Cmovc64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR10)) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rR8) (0 + offset `op_Multiply` 8) Secret) (va_pbool_and (va_codegen_success_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rR9) (0 + offset `op_Multiply` 8) Secret) (va_ttrue ())))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Cswap_single (va_mods:va_mods_t) (offset:nat) (p0_b:buffer64) (p1_b:buffer64) : (va_quickCode unit (va_code_Cswap_single offset)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (old_p0_val:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b (0 + offset) (va_get_mem_heaplet 0 va_s) in let (old_p1_val:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b (0 + offset) (va_get_mem_heaplet 0 va_s) in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 839 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsi) (0 + offset `op_Multiply` 8) Secret p0_b (0 + offset)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 840 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Load64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRdx) (0 + offset `op_Multiply` 8) Secret p1_b (0 + offset)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 841 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR8)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 842 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Cmovc64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rR9)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 843 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Cmovc64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR10)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 844 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rR8) (0 + offset `op_Multiply` 8) Secret p0_b (0 + offset)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 845 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Store64_buffer (va_op_heaplet_mem_heaplet 0) (va_op_reg_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rR9) (0 + offset `op_Multiply` 8) Secret p1_b (0 + offset)) (va_QEmpty (())))))))))) val va_lemma_Cswap_single : va_b0:va_code -> va_s0:va_state -> offset:nat -> p0_b:buffer64 -> p1_b:buffer64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Cswap_single offset) va_s0 /\ va_get_ok va_s0 /\ (let (old_p0_val:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b (0 + offset) (va_get_mem_heaplet 0 va_s0) in let (old_p1_val:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b (0 + offset) (va_get_mem_heaplet 0 va_s0) in offset < 8 /\ (Vale.X64.Decls.buffers_disjoint p1_b p0_b \/ p1_b == p0_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) p0_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdx va_s0) p1_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.valid_cf (va_get_flags va_s0)))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (old_p0_val:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b (0 + offset) (va_get_mem_heaplet 0 va_s0) in let (old_p1_val:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b (0 + offset) (va_get_mem_heaplet 0 va_s0) in Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRsi va_sM) p0_b 8 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdx va_sM) p1_b 8 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer_2 p0_b p1_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM) /\ (forall (i:nat) . 0 <= i /\ i < 8 /\ i =!= offset ==> Vale.X64.Decls.buffer64_read p0_b i (va_get_mem_heaplet 0 va_sM) == Vale.X64.Decls.buffer64_read p0_b i (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.buffer64_read p1_b i (va_get_mem_heaplet 0 va_sM) == Vale.X64.Decls.buffer64_read p1_b i (va_get_mem_heaplet 0 va_s0)) /\ (let p0_val = Vale.X64.Decls.buffer64_read p0_b (0 + offset) (va_get_mem_heaplet 0 va_sM) in let p1_val = Vale.X64.Decls.buffer64_read p1_b (0 + offset) (va_get_mem_heaplet 0 va_sM) in p0_val == (if Vale.X64.Decls.cf (va_get_flags va_sM) then old_p1_val else old_p0_val) /\ p1_val == (if Vale.X64.Decls.cf (va_get_flags va_sM) then old_p0_val else old_p1_val))) /\ va_state_eq va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))) [@"opaque_to_smt"] let va_lemma_Cswap_single va_b0 va_s0 offset p0_b p1_b = let (va_mods:va_mods_t) = [va_Mod_mem_heaplet 0; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Cswap_single va_mods offset p0_b p1_b in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Cswap_single offset) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 792 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_ok va_sM) /\ (let (old_p0_val:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b (0 + offset) (va_get_mem_heaplet 0 va_s0) in let (old_p1_val:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b (0 + offset) (va_get_mem_heaplet 0 va_s0) in label va_range1 "***** POSTCONDITION NOT MET AT line 821 column 67 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRsi va_sM) p0_b 8 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 822 column 67 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdx va_sM) p1_b 8 (va_get_mem_layout va_sM) Secret) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 824 column 57 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.modifies_buffer_2 p0_b p1_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 832 column 59 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (forall (i:nat) . 0 <= i /\ i < 8 /\ i =!= offset ==> Vale.X64.Decls.buffer64_read p0_b i (va_get_mem_heaplet 0 va_sM) == Vale.X64.Decls.buffer64_read p0_b i (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.buffer64_read p1_b i (va_get_mem_heaplet 0 va_sM) == Vale.X64.Decls.buffer64_read p1_b i (va_get_mem_heaplet 0 va_s0)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 834 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_val = Vale.X64.Decls.buffer64_read p0_b (0 + offset) (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 835 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_val = Vale.X64.Decls.buffer64_read p1_b (0 + offset) (va_get_mem_heaplet 0 va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 836 column 63 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_val == va_if (Vale.X64.Decls.cf (va_get_flags va_sM)) (fun _ -> old_p1_val) (fun _ -> old_p0_val)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 837 column 63 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_val == va_if (Vale.X64.Decls.cf (va_get_flags va_sM)) (fun _ -> old_p0_val) (fun _ -> old_p1_val)))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_mem_heaplet 0; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Cswap_single (offset:nat) (p0_b:buffer64) (p1_b:buffer64) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (let (old_p0_val:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b (0 + offset) (va_get_mem_heaplet 0 va_s0) in let (old_p1_val:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b (0 + offset) (va_get_mem_heaplet 0 va_s0) in offset < 8 /\ (Vale.X64.Decls.buffers_disjoint p1_b p0_b \/ p1_b == p0_b) /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRsi va_s0) p0_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs64 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rRdx va_s0) p1_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.valid_cf (va_get_flags va_s0)) /\ (forall (va_x_mem:vale_heap) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64) (va_x_heap0:vale_heap) . let va_sM = va_upd_mem_heaplet 0 va_x_heap0 (va_upd_reg64 rR10 va_x_r10 (va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_mem va_x_mem va_s0)))) in va_get_ok va_sM /\ (let (old_p0_val:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b (0 + offset) (va_get_mem_heaplet 0 va_s0) in let (old_p1_val:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b (0 + offset) (va_get_mem_heaplet 0 va_s0) in Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRsi va_sM) p0_b 8 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.validSrcAddrs64 (va_get_mem_heaplet 0 va_sM) (va_get_reg64 rRdx va_sM) p1_b 8 (va_get_mem_layout va_sM) Secret /\ Vale.X64.Decls.modifies_buffer_2 p0_b p1_b (va_get_mem_heaplet 0 va_s0) (va_get_mem_heaplet 0 va_sM) /\ (forall (i:nat) . 0 <= i /\ i < 8 /\ i =!= offset ==> Vale.X64.Decls.buffer64_read p0_b i (va_get_mem_heaplet 0 va_sM) == Vale.X64.Decls.buffer64_read p0_b i (va_get_mem_heaplet 0 va_s0) /\ Vale.X64.Decls.buffer64_read p1_b i (va_get_mem_heaplet 0 va_sM) == Vale.X64.Decls.buffer64_read p1_b i (va_get_mem_heaplet 0 va_s0)) /\ (let p0_val = Vale.X64.Decls.buffer64_read p0_b (0 + offset) (va_get_mem_heaplet 0 va_sM) in let p1_val = Vale.X64.Decls.buffer64_read p1_b (0 + offset) (va_get_mem_heaplet 0 va_sM) in p0_val == va_if (Vale.X64.Decls.cf (va_get_flags va_sM)) (fun _ -> old_p1_val) (fun _ -> old_p0_val) /\ p1_val == va_if (Vale.X64.Decls.cf (va_get_flags va_sM)) (fun _ -> old_p0_val) (fun _ -> old_p1_val))) ==> va_k va_sM (()))) val va_wpProof_Cswap_single : offset:nat -> p0_b:buffer64 -> p1_b:buffer64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Cswap_single offset p0_b p1_b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Cswap_single offset) ([va_Mod_mem_heaplet 0; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Cswap_single offset p0_b p1_b va_s0 va_k = let (va_sM, va_f0) = va_lemma_Cswap_single (va_code_Cswap_single offset) va_s0 offset p0_b p1_b in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_mem_heaplet 0 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))); va_lemma_norm_mods ([va_Mod_mem_heaplet 0; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Cswap_single (offset:nat) (p0_b:buffer64) (p1_b:buffer64) : (va_quickCode unit (va_code_Cswap_single offset)) = (va_QProc (va_code_Cswap_single offset) ([va_Mod_mem_heaplet 0; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_mem]) (va_wp_Cswap_single offset p0_b p1_b) (va_wpProof_Cswap_single offset p0_b p1_b)) //-- //-- Cswap2 [@ "opaque_to_smt" va_qattr] let va_code_Cswap2 () = (va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (va_code_Comment "Transfer bit into CF flag" ) (va_CCons (va_code_Add64Wrap (va_op_dst_opr64_reg64 rRdi) (va_const_opr64 18446744073709551615)) (va_CCons (va_code_Newline ()) (va_CCons (va_code_Comment "cswap p1[0], p2[0]" ) (va_CCons (va_code_Cswap_single 0) (va_CCons (va_code_Newline ()) (va_CCons (va_code_Comment "cswap p1[1], p2[1]" ) (va_CCons (va_code_Cswap_single 1) (va_CCons (va_code_Newline ()) (va_CCons (va_code_Comment "cswap p1[2], p2[2]" ) (va_CCons (va_code_Cswap_single 2) (va_CCons (va_code_Newline ()) (va_CCons (va_code_Comment "cswap p1[3], p2[3]" ) (va_CCons (va_code_Cswap_single 3) (va_CCons (va_code_Newline ()) (va_CCons (va_code_Comment "cswap p1[4], p2[4]" ) (va_CCons (va_code_Cswap_single 4) (va_CCons (va_code_Newline ()) (va_CCons (va_code_Comment "cswap p1[5], p2[5]" ) (va_CCons (va_code_Cswap_single 5) (va_CCons (va_code_Newline ()) (va_CCons (va_code_Comment "cswap p1[6], p2[6]" ) (va_CCons (va_code_Cswap_single 6) (va_CCons (va_code_Newline ()) (va_CCons (va_code_Comment "cswap p1[7], p2[7]" ) (va_CCons (va_code_Cswap_single 7) (va_CCons (va_code_DestroyHeaplets ()) (va_CNil ())))))))))))))))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_codegen_success_Cswap2 () = (va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and (va_codegen_success_Comment "Transfer bit into CF flag" ) (va_pbool_and (va_codegen_success_Add64Wrap (va_op_dst_opr64_reg64 rRdi) (va_const_opr64 18446744073709551615)) (va_pbool_and (va_codegen_success_Newline ()) (va_pbool_and (va_codegen_success_Comment "cswap p1[0], p2[0]" ) (va_pbool_and (va_codegen_success_Cswap_single 0) (va_pbool_and (va_codegen_success_Newline ()) (va_pbool_and (va_codegen_success_Comment "cswap p1[1], p2[1]" ) (va_pbool_and (va_codegen_success_Cswap_single 1) (va_pbool_and (va_codegen_success_Newline ()) (va_pbool_and (va_codegen_success_Comment "cswap p1[2], p2[2]" ) (va_pbool_and (va_codegen_success_Cswap_single 2) (va_pbool_and (va_codegen_success_Newline ()) (va_pbool_and (va_codegen_success_Comment "cswap p1[3], p2[3]" ) (va_pbool_and (va_codegen_success_Cswap_single 3) (va_pbool_and (va_codegen_success_Newline ()) (va_pbool_and (va_codegen_success_Comment "cswap p1[4], p2[4]" ) (va_pbool_and (va_codegen_success_Cswap_single 4) (va_pbool_and (va_codegen_success_Newline ()) (va_pbool_and (va_codegen_success_Comment "cswap p1[5], p2[5]" ) (va_pbool_and (va_codegen_success_Cswap_single 5) (va_pbool_and (va_codegen_success_Newline ()) (va_pbool_and (va_codegen_success_Comment "cswap p1[6], p2[6]" ) (va_pbool_and (va_codegen_success_Cswap_single 6) (va_pbool_and (va_codegen_success_Newline ()) (va_pbool_and (va_codegen_success_Comment "cswap p1[7], p2[7]" ) (va_pbool_and (va_codegen_success_Cswap_single 7) (va_pbool_and (va_codegen_success_DestroyHeaplets ()) (va_ttrue ()))))))))))))))))))))))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Cswap2 (va_mods:va_mods_t) (bit_in:nat64) (p0_b:buffer64) (p1_b:buffer64) : (va_quickCode unit (va_code_Cswap2 ())) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (old_p0_0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 0 (va_get_mem va_s) in let (old_p0_1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 1 (va_get_mem va_s) in let (old_p0_2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 2 (va_get_mem va_s) in let (old_p0_3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 3 (va_get_mem va_s) in let (old_p0_4:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 4 (va_get_mem va_s) in let (old_p0_5:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 5 (va_get_mem va_s) in let (old_p0_6:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 6 (va_get_mem va_s) in let (old_p0_7:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p0_b 7 (va_get_mem va_s) in let (old_p1_0:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 0 (va_get_mem va_s) in let (old_p1_1:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 1 (va_get_mem va_s) in let (old_p1_2:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 2 (va_get_mem va_s) in let (old_p1_3:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 3 (va_get_mem va_s) in let (old_p1_4:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 4 (va_get_mem va_s) in let (old_p1_5:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 5 (va_get_mem va_s) in let (old_p1_6:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 6 (va_get_mem va_s) in let (old_p1_7:Vale.Def.Types_s.nat64) = Vale.X64.Decls.buffer64_read p1_b 7 (va_get_mem va_s) in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 932 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_CreateHeaplets ([declare_buffer64 p0_b 0 Secret Mutable; declare_buffer64 p1_b 0 Secret Mutable])) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 936 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Comment "Transfer bit into CF flag" ) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 937 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Add64Wrap (va_op_dst_opr64_reg64 rRdi) (va_const_opr64 18446744073709551615)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 939 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Newline ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 940 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Comment "cswap p1[0], p2[0]" ) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 941 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Cswap_single 0 p0_b p1_b) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 943 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Newline ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 944 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Comment "cswap p1[1], p2[1]" ) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 945 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Cswap_single 1 p0_b p1_b) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 947 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Newline ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 948 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Comment "cswap p1[2], p2[2]" ) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 949 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Cswap_single 2 p0_b p1_b) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 951 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Newline ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 952 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Comment "cswap p1[3], p2[3]" ) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 953 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Cswap_single 3 p0_b p1_b) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 955 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Newline ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 956 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Comment "cswap p1[4], p2[4]" ) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 957 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Cswap_single 4 p0_b p1_b) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 959 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Newline ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 960 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Comment "cswap p1[5], p2[5]" ) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 961 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Cswap_single 5 p0_b p1_b) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 963 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Newline ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 964 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Comment "cswap p1[6], p2[6]" ) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 965 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Cswap_single 6 p0_b p1_b) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 967 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Newline ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 968 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Comment "cswap p1[7], p2[7]" ) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 969 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_Cswap_single 7 p0_b p1_b) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 971 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_quick_DestroyHeaplets ()) (va_QEmpty (())))))))))))))))))))))))))))))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsStack.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.FastUtil_helpers.fsti.checked", "Vale.Curve25519.Fast_lemmas_external.fsti.checked", "Vale.Curve25519.Fast_defs.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.Curve25519.X64.FastUtil.fst" }
[ { "abbrev": false, "full_module": "Vale.Curve25519.FastUtil_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_lemmas_external", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 60, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> bit_in: Vale.X64.Memory.nat64 -> p0_b: Vale.X64.Memory.buffer64 -> p1_b: Vale.X64.Memory.buffer64 -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
Prims.Ghost
[]
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Vale.X64.Memory.nat64", "Vale.X64.Memory.buffer64", "Vale.X64.QuickCodes.fuel", "Prims.unit", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_fuel", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_mem_layout", "Vale.X64.QuickCode.va_Mod_mem_heaplet", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rR10", "Vale.X64.Machine_s.rR9", "Vale.X64.Machine_s.rR8", "Vale.X64.Machine_s.rRdi", "Vale.X64.QuickCode.va_Mod_ok", "Vale.X64.QuickCode.va_Mod_mem", "Prims.Nil", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.list", "Vale.X64.QuickCode.__proj__QProc__item__mods", "Vale.Curve25519.X64.FastUtil.va_code_Cswap2", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.tuple3", "Vale.X64.State.vale_state", "Vale.X64.QuickCodes.va_wp_sound_code_norm", "Prims.l_and", "Vale.X64.QuickCodes.label", "Vale.X64.QuickCodes.va_range1", "Prims.b2t", "Vale.X64.Decls.va_get_ok", "Vale.X64.Decls.modifies_buffer_2", "Vale.X64.Decls.va_get_mem", "Vale.Def.Words_s.nat64", "Vale.X64.Decls.va_if", "Prims.op_Equality", "Prims.int", "Vale.X64.Decls.va_get_reg64", "Prims.l_not", "Vale.X64.Decls.buffer64_read", "Vale.X64.QuickCode.quickCode", "Vale.Curve25519.X64.FastUtil.va_qcode_Cswap2" ]
[]
false
false
false
false
false
let va_lemma_Cswap2 va_b0 va_s0 bit_in p0_b p1_b =
let va_mods:va_mods_t = [ va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdi; va_Mod_ok; va_Mod_mem ] in let va_qc = va_qcode_Cswap2 va_mods bit_in p0_b p1_b in let va_sM, va_fM, va_g = va_wp_sound_code_norm (va_code_Cswap2 ()) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 848 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (va_get_ok va_sM) /\ (let old_p0_0:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p0_b 0 (va_get_mem va_s0) in let old_p0_1:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p0_b 1 (va_get_mem va_s0) in let old_p0_2:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p0_b 2 (va_get_mem va_s0) in let old_p0_3:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p0_b 3 (va_get_mem va_s0) in let old_p0_4:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p0_b 4 (va_get_mem va_s0) in let old_p0_5:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p0_b 5 (va_get_mem va_s0) in let old_p0_6:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p0_b 6 (va_get_mem va_s0) in let old_p0_7:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p0_b 7 (va_get_mem va_s0) in let old_p1_0:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p1_b 0 (va_get_mem va_s0) in let old_p1_1:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p1_b 1 (va_get_mem va_s0) in let old_p1_2:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p1_b 2 (va_get_mem va_s0) in let old_p1_3:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p1_b 3 (va_get_mem va_s0) in let old_p1_4:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p1_b 4 (va_get_mem va_s0) in let old_p1_5:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p1_b 5 (va_get_mem va_s0) in let old_p1_6:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p1_b 6 (va_get_mem va_s0) in let old_p1_7:Vale.Def.Types_s.nat64 = Vale.X64.Decls.buffer64_read p1_b 7 (va_get_mem va_s0) in label va_range1 "***** POSTCONDITION NOT MET AT line 894 column 53 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (Vale.X64.Decls.modifies_buffer_2 p0_b p1_b (va_get_mem va_s0) (va_get_mem va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 896 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_0 = Vale.X64.Decls.buffer64_read p0_b 0 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 897 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_1 = Vale.X64.Decls.buffer64_read p0_b 1 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 898 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_2 = Vale.X64.Decls.buffer64_read p0_b 2 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 899 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_3 = Vale.X64.Decls.buffer64_read p0_b 3 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 900 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_4 = Vale.X64.Decls.buffer64_read p0_b 4 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 901 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_5 = Vale.X64.Decls.buffer64_read p0_b 5 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 902 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_6 = Vale.X64.Decls.buffer64_read p0_b 6 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 903 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p0_7 = Vale.X64.Decls.buffer64_read p0_b 7 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 905 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_0 = Vale.X64.Decls.buffer64_read p1_b 0 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 906 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_1 = Vale.X64.Decls.buffer64_read p1_b 1 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 907 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_2 = Vale.X64.Decls.buffer64_read p1_b 2 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 908 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_3 = Vale.X64.Decls.buffer64_read p1_b 3 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 909 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_4 = Vale.X64.Decls.buffer64_read p1_b 4 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 910 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_5 = Vale.X64.Decls.buffer64_read p1_b 5 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 911 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_6 = Vale.X64.Decls.buffer64_read p1_b 6 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 912 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (let p1_7 = Vale.X64.Decls.buffer64_read p1_b 7 (va_get_mem va_sM) in label va_range1 "***** POSTCONDITION NOT MET AT line 914 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_0 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p1_0) (fun _ -> old_p0_0)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 915 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_1 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p1_1) (fun _ -> old_p0_1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 916 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_2 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p1_2) (fun _ -> old_p0_2)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 917 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_3 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p1_3) (fun _ -> old_p0_3)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 918 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_4 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p1_4) (fun _ -> old_p0_4)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 919 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_5 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p1_5) (fun _ -> old_p0_5)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 920 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_6 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p1_6) (fun _ -> old_p0_6)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 921 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p0_7 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p1_7) (fun _ -> old_p0_7)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 923 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_0 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p0_0) (fun _ -> old_p1_0)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 924 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_1 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p0_1) (fun _ -> old_p1_1)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 925 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_2 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p0_2) (fun _ -> old_p1_2)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 926 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_3 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p0_3) (fun _ -> old_p1_3)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 927 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_4 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p0_4) (fun _ -> old_p1_4)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 928 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_5 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p0_5) (fun _ -> old_p1_5)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 929 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_6 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p0_6) (fun _ -> old_p1_6)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 930 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/thirdPartyPorts/rfc7748/curve25519/x64/Vale.Curve25519.X64.FastUtil.vaf *****" (p1_7 == va_if (va_get_reg64 rRdi va_s0 = 1) (fun _ -> old_p0_7) (fun _ -> old_p1_7)) )))))))))))))))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([ va_Mod_mem_layout; va_Mod_mem_heaplet 0; va_Mod_flags; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRdi; va_Mod_ok; va_Mod_mem ]) va_sM va_s0; (va_sM, va_fM)
false
Pulse.JoinComp.fst
Pulse.JoinComp.compute_iname_join
val compute_iname_join (is1 is2: term) : term
val compute_iname_join (is1 is2: term) : term
let compute_iname_join (is1 is2 : term) : term = tm_join_inames is1 is2
{ "file_name": "lib/steel/pulse/Pulse.JoinComp.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 24, "end_line": 34, "start_col": 0, "start_line": 33 }
(* 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.JoinComp open Pulse.Syntax open Pulse.Typing open Pulse.Typing.Combinators open Pulse.Checker.Pure open Pulse.Checker.Base open Pulse.Checker.Prover module T = FStar.Tactics.V2 module P = Pulse.Syntax.Printer module Metatheory = Pulse.Typing.Metatheory module RU = Pulse.RuntimeUtils (* For now we just create a term with the union,
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.fst.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Checker.Pure.fsti.checked", "Pulse.Checker.Prover.fsti.checked", "Pulse.Checker.Base.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.BreakVC.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Pulse.JoinComp.fst" }
[ { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker.Prover", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse", "short_module": null }, { "abbrev": false, "full_module": "Pulse", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
is1: Pulse.Syntax.Base.term -> is2: Pulse.Syntax.Base.term -> Pulse.Syntax.Base.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.term", "Pulse.Typing.tm_join_inames" ]
[]
false
false
false
true
false
let compute_iname_join (is1 is2: term) : term =
tm_join_inames is1 is2
false
Hacl.P256.PrecompTable.fst
Hacl.P256.PrecompTable.proj_g_pow2_192
val proj_g_pow2_192:S.proj_point
val proj_g_pow2_192:S.proj_point
let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ)
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 14, "end_line": 90, "start_col": 0, "start_line": 83 }
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ)
{ "checked_file": "/", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.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.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "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.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "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.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Spec.P256.PointOps.proj_point
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.Mktuple3", "Prims.nat", "Spec.P256.PointOps.felem" ]
[]
false
false
false
true
false
let proj_g_pow2_192:S.proj_point =
[@@ inline_let ]let rX:S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@@ inline_let ]let rY:S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@@ inline_let ]let rZ:S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ)
false
FStar.Buffer.fst
FStar.Buffer.as_ref
val as_ref : b: FStar.Buffer.buffer a -> Prims.GTot (FStar.Monotonic.Heap.mref (FStar.Buffer.lseq a (FStar.Buffer.max_length b)) (FStar.Heap.trivial_preorder (FStar.Buffer.lseq a (FStar.Buffer.max_length b))))
let as_ref #a (b:buffer a) = as_ref (content b)
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 47, "end_line": 68, "start_col": 0, "start_line": 68 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Buffer.buffer a -> Prims.GTot (FStar.Monotonic.Heap.mref (FStar.Buffer.lseq a (FStar.Buffer.max_length b)) (FStar.Heap.trivial_preorder (FStar.Buffer.lseq a (FStar.Buffer.max_length b))))
Prims.GTot
[ "sometrivial" ]
[]
[ "FStar.Buffer.buffer", "FStar.Monotonic.HyperStack.as_ref", "FStar.Buffer.lseq", "FStar.Buffer.max_length", "FStar.Heap.trivial_preorder", "FStar.Buffer.content", "FStar.Monotonic.Heap.mref" ]
[]
false
false
false
false
false
let as_ref #a (b: buffer a) =
as_ref (content b)
false
FStar.Buffer.fst
FStar.Buffer.content
val content (#a: _) (b: buffer a) : GTot (reference (lseq a (max_length b)))
val content (#a: _) (b: buffer a) : GTot (reference (lseq a (max_length b)))
let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 54, "end_line": 65, "start_col": 0, "start_line": 64 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Buffer.buffer a -> Prims.GTot (FStar.HyperStack.ST.reference (FStar.Buffer.lseq a (FStar.Buffer.max_length b)))
Prims.GTot
[ "sometrivial" ]
[]
[ "FStar.Buffer.buffer", "FStar.Buffer.__proj__MkBuffer__item__content", "FStar.HyperStack.ST.reference", "FStar.Buffer.lseq", "FStar.Buffer.max_length" ]
[]
false
false
false
false
false
let content #a (b: buffer a) : GTot (reference (lseq a (max_length b))) =
b.content
false
FStar.Buffer.fst
FStar.Buffer.as_addr
val as_addr : b: FStar.Buffer.buffer a -> Prims.GTot Prims.pos
let as_addr #a (b:buffer a) = as_addr (content b)
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 49, "end_line": 69, "start_col": 0, "start_line": 69 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Buffer.buffer a -> Prims.GTot Prims.pos
Prims.GTot
[ "sometrivial" ]
[]
[ "FStar.Buffer.buffer", "FStar.Monotonic.HyperStack.as_addr", "FStar.Buffer.lseq", "FStar.Buffer.max_length", "FStar.Heap.trivial_preorder", "FStar.Buffer.content", "Prims.pos" ]
[]
false
false
false
false
false
let as_addr #a (b: buffer a) =
as_addr (content b)
false
FStar.Buffer.fst
FStar.Buffer.frameOf
val frameOf (#a: _) (b: buffer a) : GTot HS.rid
val frameOf (#a: _) (b: buffer a) : GTot HS.rid
let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b)
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 66, "end_line": 70, "start_col": 0, "start_line": 70 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Buffer.buffer a -> Prims.GTot FStar.Monotonic.HyperHeap.rid
Prims.GTot
[ "sometrivial" ]
[]
[ "FStar.Buffer.buffer", "FStar.Monotonic.HyperStack.frameOf", "FStar.Buffer.lseq", "FStar.Buffer.max_length", "FStar.Heap.trivial_preorder", "FStar.Buffer.content", "FStar.Monotonic.HyperHeap.rid" ]
[]
false
false
false
false
false
let frameOf #a (b: buffer a) : GTot HS.rid =
HS.frameOf (content b)
false
FStar.Buffer.fst
FStar.Buffer.unmapped_in
val unmapped_in (#a: _) (b: buffer a) (h: mem) : GTot Type0
val unmapped_in (#a: _) (b: buffer a) (h: mem) : GTot Type0
let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 68, "end_line": 74, "start_col": 0, "start_line": 74 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Buffer.buffer a -> h: FStar.Monotonic.HyperStack.mem -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "FStar.Buffer.buffer", "FStar.Monotonic.HyperStack.mem", "FStar.Buffer.unused_in" ]
[]
false
false
false
false
true
let unmapped_in #a (b: buffer a) (h: mem) : GTot Type0 =
unused_in b h
false
FStar.Buffer.fst
FStar.Buffer.length
val length (#a: _) (b: buffer a) : GTot nat
val length (#a: _) (b: buffer a) : GTot nat
let length #a (b:buffer a) : GTot nat = v b.length
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 50, "end_line": 60, "start_col": 0, "start_line": 60 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Buffer.buffer a -> Prims.GTot Prims.nat
Prims.GTot
[ "sometrivial" ]
[]
[ "FStar.Buffer.buffer", "FStar.UInt32.v", "FStar.Buffer.__proj__MkBuffer__item__length", "Prims.nat" ]
[]
false
false
false
false
false
let length #a (b: buffer a) : GTot nat =
v b.length
false
FStar.Buffer.fst
FStar.Buffer.max_length
val max_length (#a: _) (b: buffer a) : GTot nat
val max_length (#a: _) (b: buffer a) : GTot nat
let max_length #a (b:buffer a) : GTot nat = v b.max_length
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 58, "end_line": 59, "start_col": 0, "start_line": 59 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Buffer.buffer a -> Prims.GTot Prims.nat
Prims.GTot
[ "sometrivial" ]
[]
[ "FStar.Buffer.buffer", "FStar.UInt32.v", "FStar.Buffer.__proj__MkBuffer__item__max_length", "Prims.nat" ]
[]
false
false
false
false
false
let max_length #a (b: buffer a) : GTot nat =
v b.max_length
false
FStar.Buffer.fst
FStar.Buffer.disjoint
val disjoint (#a #a': _) (x: buffer a) (y: buffer a') : GTot Type0
val disjoint (#a #a': _) (x: buffer a) (y: buffer a') : GTot Type0
let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x))
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 62, "end_line": 124, "start_col": 0, "start_line": 121 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Buffer.buffer a -> y: FStar.Buffer.buffer a' -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "FStar.Buffer.buffer", "Prims.l_or", "Prims.l_not", "Prims.eq2", "FStar.Monotonic.HyperHeap.rid", "FStar.Buffer.frameOf", "Prims.pos", "FStar.Buffer.as_addr", "Prims.l_and", "FStar.UInt32.t", "FStar.Buffer.__proj__MkBuffer__item__max_length", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "FStar.Buffer.idx", "FStar.Buffer.length" ]
[]
false
false
false
false
true
let disjoint #a #a' (x: buffer a) (y: buffer a') : GTot Type0 =
frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x))
false
FStar.Buffer.fst
FStar.Buffer.idx
val idx (#a: _) (b: buffer a) : GTot nat
val idx (#a: _) (b: buffer a) : GTot nat
let idx #a (b:buffer a) : GTot nat = v b.idx
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 44, "end_line": 61, "start_col": 0, "start_line": 61 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Buffer.buffer a -> Prims.GTot Prims.nat
Prims.GTot
[ "sometrivial" ]
[]
[ "FStar.Buffer.buffer", "FStar.UInt32.v", "FStar.Buffer.__proj__MkBuffer__item__idx", "Prims.nat" ]
[]
false
false
false
false
false
let idx #a (b: buffer a) : GTot nat =
v b.idx
false
FStar.Buffer.fst
FStar.Buffer.live
val live (#a: _) (h: mem) (b: buffer a) : GTot Type0
val live (#a: _) (h: mem) (b: buffer a) : GTot Type0
let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 71, "end_line": 73, "start_col": 0, "start_line": 73 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: FStar.Monotonic.HyperStack.mem -> b: FStar.Buffer.buffer a -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "FStar.Buffer.buffer", "FStar.Monotonic.HyperStack.contains", "FStar.Buffer.lseq", "FStar.UInt32.v", "FStar.Buffer.__proj__MkBuffer__item__max_length", "FStar.Heap.trivial_preorder", "FStar.Buffer.__proj__MkBuffer__item__content" ]
[]
false
false
false
false
true
let live #a (h: mem) (b: buffer a) : GTot Type0 =
HS.contains h b.content
false
FStar.Buffer.fst
FStar.Buffer.op_Plus_Plus
val op_Plus_Plus : x: FStar.TSet.set _ -> y: FStar.TSet.set _ -> FStar.TSet.set _
let op_Plus_Plus = TSet.union
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 29, "end_line": 160, "start_col": 0, "start_line": 160 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.TSet.set _ -> y: FStar.TSet.set _ -> FStar.TSet.set _
Prims.Tot
[ "total" ]
[]
[ "FStar.TSet.union", "FStar.TSet.set" ]
[]
false
false
false
true
false
let op_Plus_Plus =
TSet.union
false
FStar.Buffer.fst
FStar.Buffer.op_Bang_Bang
val op_Bang_Bang : x: _ -> FStar.TSet.set _
let op_Bang_Bang = TSet.singleton
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 33, "end_line": 159, "start_col": 0, "start_line": 159 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: _ -> FStar.TSet.set _
Prims.Tot
[ "total" ]
[]
[ "FStar.TSet.singleton", "FStar.TSet.set" ]
[]
false
false
false
true
false
let op_Bang_Bang =
TSet.singleton
false
FStar.Buffer.fst
FStar.Buffer.only
val only (#t: _) (b: buffer t) : Tot (TSet.set abuffer)
val only (#t: _) (b: buffer t) : Tot (TSet.set abuffer)
let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b)
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 84, "end_line": 155, "start_col": 0, "start_line": 155 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Buffer.buffer t -> FStar.TSet.set FStar.Buffer.abuffer
Prims.Tot
[ "total" ]
[]
[ "FStar.Buffer.buffer", "FStar.TSet.singleton", "FStar.Buffer.abuffer", "FStar.Buffer.Buff", "FStar.TSet.set" ]
[]
false
false
false
true
false
let only #t (b: buffer t) : Tot (TSet.set abuffer) =
FStar.TSet.singleton (Buff #t b)
false
FStar.Buffer.fst
FStar.Buffer.disjoint_from_bufs
val disjoint_from_bufs : b: FStar.Buffer.buffer a -> bufs: FStar.TSet.set FStar.Buffer.abuffer -> Prims.logical
let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 49, "end_line": 191, "start_col": 0, "start_line": 190 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Buffer.buffer a -> bufs: FStar.TSet.set FStar.Buffer.abuffer -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "FStar.Buffer.buffer", "FStar.TSet.set", "FStar.Buffer.abuffer", "Prims.l_Forall", "Prims.l_imp", "FStar.TSet.mem", "FStar.Buffer.disjoint", "FStar.Buffer.__proj__Buff__item__t", "FStar.Buffer.__proj__Buff__item__b", "Prims.logical" ]
[]
false
false
false
true
true
let disjoint_from_bufs #a (b: buffer a) (bufs: TSet.set abuffer) =
forall b'. TSet.mem b' bufs ==> disjoint b b'.b
false
FStar.Buffer.fst
FStar.Buffer.recall
val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b))
val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b))
let recall #a b = recall b.content
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 34, "end_line": 80, "start_col": 0, "start_line": 80 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Buffer.buffer a { FStar.HyperStack.ST.is_eternal_region (FStar.Buffer.frameOf b) /\ Prims.op_Negation (FStar.Monotonic.HyperStack.is_mm (MkBuffer?.content b)) } -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "FStar.Buffer.buffer", "Prims.l_and", "FStar.HyperStack.ST.is_eternal_region", "FStar.Buffer.frameOf", "Prims.b2t", "Prims.op_Negation", "FStar.Monotonic.HyperStack.is_mm", "FStar.Buffer.lseq", "FStar.UInt32.v", "FStar.Buffer.__proj__MkBuffer__item__max_length", "FStar.Heap.trivial_preorder", "FStar.Buffer.__proj__MkBuffer__item__content", "FStar.HyperStack.ST.recall", "Prims.unit" ]
[]
false
true
false
false
false
let recall #a b =
recall b.content
false
FStar.Buffer.fst
FStar.Buffer.disjoint_1
val disjoint_1 : a: FStar.Buffer.buffer _ -> b: FStar.Buffer.buffer _ -> Type0
let disjoint_1 a b = disjoint a b
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 33, "end_line": 199, "start_col": 0, "start_line": 199 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: FStar.Buffer.buffer _ -> b: FStar.Buffer.buffer _ -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Buffer.buffer", "FStar.Buffer.disjoint" ]
[]
false
false
false
true
true
let disjoint_1 a b =
disjoint a b
false
FStar.Buffer.fst
FStar.Buffer.includes_as_seq
val includes_as_seq (#a h1 h2: _) (x y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y))
val includes_as_seq (#a h1 h2: _) (x y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y))
let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y)
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 99, "end_line": 112, "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.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h1: FStar.Monotonic.HyperStack.mem -> h2: FStar.Monotonic.HyperStack.mem -> x: FStar.Buffer.buffer a -> y: FStar.Buffer.buffer a -> FStar.Pervasives.Lemma (requires FStar.Buffer.includes x y /\ FStar.Buffer.as_seq h1 x == FStar.Buffer.as_seq h2 x) (ensures FStar.Buffer.as_seq h1 y == FStar.Buffer.as_seq h2 y)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "FStar.Buffer.buffer", "FStar.Seq.Properties.slice_slice", "FStar.Buffer.sel", "FStar.Buffer.idx", "Prims.op_Addition", "FStar.Buffer.length", "Prims.op_Subtraction", "Prims.unit", "Prims.l_and", "FStar.Buffer.includes", "Prims.eq2", "FStar.Seq.Base.seq", "Prims.l_or", "Prims.nat", "FStar.Seq.Base.length", "FStar.Buffer.as_seq", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) =
Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y)
false
FStar.Buffer.fst
FStar.Buffer.disjoint_ref_1
val disjoint_ref_1 : a: FStar.Buffer.buffer t -> r: FStar.HyperStack.ST.reference u401 -> Prims.logical
let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) = frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 58, "end_line": 206, "start_col": 0, "start_line": 205 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b''''
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: FStar.Buffer.buffer t -> r: FStar.HyperStack.ST.reference u401 -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "FStar.Buffer.buffer", "FStar.HyperStack.ST.reference", "Prims.l_or", "Prims.l_not", "Prims.eq2", "FStar.Monotonic.HyperHeap.rid", "FStar.Buffer.frameOf", "FStar.Monotonic.HyperStack.frameOf", "FStar.Heap.trivial_preorder", "Prims.pos", "FStar.Buffer.as_addr", "FStar.Monotonic.HyperStack.as_addr", "Prims.logical" ]
[]
false
false
false
true
true
let disjoint_ref_1 (#t #u: Type) (a: buffer t) (r: reference u) =
frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r
false
FStar.Buffer.fst
FStar.Buffer.disjoint_2
val disjoint_2 : a: FStar.Buffer.buffer _ -> b: FStar.Buffer.buffer _ -> b': FStar.Buffer.buffer _ -> Prims.logical
let disjoint_2 a b b' = disjoint a b /\ disjoint a b'
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 53, "end_line": 200, "start_col": 0, "start_line": 200 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: FStar.Buffer.buffer _ -> b: FStar.Buffer.buffer _ -> b': FStar.Buffer.buffer _ -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "FStar.Buffer.buffer", "Prims.l_and", "FStar.Buffer.disjoint", "Prims.logical" ]
[]
false
false
false
true
true
let disjoint_2 a b b' =
disjoint a b /\ disjoint a b'
false
FStar.Buffer.fst
FStar.Buffer.lemma_arefs_1
val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)]
val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)]
let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty)
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 65, "end_line": 172, "start_col": 0, "start_line": 172 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.TSet.set FStar.Buffer.abuffer -> FStar.Pervasives.Lemma (requires s == FStar.TSet.empty) (ensures FStar.Buffer.arefs s == FStar.Set.empty) [SMTPat (FStar.Buffer.arefs s)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.TSet.set", "FStar.Buffer.abuffer", "FStar.Set.lemma_equal_intro", "Prims.nat", "FStar.Buffer.arefs", "FStar.Set.empty", "Prims.unit" ]
[]
true
false
true
false
false
let lemma_arefs_1 s =
Set.lemma_equal_intro (arefs s) (Set.empty)
false
FStar.Buffer.fst
FStar.Buffer.includes
val includes (#a: _) (x y: buffer a) : GTot Type0
val includes (#a: _) (x y: buffer a) : GTot Type0
let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 38, "end_line": 99, "start_col": 0, "start_line": 95 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b'
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.Buffer.buffer a -> y: FStar.Buffer.buffer a -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "FStar.Buffer.buffer", "Prims.l_and", "Prims.eq2", "FStar.UInt32.t", "FStar.Buffer.__proj__MkBuffer__item__max_length", "Prims.op_Equals_Equals_Equals", "FStar.HyperStack.ST.reference", "FStar.Buffer.lseq", "FStar.UInt32.v", "FStar.Buffer.__proj__MkBuffer__item__content", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.Buffer.idx", "Prims.op_Addition", "FStar.Buffer.length" ]
[]
false
false
false
false
true
let includes #a (x: buffer a) (y: buffer a) : GTot Type0 =
x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y
false
FStar.Buffer.fst
FStar.Buffer.disjoint_4
val disjoint_4 : a: FStar.Buffer.buffer _ -> b: FStar.Buffer.buffer _ -> b': FStar.Buffer.buffer _ -> b'': FStar.Buffer.buffer _ -> b''': FStar.Buffer.buffer _ -> Prims.logical
let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b'''
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 99, "end_line": 202, "start_col": 0, "start_line": 202 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b'
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: FStar.Buffer.buffer _ -> b: FStar.Buffer.buffer _ -> b': FStar.Buffer.buffer _ -> b'': FStar.Buffer.buffer _ -> b''': FStar.Buffer.buffer _ -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "FStar.Buffer.buffer", "Prims.l_and", "FStar.Buffer.disjoint", "Prims.logical" ]
[]
false
false
false
true
true
let disjoint_4 a b b' b'' b''' =
disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b'''
false
FStar.Buffer.fst
FStar.Buffer.disjoint_3
val disjoint_3 : a: FStar.Buffer.buffer _ -> b: FStar.Buffer.buffer _ -> b': FStar.Buffer.buffer _ -> b'': FStar.Buffer.buffer _ -> Prims.logical
let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b''
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 75, "end_line": 201, "start_col": 0, "start_line": 201 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: FStar.Buffer.buffer _ -> b: FStar.Buffer.buffer _ -> b': FStar.Buffer.buffer _ -> b'': FStar.Buffer.buffer _ -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "FStar.Buffer.buffer", "Prims.l_and", "FStar.Buffer.disjoint", "Prims.logical" ]
[]
false
false
false
true
true
let disjoint_3 a b b' b'' =
disjoint a b /\ disjoint a b' /\ disjoint a b''
false
FStar.Buffer.fst
FStar.Buffer.disjoint_ref_2
val disjoint_ref_2 : a: FStar.Buffer.buffer _ -> r: FStar.HyperStack.ST.reference _ -> r': FStar.HyperStack.ST.reference _ -> Prims.logical
let disjoint_ref_2 a r r' = disjoint_ref_1 a r /\ disjoint_ref_1 a r'
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 69, "end_line": 207, "start_col": 0, "start_line": 207 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b'''' let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) =
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: FStar.Buffer.buffer _ -> r: FStar.HyperStack.ST.reference _ -> r': FStar.HyperStack.ST.reference _ -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "FStar.Buffer.buffer", "FStar.HyperStack.ST.reference", "Prims.l_and", "FStar.Buffer.disjoint_ref_1", "Prims.logical" ]
[]
false
false
false
true
true
let disjoint_ref_2 a r r' =
disjoint_ref_1 a r /\ disjoint_ref_1 a r'
false
FStar.Buffer.fst
FStar.Buffer.disjoint_5
val disjoint_5 : a: FStar.Buffer.buffer _ -> b: FStar.Buffer.buffer _ -> b': FStar.Buffer.buffer _ -> b'': FStar.Buffer.buffer _ -> b''': FStar.Buffer.buffer _ -> b'''': FStar.Buffer.buffer _ -> Prims.logical
let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b''''
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 125, "end_line": 203, "start_col": 0, "start_line": 203 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b''
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: FStar.Buffer.buffer _ -> b: FStar.Buffer.buffer _ -> b': FStar.Buffer.buffer _ -> b'': FStar.Buffer.buffer _ -> b''': FStar.Buffer.buffer _ -> b'''': FStar.Buffer.buffer _ -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "FStar.Buffer.buffer", "Prims.l_and", "FStar.Buffer.disjoint", "Prims.logical" ]
[]
false
false
false
true
true
let disjoint_5 a b b' b'' b''' b'''' =
disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b''''
false
FStar.Buffer.fst
FStar.Buffer.disjoint_ref_3
val disjoint_ref_3 : a: FStar.Buffer.buffer _ -> r: FStar.HyperStack.ST.reference _ -> r': FStar.HyperStack.ST.reference _ -> r'': FStar.HyperStack.ST.reference _ -> Prims.logical
let disjoint_ref_3 a r r' r'' = disjoint_ref_1 a r /\ disjoint_ref_2 a r' r''
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 77, "end_line": 208, "start_col": 0, "start_line": 208 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b'''' let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) = frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: FStar.Buffer.buffer _ -> r: FStar.HyperStack.ST.reference _ -> r': FStar.HyperStack.ST.reference _ -> r'': FStar.HyperStack.ST.reference _ -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "FStar.Buffer.buffer", "FStar.HyperStack.ST.reference", "Prims.l_and", "FStar.Buffer.disjoint_ref_1", "FStar.Buffer.disjoint_ref_2", "Prims.logical" ]
[]
false
false
false
true
true
let disjoint_ref_3 a r r' r'' =
disjoint_ref_1 a r /\ disjoint_ref_2 a r' r''
false
FStar.Buffer.fst
FStar.Buffer.disjoint_ref_5
val disjoint_ref_5 : a: FStar.Buffer.buffer _ -> r: FStar.HyperStack.ST.reference _ -> r': FStar.HyperStack.ST.reference _ -> r'': FStar.HyperStack.ST.reference _ -> r''': FStar.HyperStack.ST.reference _ -> r'''': FStar.HyperStack.ST.reference _ -> Prims.logical
let disjoint_ref_5 a r r' r'' r''' r'''' = disjoint_ref_1 a r /\ disjoint_ref_4 a r' r'' r''' r''''
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 99, "end_line": 210, "start_col": 0, "start_line": 210 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b'''' let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) = frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r let disjoint_ref_2 a r r' = disjoint_ref_1 a r /\ disjoint_ref_1 a r' let disjoint_ref_3 a r r' r'' = disjoint_ref_1 a r /\ disjoint_ref_2 a r' r''
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: FStar.Buffer.buffer _ -> r: FStar.HyperStack.ST.reference _ -> r': FStar.HyperStack.ST.reference _ -> r'': FStar.HyperStack.ST.reference _ -> r''': FStar.HyperStack.ST.reference _ -> r'''': FStar.HyperStack.ST.reference _ -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "FStar.Buffer.buffer", "FStar.HyperStack.ST.reference", "Prims.l_and", "FStar.Buffer.disjoint_ref_1", "FStar.Buffer.disjoint_ref_4", "Prims.logical" ]
[]
false
false
false
true
true
let disjoint_ref_5 a r r' r'' r''' r'''' =
disjoint_ref_1 a r /\ disjoint_ref_4 a r' r'' r''' r''''
false
FStar.Buffer.fst
FStar.Buffer.disjoint_ref_4
val disjoint_ref_4 : a: FStar.Buffer.buffer _ -> r: FStar.HyperStack.ST.reference _ -> r': FStar.HyperStack.ST.reference _ -> r'': FStar.HyperStack.ST.reference _ -> r''': FStar.HyperStack.ST.reference _ -> Prims.logical
let disjoint_ref_4 a r r' r'' r''' = disjoint_ref_1 a r /\ disjoint_ref_3 a r' r'' r'''
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 87, "end_line": 209, "start_col": 0, "start_line": 209 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b'''' let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) = frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r let disjoint_ref_2 a r r' = disjoint_ref_1 a r /\ disjoint_ref_1 a r'
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: FStar.Buffer.buffer _ -> r: FStar.HyperStack.ST.reference _ -> r': FStar.HyperStack.ST.reference _ -> r'': FStar.HyperStack.ST.reference _ -> r''': FStar.HyperStack.ST.reference _ -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "FStar.Buffer.buffer", "FStar.HyperStack.ST.reference", "Prims.l_and", "FStar.Buffer.disjoint_ref_1", "FStar.Buffer.disjoint_ref_3", "Prims.logical" ]
[]
false
false
false
true
true
let disjoint_ref_4 a r r' r'' r''' =
disjoint_ref_1 a r /\ disjoint_ref_3 a r' r'' r'''
false
FStar.Buffer.fst
FStar.Buffer.lemma_arefs_2
val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]]
val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]]
let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2))
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 76, "end_line": 182, "start_col": 0, "start_line": 181 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s1: FStar.TSet.set FStar.Buffer.abuffer -> s2: FStar.TSet.set FStar.Buffer.abuffer -> FStar.Pervasives.Lemma (ensures FStar.Buffer.arefs (s1 ++ s2) == FStar.Set.union (FStar.Buffer.arefs s1) (FStar.Buffer.arefs s2)) [ SMTPatOr [ [SMTPat (FStar.Buffer.arefs (s2 ++ s1))]; [SMTPat (FStar.Buffer.arefs (s1 ++ s2))] ] ]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.TSet.set", "FStar.Buffer.abuffer", "FStar.Set.lemma_equal_intro", "Prims.nat", "FStar.Buffer.arefs", "FStar.Buffer.op_Plus_Plus", "FStar.Set.union", "Prims.unit" ]
[]
true
false
true
false
false
let lemma_arefs_2 s1 s2 =
Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2))
false
FStar.Buffer.fst
FStar.Buffer.modifies_bufs
val modifies_bufs : rid: FStar.Monotonic.HyperHeap.rid -> buffs: FStar.TSet.set FStar.Buffer.abuffer -> h: FStar.Monotonic.HyperStack.mem -> h': FStar.Monotonic.HyperStack.mem -> Prims.logical
let modifies_bufs rid buffs h h' = modifies_ref rid (arefs buffs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b buffs) ==> equal h b h' b /\ live h' b)
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 130, "end_line": 234, "start_col": 0, "start_line": 232 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b'''' let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) = frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r let disjoint_ref_2 a r r' = disjoint_ref_1 a r /\ disjoint_ref_1 a r' let disjoint_ref_3 a r r' r'' = disjoint_ref_1 a r /\ disjoint_ref_2 a r' r'' let disjoint_ref_4 a r r' r'' r''' = disjoint_ref_1 a r /\ disjoint_ref_3 a r' r'' r''' let disjoint_ref_5 a r r' r'' r''' r'''' = disjoint_ref_1 a r /\ disjoint_ref_4 a r' r'' r''' r'''' val disjoint_only_lemma: #a:Type -> #a':Type -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint b b')) (ensures (disjoint_from_bufs b (only b'))) let disjoint_only_lemma #a #a' b b' = () (* Fully general modifies clause *) let modifies_bufs_and_refs (bufs:TSet.set abuffer) (refs:Set.set nat) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (Set.union (arefs bufs) refs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs /\ disjoint_from_refs b refs) ==> equal h b h' b /\ live h' b))) (* Fully general modifies clause for buffer sets *) let modifies_buffers (bufs:TSet.set abuffer) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (arefs bufs) h h' /\ (forall (#a:Type) (b:buffer a). {:pattern (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs)} (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs ==> equal h b h' b /\ live h' b))))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
rid: FStar.Monotonic.HyperHeap.rid -> buffs: FStar.TSet.set FStar.Buffer.abuffer -> h: FStar.Monotonic.HyperStack.mem -> h': FStar.Monotonic.HyperStack.mem -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "FStar.Monotonic.HyperHeap.rid", "FStar.TSet.set", "FStar.Buffer.abuffer", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "FStar.Monotonic.HyperStack.modifies_ref", "FStar.Buffer.arefs", "Prims.l_Forall", "FStar.Buffer.buffer", "Prims.l_imp", "Prims.eq2", "FStar.Buffer.frameOf", "FStar.Buffer.live", "FStar.Buffer.disjoint_from_bufs", "FStar.Buffer.equal", "Prims.logical" ]
[]
false
false
false
true
true
let modifies_bufs rid buffs h h' =
modifies_ref rid (arefs buffs) h h' /\ (forall (#a: Type) (b: buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b buffs) ==> equal h b h' b /\ live h' b)
false
FStar.Buffer.fst
FStar.Buffer.modifies_none
val modifies_none : h: m: FStar.Monotonic.HyperStack.mem' { FStar.Monotonic.HyperStack.is_wf_with_ctr_and_tip (FStar.Monotonic.HyperStack.get_hmap m) (FStar.Monotonic.HyperStack.get_rid_ctr m) (FStar.Monotonic.HyperStack.get_tip m) } -> h': m: FStar.Monotonic.HyperStack.mem' { FStar.Monotonic.HyperStack.is_wf_with_ctr_and_tip (FStar.Monotonic.HyperStack.get_hmap m) (FStar.Monotonic.HyperStack.get_rid_ctr m) (FStar.Monotonic.HyperStack.get_tip m) } -> Prims.logical
let modifies_none h h' = HS.get_tip h' == HS.get_tip h /\ HS.modifies_transitively Set.empty h h'
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 74, "end_line": 237, "start_col": 0, "start_line": 236 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b'''' let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) = frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r let disjoint_ref_2 a r r' = disjoint_ref_1 a r /\ disjoint_ref_1 a r' let disjoint_ref_3 a r r' r'' = disjoint_ref_1 a r /\ disjoint_ref_2 a r' r'' let disjoint_ref_4 a r r' r'' r''' = disjoint_ref_1 a r /\ disjoint_ref_3 a r' r'' r''' let disjoint_ref_5 a r r' r'' r''' r'''' = disjoint_ref_1 a r /\ disjoint_ref_4 a r' r'' r''' r'''' val disjoint_only_lemma: #a:Type -> #a':Type -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint b b')) (ensures (disjoint_from_bufs b (only b'))) let disjoint_only_lemma #a #a' b b' = () (* Fully general modifies clause *) let modifies_bufs_and_refs (bufs:TSet.set abuffer) (refs:Set.set nat) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (Set.union (arefs bufs) refs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs /\ disjoint_from_refs b refs) ==> equal h b h' b /\ live h' b))) (* Fully general modifies clause for buffer sets *) let modifies_buffers (bufs:TSet.set abuffer) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (arefs bufs) h h' /\ (forall (#a:Type) (b:buffer a). {:pattern (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs)} (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs ==> equal h b h' b /\ live h' b)))) (* General modifies clause for buffers only *) let modifies_bufs rid buffs h h' = modifies_ref rid (arefs buffs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b buffs) ==> equal h b h' b /\ live h' b)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: m: FStar.Monotonic.HyperStack.mem' { FStar.Monotonic.HyperStack.is_wf_with_ctr_and_tip (FStar.Monotonic.HyperStack.get_hmap m) (FStar.Monotonic.HyperStack.get_rid_ctr m) (FStar.Monotonic.HyperStack.get_tip m) } -> h': m: FStar.Monotonic.HyperStack.mem' { FStar.Monotonic.HyperStack.is_wf_with_ctr_and_tip (FStar.Monotonic.HyperStack.get_hmap m) (FStar.Monotonic.HyperStack.get_rid_ctr m) (FStar.Monotonic.HyperStack.get_tip m) } -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "FStar.Monotonic.HyperStack.mem'", "FStar.Monotonic.HyperStack.is_wf_with_ctr_and_tip", "FStar.Monotonic.HyperStack.get_hmap", "FStar.Monotonic.HyperStack.get_rid_ctr", "FStar.Monotonic.HyperStack.get_tip", "Prims.l_and", "Prims.eq2", "FStar.Monotonic.HyperHeap.rid", "FStar.Monotonic.HyperStack.modifies_transitively", "FStar.Set.empty", "Prims.logical" ]
[]
false
false
false
false
true
let modifies_none h h' =
HS.get_tip h' == HS.get_tip h /\ HS.modifies_transitively Set.empty h h'
false
FStar.Buffer.fst
FStar.Buffer.disjoint_from_refs
val disjoint_from_refs : b: FStar.Buffer.buffer a -> set: FStar.Set.set Prims.nat -> Prims.logical
let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set)
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 28, "end_line": 195, "start_col": 0, "start_line": 194 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Buffer.buffer a -> set: FStar.Set.set Prims.nat -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "FStar.Buffer.buffer", "FStar.Set.set", "Prims.nat", "Prims.l_not", "Prims.b2t", "FStar.Set.mem", "FStar.Buffer.as_addr", "Prims.logical" ]
[]
false
false
false
true
true
let disjoint_from_refs #a (b: buffer a) (set: Set.set nat) =
~(Set.mem (as_addr b) set)
false
FStar.Buffer.fst
FStar.Buffer.modifies_buf_2
val modifies_buf_2 : rid: FStar.Monotonic.HyperHeap.rid -> b: FStar.Buffer.buffer t -> b': FStar.Buffer.buffer t' -> h: FStar.Monotonic.HyperStack.mem -> h': FStar.Monotonic.HyperStack.mem -> Prims.logical
let modifies_buf_2 (#t:Type) (#t':Type) rid (b:buffer t) (b':buffer t') h h' = modifies_ref rid (to_set_2 (as_addr b) (as_addr b')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb) ==> equal h bb h' bb /\ live h' bb)
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 42, "end_line": 253, "start_col": 0, "start_line": 250 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b'''' let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) = frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r let disjoint_ref_2 a r r' = disjoint_ref_1 a r /\ disjoint_ref_1 a r' let disjoint_ref_3 a r r' r'' = disjoint_ref_1 a r /\ disjoint_ref_2 a r' r'' let disjoint_ref_4 a r r' r'' r''' = disjoint_ref_1 a r /\ disjoint_ref_3 a r' r'' r''' let disjoint_ref_5 a r r' r'' r''' r'''' = disjoint_ref_1 a r /\ disjoint_ref_4 a r' r'' r''' r'''' val disjoint_only_lemma: #a:Type -> #a':Type -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint b b')) (ensures (disjoint_from_bufs b (only b'))) let disjoint_only_lemma #a #a' b b' = () (* Fully general modifies clause *) let modifies_bufs_and_refs (bufs:TSet.set abuffer) (refs:Set.set nat) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (Set.union (arefs bufs) refs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs /\ disjoint_from_refs b refs) ==> equal h b h' b /\ live h' b))) (* Fully general modifies clause for buffer sets *) let modifies_buffers (bufs:TSet.set abuffer) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (arefs bufs) h h' /\ (forall (#a:Type) (b:buffer a). {:pattern (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs)} (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs ==> equal h b h' b /\ live h' b)))) (* General modifies clause for buffers only *) let modifies_bufs rid buffs h h' = modifies_ref rid (arefs buffs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b buffs) ==> equal h b h' b /\ live h' b) let modifies_none h h' = HS.get_tip h' == HS.get_tip h /\ HS.modifies_transitively Set.empty h h' (* Specialized clauses for small numbers of buffers *) let modifies_buf_0 rid h h' = modifies_ref rid (Set.empty #nat) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb) ==> equal h bb h' bb /\ live h' bb) let modifies_buf_1 (#t:Type) rid (b:buffer t) h h' = //would be good to drop the rid argument on these, since they can be computed from the buffers modifies_ref rid (Set.singleton (Heap.addr_of (as_ref b))) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb) ==> equal h bb h' bb /\ live h' bb) let to_set_2 (n1:nat) (n2:nat) :Set.set nat = Set.union (Set.singleton n1) (Set.singleton n2)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
rid: FStar.Monotonic.HyperHeap.rid -> b: FStar.Buffer.buffer t -> b': FStar.Buffer.buffer t' -> h: FStar.Monotonic.HyperStack.mem -> h': FStar.Monotonic.HyperStack.mem -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "FStar.Monotonic.HyperHeap.rid", "FStar.Buffer.buffer", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "FStar.Monotonic.HyperStack.modifies_ref", "FStar.Buffer.to_set_2", "FStar.Buffer.as_addr", "Prims.l_Forall", "Prims.l_imp", "Prims.eq2", "FStar.Buffer.frameOf", "FStar.Buffer.live", "FStar.Buffer.disjoint", "FStar.Buffer.equal", "Prims.logical" ]
[]
false
false
false
true
true
let modifies_buf_2 (#t: Type) (#t': Type) rid (b: buffer t) (b': buffer t') h h' =
modifies_ref rid (to_set_2 (as_addr b) (as_addr b')) h h' /\ (forall (#tt: Type) (bb: buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb) ==> equal h bb h' bb /\ live h' bb)
false
FStar.Buffer.fst
FStar.Buffer.to_set_2
val to_set_2 (n1 n2: nat) : Set.set nat
val to_set_2 (n1 n2: nat) : Set.set nat
let to_set_2 (n1:nat) (n2:nat) :Set.set nat = Set.union (Set.singleton n1) (Set.singleton n2)
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 93, "end_line": 248, "start_col": 0, "start_line": 248 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b'''' let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) = frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r let disjoint_ref_2 a r r' = disjoint_ref_1 a r /\ disjoint_ref_1 a r' let disjoint_ref_3 a r r' r'' = disjoint_ref_1 a r /\ disjoint_ref_2 a r' r'' let disjoint_ref_4 a r r' r'' r''' = disjoint_ref_1 a r /\ disjoint_ref_3 a r' r'' r''' let disjoint_ref_5 a r r' r'' r''' r'''' = disjoint_ref_1 a r /\ disjoint_ref_4 a r' r'' r''' r'''' val disjoint_only_lemma: #a:Type -> #a':Type -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint b b')) (ensures (disjoint_from_bufs b (only b'))) let disjoint_only_lemma #a #a' b b' = () (* Fully general modifies clause *) let modifies_bufs_and_refs (bufs:TSet.set abuffer) (refs:Set.set nat) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (Set.union (arefs bufs) refs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs /\ disjoint_from_refs b refs) ==> equal h b h' b /\ live h' b))) (* Fully general modifies clause for buffer sets *) let modifies_buffers (bufs:TSet.set abuffer) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (arefs bufs) h h' /\ (forall (#a:Type) (b:buffer a). {:pattern (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs)} (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs ==> equal h b h' b /\ live h' b)))) (* General modifies clause for buffers only *) let modifies_bufs rid buffs h h' = modifies_ref rid (arefs buffs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b buffs) ==> equal h b h' b /\ live h' b) let modifies_none h h' = HS.get_tip h' == HS.get_tip h /\ HS.modifies_transitively Set.empty h h' (* Specialized clauses for small numbers of buffers *) let modifies_buf_0 rid h h' = modifies_ref rid (Set.empty #nat) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb) ==> equal h bb h' bb /\ live h' bb) let modifies_buf_1 (#t:Type) rid (b:buffer t) h h' = //would be good to drop the rid argument on these, since they can be computed from the buffers modifies_ref rid (Set.singleton (Heap.addr_of (as_ref b))) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb) ==> equal h bb h' bb /\ live h' bb)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n1: Prims.nat -> n2: Prims.nat -> FStar.Set.set Prims.nat
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "FStar.Set.union", "FStar.Set.singleton", "FStar.Set.set" ]
[]
false
false
false
true
false
let to_set_2 (n1 n2: nat) : Set.set nat =
Set.union (Set.singleton n1) (Set.singleton n2)
false
FStar.Buffer.fst
FStar.Buffer.modifies_buf_0
val modifies_buf_0 : rid: FStar.Monotonic.HyperHeap.rid -> h: FStar.Monotonic.HyperStack.mem -> h': FStar.Monotonic.HyperStack.mem -> Prims.logical
let modifies_buf_0 rid h h' = modifies_ref rid (Set.empty #nat) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb) ==> equal h bb h' bb /\ live h' bb)
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 108, "end_line": 242, "start_col": 0, "start_line": 240 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b'''' let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) = frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r let disjoint_ref_2 a r r' = disjoint_ref_1 a r /\ disjoint_ref_1 a r' let disjoint_ref_3 a r r' r'' = disjoint_ref_1 a r /\ disjoint_ref_2 a r' r'' let disjoint_ref_4 a r r' r'' r''' = disjoint_ref_1 a r /\ disjoint_ref_3 a r' r'' r''' let disjoint_ref_5 a r r' r'' r''' r'''' = disjoint_ref_1 a r /\ disjoint_ref_4 a r' r'' r''' r'''' val disjoint_only_lemma: #a:Type -> #a':Type -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint b b')) (ensures (disjoint_from_bufs b (only b'))) let disjoint_only_lemma #a #a' b b' = () (* Fully general modifies clause *) let modifies_bufs_and_refs (bufs:TSet.set abuffer) (refs:Set.set nat) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (Set.union (arefs bufs) refs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs /\ disjoint_from_refs b refs) ==> equal h b h' b /\ live h' b))) (* Fully general modifies clause for buffer sets *) let modifies_buffers (bufs:TSet.set abuffer) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (arefs bufs) h h' /\ (forall (#a:Type) (b:buffer a). {:pattern (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs)} (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs ==> equal h b h' b /\ live h' b)))) (* General modifies clause for buffers only *) let modifies_bufs rid buffs h h' = modifies_ref rid (arefs buffs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b buffs) ==> equal h b h' b /\ live h' b) let modifies_none h h' = HS.get_tip h' == HS.get_tip h /\ HS.modifies_transitively Set.empty h h'
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
rid: FStar.Monotonic.HyperHeap.rid -> h: FStar.Monotonic.HyperStack.mem -> h': FStar.Monotonic.HyperStack.mem -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "FStar.Monotonic.HyperHeap.rid", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "FStar.Monotonic.HyperStack.modifies_ref", "FStar.Set.empty", "Prims.nat", "Prims.l_Forall", "FStar.Buffer.buffer", "Prims.l_imp", "Prims.eq2", "FStar.Buffer.frameOf", "FStar.Buffer.live", "FStar.Buffer.equal", "Prims.logical" ]
[]
false
false
false
true
true
let modifies_buf_0 rid h h' =
modifies_ref rid (Set.empty #nat) h h' /\ (forall (#tt: Type) (bb: buffer tt). (frameOf bb == rid /\ live h bb) ==> equal h bb h' bb /\ live h' bb)
false
FStar.Buffer.fst
FStar.Buffer.modifies_buf_1
val modifies_buf_1 : rid: FStar.Monotonic.HyperHeap.rid -> b: FStar.Buffer.buffer t -> h: FStar.Monotonic.HyperStack.mem -> h': FStar.Monotonic.HyperStack.mem -> Prims.logical
let modifies_buf_1 (#t:Type) rid (b:buffer t) h h' = //would be good to drop the rid argument on these, since they can be computed from the buffers modifies_ref rid (Set.singleton (Heap.addr_of (as_ref b))) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb) ==> equal h bb h' bb /\ live h' bb)
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 125, "end_line": 246, "start_col": 0, "start_line": 244 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b'''' let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) = frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r let disjoint_ref_2 a r r' = disjoint_ref_1 a r /\ disjoint_ref_1 a r' let disjoint_ref_3 a r r' r'' = disjoint_ref_1 a r /\ disjoint_ref_2 a r' r'' let disjoint_ref_4 a r r' r'' r''' = disjoint_ref_1 a r /\ disjoint_ref_3 a r' r'' r''' let disjoint_ref_5 a r r' r'' r''' r'''' = disjoint_ref_1 a r /\ disjoint_ref_4 a r' r'' r''' r'''' val disjoint_only_lemma: #a:Type -> #a':Type -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint b b')) (ensures (disjoint_from_bufs b (only b'))) let disjoint_only_lemma #a #a' b b' = () (* Fully general modifies clause *) let modifies_bufs_and_refs (bufs:TSet.set abuffer) (refs:Set.set nat) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (Set.union (arefs bufs) refs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs /\ disjoint_from_refs b refs) ==> equal h b h' b /\ live h' b))) (* Fully general modifies clause for buffer sets *) let modifies_buffers (bufs:TSet.set abuffer) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (arefs bufs) h h' /\ (forall (#a:Type) (b:buffer a). {:pattern (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs)} (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs ==> equal h b h' b /\ live h' b)))) (* General modifies clause for buffers only *) let modifies_bufs rid buffs h h' = modifies_ref rid (arefs buffs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b buffs) ==> equal h b h' b /\ live h' b) let modifies_none h h' = HS.get_tip h' == HS.get_tip h /\ HS.modifies_transitively Set.empty h h' (* Specialized clauses for small numbers of buffers *) let modifies_buf_0 rid h h' = modifies_ref rid (Set.empty #nat) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb) ==> equal h bb h' bb /\ live h' bb)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
rid: FStar.Monotonic.HyperHeap.rid -> b: FStar.Buffer.buffer t -> h: FStar.Monotonic.HyperStack.mem -> h': FStar.Monotonic.HyperStack.mem -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "FStar.Monotonic.HyperHeap.rid", "FStar.Buffer.buffer", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "FStar.Monotonic.HyperStack.modifies_ref", "FStar.Set.singleton", "Prims.nat", "FStar.Monotonic.Heap.addr_of", "FStar.Buffer.lseq", "FStar.Buffer.max_length", "FStar.Heap.trivial_preorder", "FStar.Buffer.as_ref", "Prims.l_Forall", "Prims.l_imp", "Prims.eq2", "FStar.Buffer.frameOf", "FStar.Buffer.live", "FStar.Buffer.disjoint", "FStar.Buffer.equal", "Prims.logical" ]
[]
false
false
false
true
true
let modifies_buf_1 (#t: Type) rid (b: buffer t) h h' =
modifies_ref rid (Set.singleton (Heap.addr_of (as_ref b))) h h' /\ (forall (#tt: Type) (bb: buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb) ==> equal h bb h' bb /\ live h' bb)
false
FStar.Buffer.fst
FStar.Buffer.modifies_0
val modifies_0 (h0 h1: mem) : Type0
val modifies_0 (h0 h1: mem) : Type0
let modifies_0 (h0 h1:mem) :Type0 = modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 35, "end_line": 385, "start_col": 0, "start_line": 382 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b'''' let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) = frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r let disjoint_ref_2 a r r' = disjoint_ref_1 a r /\ disjoint_ref_1 a r' let disjoint_ref_3 a r r' r'' = disjoint_ref_1 a r /\ disjoint_ref_2 a r' r'' let disjoint_ref_4 a r r' r'' r''' = disjoint_ref_1 a r /\ disjoint_ref_3 a r' r'' r''' let disjoint_ref_5 a r r' r'' r''' r'''' = disjoint_ref_1 a r /\ disjoint_ref_4 a r' r'' r''' r'''' val disjoint_only_lemma: #a:Type -> #a':Type -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint b b')) (ensures (disjoint_from_bufs b (only b'))) let disjoint_only_lemma #a #a' b b' = () (* Fully general modifies clause *) let modifies_bufs_and_refs (bufs:TSet.set abuffer) (refs:Set.set nat) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (Set.union (arefs bufs) refs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs /\ disjoint_from_refs b refs) ==> equal h b h' b /\ live h' b))) (* Fully general modifies clause for buffer sets *) let modifies_buffers (bufs:TSet.set abuffer) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (arefs bufs) h h' /\ (forall (#a:Type) (b:buffer a). {:pattern (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs)} (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs ==> equal h b h' b /\ live h' b)))) (* General modifies clause for buffers only *) let modifies_bufs rid buffs h h' = modifies_ref rid (arefs buffs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b buffs) ==> equal h b h' b /\ live h' b) let modifies_none h h' = HS.get_tip h' == HS.get_tip h /\ HS.modifies_transitively Set.empty h h' (* Specialized clauses for small numbers of buffers *) let modifies_buf_0 rid h h' = modifies_ref rid (Set.empty #nat) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb) ==> equal h bb h' bb /\ live h' bb) let modifies_buf_1 (#t:Type) rid (b:buffer t) h h' = //would be good to drop the rid argument on these, since they can be computed from the buffers modifies_ref rid (Set.singleton (Heap.addr_of (as_ref b))) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb) ==> equal h bb h' bb /\ live h' bb) let to_set_2 (n1:nat) (n2:nat) :Set.set nat = Set.union (Set.singleton n1) (Set.singleton n2) let modifies_buf_2 (#t:Type) (#t':Type) rid (b:buffer t) (b':buffer t') h h' = modifies_ref rid (to_set_2 (as_addr b) (as_addr b')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_3 (n1:nat) (n2:nat) (n3:nat) :Set.set nat = Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3) let modifies_buf_3 (#t:Type) (#t':Type) (#t'':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') h h' = modifies_ref rid (to_set_3 (as_addr b) (as_addr b') (as_addr b'')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_4 (n1:nat) (n2:nat) (n3:nat) (n4:nat) :Set.set nat = Set.union (Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3)) (Set.singleton n4) let modifies_buf_4 (#t:Type) (#t':Type) (#t'':Type) (#t''':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') h h' = modifies_ref rid (to_set_4 (as_addr b) (as_addr b') (as_addr b'') (as_addr b''')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb /\ disjoint b''' bb) ==> equal h bb h' bb /\ live h' bb) (* General lemmas for the modifies_bufs clause *) let lemma_modifies_bufs_trans rid bufs h0 h1 h2 : Lemma (requires (modifies_bufs rid bufs h0 h1 /\ modifies_bufs rid bufs h1 h2)) (ensures (modifies_bufs rid bufs h0 h2)) [SMTPat (modifies_bufs rid bufs h0 h1); SMTPat (modifies_bufs rid bufs h1 h2)] = () let lemma_modifies_bufs_sub rid bufs subbufs h0 h1 : Lemma (requires (TSet.subset subbufs bufs /\ modifies_bufs rid subbufs h0 h1)) (ensures (modifies_bufs rid bufs h0 h1)) [SMTPat (modifies_bufs rid subbufs h0 h1); SMTPat (TSet.subset subbufs bufs)] = () val lemma_modifies_bufs_subset: #a:Type -> #a':Type -> h0:mem -> h1:mem -> bufs:TSet.set abuffer -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint_from_bufs b (bufs ++ (only b')) )) (ensures (disjoint_from_bufs b bufs)) [SMTPat (modifies_bufs (HS.get_tip h0) (bufs ++ (only b')) h0 h1); SMTPat (live h0 b)] let lemma_modifies_bufs_subset #a #a' h0 h1 bufs b b' = () val lemma_modifies_bufs_superset: #a:Type -> #a':Type -> h0:mem -> h1:mem -> bufs:TSet.set abuffer -> b:buffer a -> b':buffer a' -> Lemma (requires (b' `unused_in` h0 /\ live h0 b /\ disjoint_from_bufs b bufs)) (ensures (disjoint_from_bufs b (bufs ++ (only b')))) [SMTPat (modifies_bufs (HS.get_tip h0) bufs h0 h1); SMTPat (b' `unmapped_in` h0); SMTPat (live h0 b)] let lemma_modifies_bufs_superset #a #a' h0 h1 bufs b b' = () (* Specialized lemmas *) let modifies_trans_0_0 (rid:rid) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_0 rid h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_1_0 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_0_1 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_1_1 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_1_1' (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_1 rid b' h1 h2)] = () let modifies_trans_2_0 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_2_1 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_2_1' (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b' b h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b' b h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_0_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_1_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_2_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_3_3 (#t #t' #t'':Type) (rid:rid) (b:buffer t) (b':buffer t') (b'':buffer t'') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_buf_3 rid b b' b'' h1 h2)) (ensures (modifies_buf_3 rid b b' b'' h0 h2)) [SMTPat (modifies_buf_3 rid b b' b'' h0 h1); SMTPat (modifies_buf_3 rid b b' b'' h1 h2)] = () let modifies_trans_4_4 (#t #t' #t'' #t''':Type) (rid:rid) (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_4 rid b b' b'' b''' h0 h1 /\ modifies_buf_4 rid b b' b'' b''' h1 h2)) (ensures (modifies_buf_4 rid b b' b'' b''' h0 h2)) [SMTPat (modifies_buf_4 rid b b' b'' b''' h0 h1); SMTPat (modifies_buf_4 rid b b' b'' b''' h1 h2)] = () (* TODO: complete with specialized versions of every general lemma *) (* Modifies clauses that do not change the shape of the HyperStack ((HS.get_tip h1) = (HS.get_tip h0)) *) (* NB: those clauses are made abstract in order to make verification faster // Lemmas follow to allow the programmer to make use of the real definition
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h0: FStar.Monotonic.HyperStack.mem -> h1: FStar.Monotonic.HyperStack.mem -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "FStar.Monotonic.HyperStack.modifies_one", "FStar.Monotonic.HyperStack.get_tip", "FStar.Buffer.modifies_buf_0", "Prims.eq2", "FStar.Monotonic.HyperHeap.rid" ]
[]
false
false
false
true
true
let modifies_0 (h0 h1: mem) : Type0 =
modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1
false
FStar.Buffer.fst
FStar.Buffer.modifies_buf_3
val modifies_buf_3 : rid: FStar.Monotonic.HyperHeap.rid -> b: FStar.Buffer.buffer t -> b': FStar.Buffer.buffer t' -> b'': FStar.Buffer.buffer t'' -> h: FStar.Monotonic.HyperStack.mem -> h': FStar.Monotonic.HyperStack.mem -> Prims.logical
let modifies_buf_3 (#t:Type) (#t':Type) (#t'':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') h h' = modifies_ref rid (to_set_3 (as_addr b) (as_addr b') (as_addr b'')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb) ==> equal h bb h' bb /\ live h' bb)
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 42, "end_line": 260, "start_col": 0, "start_line": 257 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b'''' let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) = frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r let disjoint_ref_2 a r r' = disjoint_ref_1 a r /\ disjoint_ref_1 a r' let disjoint_ref_3 a r r' r'' = disjoint_ref_1 a r /\ disjoint_ref_2 a r' r'' let disjoint_ref_4 a r r' r'' r''' = disjoint_ref_1 a r /\ disjoint_ref_3 a r' r'' r''' let disjoint_ref_5 a r r' r'' r''' r'''' = disjoint_ref_1 a r /\ disjoint_ref_4 a r' r'' r''' r'''' val disjoint_only_lemma: #a:Type -> #a':Type -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint b b')) (ensures (disjoint_from_bufs b (only b'))) let disjoint_only_lemma #a #a' b b' = () (* Fully general modifies clause *) let modifies_bufs_and_refs (bufs:TSet.set abuffer) (refs:Set.set nat) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (Set.union (arefs bufs) refs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs /\ disjoint_from_refs b refs) ==> equal h b h' b /\ live h' b))) (* Fully general modifies clause for buffer sets *) let modifies_buffers (bufs:TSet.set abuffer) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (arefs bufs) h h' /\ (forall (#a:Type) (b:buffer a). {:pattern (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs)} (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs ==> equal h b h' b /\ live h' b)))) (* General modifies clause for buffers only *) let modifies_bufs rid buffs h h' = modifies_ref rid (arefs buffs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b buffs) ==> equal h b h' b /\ live h' b) let modifies_none h h' = HS.get_tip h' == HS.get_tip h /\ HS.modifies_transitively Set.empty h h' (* Specialized clauses for small numbers of buffers *) let modifies_buf_0 rid h h' = modifies_ref rid (Set.empty #nat) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb) ==> equal h bb h' bb /\ live h' bb) let modifies_buf_1 (#t:Type) rid (b:buffer t) h h' = //would be good to drop the rid argument on these, since they can be computed from the buffers modifies_ref rid (Set.singleton (Heap.addr_of (as_ref b))) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb) ==> equal h bb h' bb /\ live h' bb) let to_set_2 (n1:nat) (n2:nat) :Set.set nat = Set.union (Set.singleton n1) (Set.singleton n2) let modifies_buf_2 (#t:Type) (#t':Type) rid (b:buffer t) (b':buffer t') h h' = modifies_ref rid (to_set_2 (as_addr b) (as_addr b')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_3 (n1:nat) (n2:nat) (n3:nat) :Set.set nat = Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
rid: FStar.Monotonic.HyperHeap.rid -> b: FStar.Buffer.buffer t -> b': FStar.Buffer.buffer t' -> b'': FStar.Buffer.buffer t'' -> h: FStar.Monotonic.HyperStack.mem -> h': FStar.Monotonic.HyperStack.mem -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "FStar.Monotonic.HyperHeap.rid", "FStar.Buffer.buffer", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "FStar.Monotonic.HyperStack.modifies_ref", "FStar.Buffer.to_set_3", "FStar.Buffer.as_addr", "Prims.l_Forall", "Prims.l_imp", "Prims.eq2", "FStar.Buffer.frameOf", "FStar.Buffer.live", "FStar.Buffer.disjoint", "FStar.Buffer.equal", "Prims.logical" ]
[]
false
false
false
true
true
let modifies_buf_3 (#t: Type) (#t': Type) (#t'': Type) rid (b: buffer t) (b': buffer t') (b'': buffer t'') h h' =
modifies_ref rid (to_set_3 (as_addr b) (as_addr b') (as_addr b'')) h h' /\ (forall (#tt: Type) (bb: buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb) ==> equal h bb h' bb /\ live h' bb)
false
FStar.Buffer.fst
FStar.Buffer.modifies_buf_4
val modifies_buf_4 : rid: FStar.Monotonic.HyperHeap.rid -> b: FStar.Buffer.buffer t -> b': FStar.Buffer.buffer t' -> b'': FStar.Buffer.buffer t'' -> b''': FStar.Buffer.buffer t''' -> h: FStar.Monotonic.HyperStack.mem -> h': FStar.Monotonic.HyperStack.mem -> Prims.logical
let modifies_buf_4 (#t:Type) (#t':Type) (#t'':Type) (#t''':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') h h' = modifies_ref rid (to_set_4 (as_addr b) (as_addr b') (as_addr b'') (as_addr b''')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb /\ disjoint b''' bb) ==> equal h bb h' bb /\ live h' bb)
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 42, "end_line": 268, "start_col": 0, "start_line": 265 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b'''' let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) = frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r let disjoint_ref_2 a r r' = disjoint_ref_1 a r /\ disjoint_ref_1 a r' let disjoint_ref_3 a r r' r'' = disjoint_ref_1 a r /\ disjoint_ref_2 a r' r'' let disjoint_ref_4 a r r' r'' r''' = disjoint_ref_1 a r /\ disjoint_ref_3 a r' r'' r''' let disjoint_ref_5 a r r' r'' r''' r'''' = disjoint_ref_1 a r /\ disjoint_ref_4 a r' r'' r''' r'''' val disjoint_only_lemma: #a:Type -> #a':Type -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint b b')) (ensures (disjoint_from_bufs b (only b'))) let disjoint_only_lemma #a #a' b b' = () (* Fully general modifies clause *) let modifies_bufs_and_refs (bufs:TSet.set abuffer) (refs:Set.set nat) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (Set.union (arefs bufs) refs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs /\ disjoint_from_refs b refs) ==> equal h b h' b /\ live h' b))) (* Fully general modifies clause for buffer sets *) let modifies_buffers (bufs:TSet.set abuffer) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (arefs bufs) h h' /\ (forall (#a:Type) (b:buffer a). {:pattern (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs)} (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs ==> equal h b h' b /\ live h' b)))) (* General modifies clause for buffers only *) let modifies_bufs rid buffs h h' = modifies_ref rid (arefs buffs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b buffs) ==> equal h b h' b /\ live h' b) let modifies_none h h' = HS.get_tip h' == HS.get_tip h /\ HS.modifies_transitively Set.empty h h' (* Specialized clauses for small numbers of buffers *) let modifies_buf_0 rid h h' = modifies_ref rid (Set.empty #nat) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb) ==> equal h bb h' bb /\ live h' bb) let modifies_buf_1 (#t:Type) rid (b:buffer t) h h' = //would be good to drop the rid argument on these, since they can be computed from the buffers modifies_ref rid (Set.singleton (Heap.addr_of (as_ref b))) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb) ==> equal h bb h' bb /\ live h' bb) let to_set_2 (n1:nat) (n2:nat) :Set.set nat = Set.union (Set.singleton n1) (Set.singleton n2) let modifies_buf_2 (#t:Type) (#t':Type) rid (b:buffer t) (b':buffer t') h h' = modifies_ref rid (to_set_2 (as_addr b) (as_addr b')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_3 (n1:nat) (n2:nat) (n3:nat) :Set.set nat = Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3) let modifies_buf_3 (#t:Type) (#t':Type) (#t'':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') h h' = modifies_ref rid (to_set_3 (as_addr b) (as_addr b') (as_addr b'')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_4 (n1:nat) (n2:nat) (n3:nat) (n4:nat) :Set.set nat = Set.union (Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3)) (Set.singleton n4)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
rid: FStar.Monotonic.HyperHeap.rid -> b: FStar.Buffer.buffer t -> b': FStar.Buffer.buffer t' -> b'': FStar.Buffer.buffer t'' -> b''': FStar.Buffer.buffer t''' -> h: FStar.Monotonic.HyperStack.mem -> h': FStar.Monotonic.HyperStack.mem -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "FStar.Monotonic.HyperHeap.rid", "FStar.Buffer.buffer", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "FStar.Monotonic.HyperStack.modifies_ref", "FStar.Buffer.to_set_4", "FStar.Buffer.as_addr", "Prims.l_Forall", "Prims.l_imp", "Prims.eq2", "FStar.Buffer.frameOf", "FStar.Buffer.live", "FStar.Buffer.disjoint", "FStar.Buffer.equal", "Prims.logical" ]
[]
false
false
false
true
true
let modifies_buf_4 (#t: Type) (#t': Type) (#t'': Type) (#t''': Type) rid (b: buffer t) (b': buffer t') (b'': buffer t'') (b''': buffer t''') h h' =
modifies_ref rid (to_set_4 (as_addr b) (as_addr b') (as_addr b'') (as_addr b''')) h h' /\ (forall (#tt: Type) (bb: buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb /\ disjoint b''' bb) ==> equal h bb h' bb /\ live h' bb)
false
FStar.Buffer.fst
FStar.Buffer.modifies_1
val modifies_1 (#a: Type) (b: buffer a) (h0 h1: mem) : Type0
val modifies_1 (#a: Type) (b: buffer a) (h0 h1: mem) : Type0
let modifies_1 (#a:Type) (b:buffer a) (h0 h1:mem) :Type0 = let rid = frameOf b in modifies_one rid h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.get_tip h0 == HS.get_tip h1
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 88, "end_line": 392, "start_col": 0, "start_line": 390 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b'''' let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) = frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r let disjoint_ref_2 a r r' = disjoint_ref_1 a r /\ disjoint_ref_1 a r' let disjoint_ref_3 a r r' r'' = disjoint_ref_1 a r /\ disjoint_ref_2 a r' r'' let disjoint_ref_4 a r r' r'' r''' = disjoint_ref_1 a r /\ disjoint_ref_3 a r' r'' r''' let disjoint_ref_5 a r r' r'' r''' r'''' = disjoint_ref_1 a r /\ disjoint_ref_4 a r' r'' r''' r'''' val disjoint_only_lemma: #a:Type -> #a':Type -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint b b')) (ensures (disjoint_from_bufs b (only b'))) let disjoint_only_lemma #a #a' b b' = () (* Fully general modifies clause *) let modifies_bufs_and_refs (bufs:TSet.set abuffer) (refs:Set.set nat) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (Set.union (arefs bufs) refs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs /\ disjoint_from_refs b refs) ==> equal h b h' b /\ live h' b))) (* Fully general modifies clause for buffer sets *) let modifies_buffers (bufs:TSet.set abuffer) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (arefs bufs) h h' /\ (forall (#a:Type) (b:buffer a). {:pattern (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs)} (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs ==> equal h b h' b /\ live h' b)))) (* General modifies clause for buffers only *) let modifies_bufs rid buffs h h' = modifies_ref rid (arefs buffs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b buffs) ==> equal h b h' b /\ live h' b) let modifies_none h h' = HS.get_tip h' == HS.get_tip h /\ HS.modifies_transitively Set.empty h h' (* Specialized clauses for small numbers of buffers *) let modifies_buf_0 rid h h' = modifies_ref rid (Set.empty #nat) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb) ==> equal h bb h' bb /\ live h' bb) let modifies_buf_1 (#t:Type) rid (b:buffer t) h h' = //would be good to drop the rid argument on these, since they can be computed from the buffers modifies_ref rid (Set.singleton (Heap.addr_of (as_ref b))) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb) ==> equal h bb h' bb /\ live h' bb) let to_set_2 (n1:nat) (n2:nat) :Set.set nat = Set.union (Set.singleton n1) (Set.singleton n2) let modifies_buf_2 (#t:Type) (#t':Type) rid (b:buffer t) (b':buffer t') h h' = modifies_ref rid (to_set_2 (as_addr b) (as_addr b')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_3 (n1:nat) (n2:nat) (n3:nat) :Set.set nat = Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3) let modifies_buf_3 (#t:Type) (#t':Type) (#t'':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') h h' = modifies_ref rid (to_set_3 (as_addr b) (as_addr b') (as_addr b'')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_4 (n1:nat) (n2:nat) (n3:nat) (n4:nat) :Set.set nat = Set.union (Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3)) (Set.singleton n4) let modifies_buf_4 (#t:Type) (#t':Type) (#t'':Type) (#t''':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') h h' = modifies_ref rid (to_set_4 (as_addr b) (as_addr b') (as_addr b'') (as_addr b''')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb /\ disjoint b''' bb) ==> equal h bb h' bb /\ live h' bb) (* General lemmas for the modifies_bufs clause *) let lemma_modifies_bufs_trans rid bufs h0 h1 h2 : Lemma (requires (modifies_bufs rid bufs h0 h1 /\ modifies_bufs rid bufs h1 h2)) (ensures (modifies_bufs rid bufs h0 h2)) [SMTPat (modifies_bufs rid bufs h0 h1); SMTPat (modifies_bufs rid bufs h1 h2)] = () let lemma_modifies_bufs_sub rid bufs subbufs h0 h1 : Lemma (requires (TSet.subset subbufs bufs /\ modifies_bufs rid subbufs h0 h1)) (ensures (modifies_bufs rid bufs h0 h1)) [SMTPat (modifies_bufs rid subbufs h0 h1); SMTPat (TSet.subset subbufs bufs)] = () val lemma_modifies_bufs_subset: #a:Type -> #a':Type -> h0:mem -> h1:mem -> bufs:TSet.set abuffer -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint_from_bufs b (bufs ++ (only b')) )) (ensures (disjoint_from_bufs b bufs)) [SMTPat (modifies_bufs (HS.get_tip h0) (bufs ++ (only b')) h0 h1); SMTPat (live h0 b)] let lemma_modifies_bufs_subset #a #a' h0 h1 bufs b b' = () val lemma_modifies_bufs_superset: #a:Type -> #a':Type -> h0:mem -> h1:mem -> bufs:TSet.set abuffer -> b:buffer a -> b':buffer a' -> Lemma (requires (b' `unused_in` h0 /\ live h0 b /\ disjoint_from_bufs b bufs)) (ensures (disjoint_from_bufs b (bufs ++ (only b')))) [SMTPat (modifies_bufs (HS.get_tip h0) bufs h0 h1); SMTPat (b' `unmapped_in` h0); SMTPat (live h0 b)] let lemma_modifies_bufs_superset #a #a' h0 h1 bufs b b' = () (* Specialized lemmas *) let modifies_trans_0_0 (rid:rid) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_0 rid h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_1_0 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_0_1 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_1_1 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_1_1' (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_1 rid b' h1 h2)] = () let modifies_trans_2_0 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_2_1 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_2_1' (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b' b h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b' b h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_0_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_1_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_2_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_3_3 (#t #t' #t'':Type) (rid:rid) (b:buffer t) (b':buffer t') (b'':buffer t'') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_buf_3 rid b b' b'' h1 h2)) (ensures (modifies_buf_3 rid b b' b'' h0 h2)) [SMTPat (modifies_buf_3 rid b b' b'' h0 h1); SMTPat (modifies_buf_3 rid b b' b'' h1 h2)] = () let modifies_trans_4_4 (#t #t' #t'' #t''':Type) (rid:rid) (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_4 rid b b' b'' b''' h0 h1 /\ modifies_buf_4 rid b b' b'' b''' h1 h2)) (ensures (modifies_buf_4 rid b b' b'' b''' h0 h2)) [SMTPat (modifies_buf_4 rid b b' b'' b''' h0 h1); SMTPat (modifies_buf_4 rid b b' b'' b''' h1 h2)] = () (* TODO: complete with specialized versions of every general lemma *) (* Modifies clauses that do not change the shape of the HyperStack ((HS.get_tip h1) = (HS.get_tip h0)) *) (* NB: those clauses are made abstract in order to make verification faster // Lemmas follow to allow the programmer to make use of the real definition // of those predicates in a general setting *) let modifies_0 (h0 h1:mem) :Type0 = modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 (* This one is very generic: it says // * - some references have changed in the frame of b, but
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Buffer.buffer a -> h0: FStar.Monotonic.HyperStack.mem -> h1: FStar.Monotonic.HyperStack.mem -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Buffer.buffer", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "FStar.Monotonic.HyperStack.modifies_one", "FStar.Buffer.modifies_buf_1", "Prims.eq2", "FStar.Monotonic.HyperHeap.rid", "FStar.Monotonic.HyperStack.get_tip", "FStar.Buffer.frameOf" ]
[]
false
false
false
true
true
let modifies_1 (#a: Type) (b: buffer a) (h0 h1: mem) : Type0 =
let rid = frameOf b in modifies_one rid h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.get_tip h0 == HS.get_tip h1
false
FStar.Buffer.fst
FStar.Buffer.to_set_3
val to_set_3 (n1 n2 n3: nat) : Set.set nat
val to_set_3 (n1 n2 n3: nat) : Set.set nat
let to_set_3 (n1:nat) (n2:nat) (n3:nat) :Set.set nat = Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3)
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 133, "end_line": 255, "start_col": 0, "start_line": 255 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b'''' let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) = frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r let disjoint_ref_2 a r r' = disjoint_ref_1 a r /\ disjoint_ref_1 a r' let disjoint_ref_3 a r r' r'' = disjoint_ref_1 a r /\ disjoint_ref_2 a r' r'' let disjoint_ref_4 a r r' r'' r''' = disjoint_ref_1 a r /\ disjoint_ref_3 a r' r'' r''' let disjoint_ref_5 a r r' r'' r''' r'''' = disjoint_ref_1 a r /\ disjoint_ref_4 a r' r'' r''' r'''' val disjoint_only_lemma: #a:Type -> #a':Type -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint b b')) (ensures (disjoint_from_bufs b (only b'))) let disjoint_only_lemma #a #a' b b' = () (* Fully general modifies clause *) let modifies_bufs_and_refs (bufs:TSet.set abuffer) (refs:Set.set nat) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (Set.union (arefs bufs) refs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs /\ disjoint_from_refs b refs) ==> equal h b h' b /\ live h' b))) (* Fully general modifies clause for buffer sets *) let modifies_buffers (bufs:TSet.set abuffer) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (arefs bufs) h h' /\ (forall (#a:Type) (b:buffer a). {:pattern (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs)} (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs ==> equal h b h' b /\ live h' b)))) (* General modifies clause for buffers only *) let modifies_bufs rid buffs h h' = modifies_ref rid (arefs buffs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b buffs) ==> equal h b h' b /\ live h' b) let modifies_none h h' = HS.get_tip h' == HS.get_tip h /\ HS.modifies_transitively Set.empty h h' (* Specialized clauses for small numbers of buffers *) let modifies_buf_0 rid h h' = modifies_ref rid (Set.empty #nat) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb) ==> equal h bb h' bb /\ live h' bb) let modifies_buf_1 (#t:Type) rid (b:buffer t) h h' = //would be good to drop the rid argument on these, since they can be computed from the buffers modifies_ref rid (Set.singleton (Heap.addr_of (as_ref b))) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb) ==> equal h bb h' bb /\ live h' bb) let to_set_2 (n1:nat) (n2:nat) :Set.set nat = Set.union (Set.singleton n1) (Set.singleton n2) let modifies_buf_2 (#t:Type) (#t':Type) rid (b:buffer t) (b':buffer t') h h' = modifies_ref rid (to_set_2 (as_addr b) (as_addr b')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb) ==> equal h bb h' bb /\ live h' bb)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n1: Prims.nat -> n2: Prims.nat -> n3: Prims.nat -> FStar.Set.set Prims.nat
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "FStar.Set.union", "FStar.Set.singleton", "FStar.Set.set" ]
[]
false
false
false
true
false
let to_set_3 (n1 n2 n3: nat) : Set.set nat =
Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3)
false
FStar.Buffer.fst
FStar.Buffer.to_set_4
val to_set_4 (n1 n2 n3 n4: nat) : Set.set nat
val to_set_4 (n1 n2 n3 n4: nat) : Set.set nat
let to_set_4 (n1:nat) (n2:nat) (n3:nat) (n4:nat) :Set.set nat = Set.union (Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3)) (Set.singleton n4)
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 111, "end_line": 263, "start_col": 0, "start_line": 262 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b'''' let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) = frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r let disjoint_ref_2 a r r' = disjoint_ref_1 a r /\ disjoint_ref_1 a r' let disjoint_ref_3 a r r' r'' = disjoint_ref_1 a r /\ disjoint_ref_2 a r' r'' let disjoint_ref_4 a r r' r'' r''' = disjoint_ref_1 a r /\ disjoint_ref_3 a r' r'' r''' let disjoint_ref_5 a r r' r'' r''' r'''' = disjoint_ref_1 a r /\ disjoint_ref_4 a r' r'' r''' r'''' val disjoint_only_lemma: #a:Type -> #a':Type -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint b b')) (ensures (disjoint_from_bufs b (only b'))) let disjoint_only_lemma #a #a' b b' = () (* Fully general modifies clause *) let modifies_bufs_and_refs (bufs:TSet.set abuffer) (refs:Set.set nat) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (Set.union (arefs bufs) refs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs /\ disjoint_from_refs b refs) ==> equal h b h' b /\ live h' b))) (* Fully general modifies clause for buffer sets *) let modifies_buffers (bufs:TSet.set abuffer) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (arefs bufs) h h' /\ (forall (#a:Type) (b:buffer a). {:pattern (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs)} (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs ==> equal h b h' b /\ live h' b)))) (* General modifies clause for buffers only *) let modifies_bufs rid buffs h h' = modifies_ref rid (arefs buffs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b buffs) ==> equal h b h' b /\ live h' b) let modifies_none h h' = HS.get_tip h' == HS.get_tip h /\ HS.modifies_transitively Set.empty h h' (* Specialized clauses for small numbers of buffers *) let modifies_buf_0 rid h h' = modifies_ref rid (Set.empty #nat) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb) ==> equal h bb h' bb /\ live h' bb) let modifies_buf_1 (#t:Type) rid (b:buffer t) h h' = //would be good to drop the rid argument on these, since they can be computed from the buffers modifies_ref rid (Set.singleton (Heap.addr_of (as_ref b))) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb) ==> equal h bb h' bb /\ live h' bb) let to_set_2 (n1:nat) (n2:nat) :Set.set nat = Set.union (Set.singleton n1) (Set.singleton n2) let modifies_buf_2 (#t:Type) (#t':Type) rid (b:buffer t) (b':buffer t') h h' = modifies_ref rid (to_set_2 (as_addr b) (as_addr b')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_3 (n1:nat) (n2:nat) (n3:nat) :Set.set nat = Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3) let modifies_buf_3 (#t:Type) (#t':Type) (#t'':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') h h' = modifies_ref rid (to_set_3 (as_addr b) (as_addr b') (as_addr b'')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb) ==> equal h bb h' bb /\ live h' bb)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n1: Prims.nat -> n2: Prims.nat -> n3: Prims.nat -> n4: Prims.nat -> FStar.Set.set Prims.nat
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "FStar.Set.union", "FStar.Set.singleton", "FStar.Set.set" ]
[]
false
false
false
true
false
let to_set_4 (n1 n2 n3 n4: nat) : Set.set nat =
Set.union (Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3)) (Set.singleton n4)
false
FStar.Buffer.fst
FStar.Buffer.modifies_2_1
val modifies_2_1 (#a: Type) (b: buffer a) (h0 h1: mem) : Type0
val modifies_2_1 (#a: Type) (b: buffer a) (h0 h1: mem) : Type0
let modifies_2_1 (#a:Type) (b:buffer a) (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in ((rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 )))
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 80, "end_line": 399, "start_col": 0, "start_line": 394 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b'''' let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) = frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r let disjoint_ref_2 a r r' = disjoint_ref_1 a r /\ disjoint_ref_1 a r' let disjoint_ref_3 a r r' r'' = disjoint_ref_1 a r /\ disjoint_ref_2 a r' r'' let disjoint_ref_4 a r r' r'' r''' = disjoint_ref_1 a r /\ disjoint_ref_3 a r' r'' r''' let disjoint_ref_5 a r r' r'' r''' r'''' = disjoint_ref_1 a r /\ disjoint_ref_4 a r' r'' r''' r'''' val disjoint_only_lemma: #a:Type -> #a':Type -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint b b')) (ensures (disjoint_from_bufs b (only b'))) let disjoint_only_lemma #a #a' b b' = () (* Fully general modifies clause *) let modifies_bufs_and_refs (bufs:TSet.set abuffer) (refs:Set.set nat) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (Set.union (arefs bufs) refs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs /\ disjoint_from_refs b refs) ==> equal h b h' b /\ live h' b))) (* Fully general modifies clause for buffer sets *) let modifies_buffers (bufs:TSet.set abuffer) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (arefs bufs) h h' /\ (forall (#a:Type) (b:buffer a). {:pattern (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs)} (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs ==> equal h b h' b /\ live h' b)))) (* General modifies clause for buffers only *) let modifies_bufs rid buffs h h' = modifies_ref rid (arefs buffs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b buffs) ==> equal h b h' b /\ live h' b) let modifies_none h h' = HS.get_tip h' == HS.get_tip h /\ HS.modifies_transitively Set.empty h h' (* Specialized clauses for small numbers of buffers *) let modifies_buf_0 rid h h' = modifies_ref rid (Set.empty #nat) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb) ==> equal h bb h' bb /\ live h' bb) let modifies_buf_1 (#t:Type) rid (b:buffer t) h h' = //would be good to drop the rid argument on these, since they can be computed from the buffers modifies_ref rid (Set.singleton (Heap.addr_of (as_ref b))) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb) ==> equal h bb h' bb /\ live h' bb) let to_set_2 (n1:nat) (n2:nat) :Set.set nat = Set.union (Set.singleton n1) (Set.singleton n2) let modifies_buf_2 (#t:Type) (#t':Type) rid (b:buffer t) (b':buffer t') h h' = modifies_ref rid (to_set_2 (as_addr b) (as_addr b')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_3 (n1:nat) (n2:nat) (n3:nat) :Set.set nat = Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3) let modifies_buf_3 (#t:Type) (#t':Type) (#t'':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') h h' = modifies_ref rid (to_set_3 (as_addr b) (as_addr b') (as_addr b'')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_4 (n1:nat) (n2:nat) (n3:nat) (n4:nat) :Set.set nat = Set.union (Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3)) (Set.singleton n4) let modifies_buf_4 (#t:Type) (#t':Type) (#t'':Type) (#t''':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') h h' = modifies_ref rid (to_set_4 (as_addr b) (as_addr b') (as_addr b'') (as_addr b''')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb /\ disjoint b''' bb) ==> equal h bb h' bb /\ live h' bb) (* General lemmas for the modifies_bufs clause *) let lemma_modifies_bufs_trans rid bufs h0 h1 h2 : Lemma (requires (modifies_bufs rid bufs h0 h1 /\ modifies_bufs rid bufs h1 h2)) (ensures (modifies_bufs rid bufs h0 h2)) [SMTPat (modifies_bufs rid bufs h0 h1); SMTPat (modifies_bufs rid bufs h1 h2)] = () let lemma_modifies_bufs_sub rid bufs subbufs h0 h1 : Lemma (requires (TSet.subset subbufs bufs /\ modifies_bufs rid subbufs h0 h1)) (ensures (modifies_bufs rid bufs h0 h1)) [SMTPat (modifies_bufs rid subbufs h0 h1); SMTPat (TSet.subset subbufs bufs)] = () val lemma_modifies_bufs_subset: #a:Type -> #a':Type -> h0:mem -> h1:mem -> bufs:TSet.set abuffer -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint_from_bufs b (bufs ++ (only b')) )) (ensures (disjoint_from_bufs b bufs)) [SMTPat (modifies_bufs (HS.get_tip h0) (bufs ++ (only b')) h0 h1); SMTPat (live h0 b)] let lemma_modifies_bufs_subset #a #a' h0 h1 bufs b b' = () val lemma_modifies_bufs_superset: #a:Type -> #a':Type -> h0:mem -> h1:mem -> bufs:TSet.set abuffer -> b:buffer a -> b':buffer a' -> Lemma (requires (b' `unused_in` h0 /\ live h0 b /\ disjoint_from_bufs b bufs)) (ensures (disjoint_from_bufs b (bufs ++ (only b')))) [SMTPat (modifies_bufs (HS.get_tip h0) bufs h0 h1); SMTPat (b' `unmapped_in` h0); SMTPat (live h0 b)] let lemma_modifies_bufs_superset #a #a' h0 h1 bufs b b' = () (* Specialized lemmas *) let modifies_trans_0_0 (rid:rid) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_0 rid h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_1_0 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_0_1 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_1_1 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_1_1' (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_1 rid b' h1 h2)] = () let modifies_trans_2_0 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_2_1 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_2_1' (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b' b h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b' b h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_0_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_1_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_2_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_3_3 (#t #t' #t'':Type) (rid:rid) (b:buffer t) (b':buffer t') (b'':buffer t'') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_buf_3 rid b b' b'' h1 h2)) (ensures (modifies_buf_3 rid b b' b'' h0 h2)) [SMTPat (modifies_buf_3 rid b b' b'' h0 h1); SMTPat (modifies_buf_3 rid b b' b'' h1 h2)] = () let modifies_trans_4_4 (#t #t' #t'' #t''':Type) (rid:rid) (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_4 rid b b' b'' b''' h0 h1 /\ modifies_buf_4 rid b b' b'' b''' h1 h2)) (ensures (modifies_buf_4 rid b b' b'' b''' h0 h2)) [SMTPat (modifies_buf_4 rid b b' b'' b''' h0 h1); SMTPat (modifies_buf_4 rid b b' b'' b''' h1 h2)] = () (* TODO: complete with specialized versions of every general lemma *) (* Modifies clauses that do not change the shape of the HyperStack ((HS.get_tip h1) = (HS.get_tip h0)) *) (* NB: those clauses are made abstract in order to make verification faster // Lemmas follow to allow the programmer to make use of the real definition // of those predicates in a general setting *) let modifies_0 (h0 h1:mem) :Type0 = modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 (* This one is very generic: it says // * - some references have changed in the frame of b, but // * - among all buffers in this frame, b is the only one that changed. *) let modifies_1 (#a:Type) (b:buffer a) (h0 h1:mem) :Type0 = let rid = frameOf b in modifies_one rid h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.get_tip h0 == HS.get_tip h1
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Buffer.buffer a -> h0: FStar.Monotonic.HyperStack.mem -> h1: FStar.Monotonic.HyperStack.mem -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Buffer.buffer", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "FStar.Monotonic.HyperHeap.rid", "FStar.Monotonic.HyperStack.get_tip", "Prims.l_or", "FStar.Buffer.modifies_buf_1", "FStar.Monotonic.HyperStack.modifies_one", "Prims.l_not", "FStar.Monotonic.HyperStack.modifies", "FStar.Set.union", "FStar.Set.singleton", "FStar.Buffer.modifies_buf_0", "FStar.Buffer.frameOf" ]
[]
false
false
false
true
true
let modifies_2_1 (#a: Type) (b: buffer a) (h0 h1: mem) : Type0 =
HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in ((rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1)))
false
FStar.Buffer.fst
FStar.Buffer.modifies_2
val modifies_2 (#a #a': Type) (b: buffer a) (b': buffer a') (h0 h1: mem) : Type0
val modifies_2 (#a #a': Type) (b: buffer a) (b': buffer a') (h0 h1: mem) : Type0
let modifies_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= rid' /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 )))
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 72, "end_line": 406, "start_col": 0, "start_line": 401 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b'''' let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) = frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r let disjoint_ref_2 a r r' = disjoint_ref_1 a r /\ disjoint_ref_1 a r' let disjoint_ref_3 a r r' r'' = disjoint_ref_1 a r /\ disjoint_ref_2 a r' r'' let disjoint_ref_4 a r r' r'' r''' = disjoint_ref_1 a r /\ disjoint_ref_3 a r' r'' r''' let disjoint_ref_5 a r r' r'' r''' r'''' = disjoint_ref_1 a r /\ disjoint_ref_4 a r' r'' r''' r'''' val disjoint_only_lemma: #a:Type -> #a':Type -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint b b')) (ensures (disjoint_from_bufs b (only b'))) let disjoint_only_lemma #a #a' b b' = () (* Fully general modifies clause *) let modifies_bufs_and_refs (bufs:TSet.set abuffer) (refs:Set.set nat) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (Set.union (arefs bufs) refs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs /\ disjoint_from_refs b refs) ==> equal h b h' b /\ live h' b))) (* Fully general modifies clause for buffer sets *) let modifies_buffers (bufs:TSet.set abuffer) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (arefs bufs) h h' /\ (forall (#a:Type) (b:buffer a). {:pattern (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs)} (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs ==> equal h b h' b /\ live h' b)))) (* General modifies clause for buffers only *) let modifies_bufs rid buffs h h' = modifies_ref rid (arefs buffs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b buffs) ==> equal h b h' b /\ live h' b) let modifies_none h h' = HS.get_tip h' == HS.get_tip h /\ HS.modifies_transitively Set.empty h h' (* Specialized clauses for small numbers of buffers *) let modifies_buf_0 rid h h' = modifies_ref rid (Set.empty #nat) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb) ==> equal h bb h' bb /\ live h' bb) let modifies_buf_1 (#t:Type) rid (b:buffer t) h h' = //would be good to drop the rid argument on these, since they can be computed from the buffers modifies_ref rid (Set.singleton (Heap.addr_of (as_ref b))) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb) ==> equal h bb h' bb /\ live h' bb) let to_set_2 (n1:nat) (n2:nat) :Set.set nat = Set.union (Set.singleton n1) (Set.singleton n2) let modifies_buf_2 (#t:Type) (#t':Type) rid (b:buffer t) (b':buffer t') h h' = modifies_ref rid (to_set_2 (as_addr b) (as_addr b')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_3 (n1:nat) (n2:nat) (n3:nat) :Set.set nat = Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3) let modifies_buf_3 (#t:Type) (#t':Type) (#t'':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') h h' = modifies_ref rid (to_set_3 (as_addr b) (as_addr b') (as_addr b'')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_4 (n1:nat) (n2:nat) (n3:nat) (n4:nat) :Set.set nat = Set.union (Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3)) (Set.singleton n4) let modifies_buf_4 (#t:Type) (#t':Type) (#t'':Type) (#t''':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') h h' = modifies_ref rid (to_set_4 (as_addr b) (as_addr b') (as_addr b'') (as_addr b''')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb /\ disjoint b''' bb) ==> equal h bb h' bb /\ live h' bb) (* General lemmas for the modifies_bufs clause *) let lemma_modifies_bufs_trans rid bufs h0 h1 h2 : Lemma (requires (modifies_bufs rid bufs h0 h1 /\ modifies_bufs rid bufs h1 h2)) (ensures (modifies_bufs rid bufs h0 h2)) [SMTPat (modifies_bufs rid bufs h0 h1); SMTPat (modifies_bufs rid bufs h1 h2)] = () let lemma_modifies_bufs_sub rid bufs subbufs h0 h1 : Lemma (requires (TSet.subset subbufs bufs /\ modifies_bufs rid subbufs h0 h1)) (ensures (modifies_bufs rid bufs h0 h1)) [SMTPat (modifies_bufs rid subbufs h0 h1); SMTPat (TSet.subset subbufs bufs)] = () val lemma_modifies_bufs_subset: #a:Type -> #a':Type -> h0:mem -> h1:mem -> bufs:TSet.set abuffer -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint_from_bufs b (bufs ++ (only b')) )) (ensures (disjoint_from_bufs b bufs)) [SMTPat (modifies_bufs (HS.get_tip h0) (bufs ++ (only b')) h0 h1); SMTPat (live h0 b)] let lemma_modifies_bufs_subset #a #a' h0 h1 bufs b b' = () val lemma_modifies_bufs_superset: #a:Type -> #a':Type -> h0:mem -> h1:mem -> bufs:TSet.set abuffer -> b:buffer a -> b':buffer a' -> Lemma (requires (b' `unused_in` h0 /\ live h0 b /\ disjoint_from_bufs b bufs)) (ensures (disjoint_from_bufs b (bufs ++ (only b')))) [SMTPat (modifies_bufs (HS.get_tip h0) bufs h0 h1); SMTPat (b' `unmapped_in` h0); SMTPat (live h0 b)] let lemma_modifies_bufs_superset #a #a' h0 h1 bufs b b' = () (* Specialized lemmas *) let modifies_trans_0_0 (rid:rid) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_0 rid h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_1_0 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_0_1 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_1_1 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_1_1' (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_1 rid b' h1 h2)] = () let modifies_trans_2_0 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_2_1 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_2_1' (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b' b h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b' b h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_0_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_1_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_2_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_3_3 (#t #t' #t'':Type) (rid:rid) (b:buffer t) (b':buffer t') (b'':buffer t'') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_buf_3 rid b b' b'' h1 h2)) (ensures (modifies_buf_3 rid b b' b'' h0 h2)) [SMTPat (modifies_buf_3 rid b b' b'' h0 h1); SMTPat (modifies_buf_3 rid b b' b'' h1 h2)] = () let modifies_trans_4_4 (#t #t' #t'' #t''':Type) (rid:rid) (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_4 rid b b' b'' b''' h0 h1 /\ modifies_buf_4 rid b b' b'' b''' h1 h2)) (ensures (modifies_buf_4 rid b b' b'' b''' h0 h2)) [SMTPat (modifies_buf_4 rid b b' b'' b''' h0 h1); SMTPat (modifies_buf_4 rid b b' b'' b''' h1 h2)] = () (* TODO: complete with specialized versions of every general lemma *) (* Modifies clauses that do not change the shape of the HyperStack ((HS.get_tip h1) = (HS.get_tip h0)) *) (* NB: those clauses are made abstract in order to make verification faster // Lemmas follow to allow the programmer to make use of the real definition // of those predicates in a general setting *) let modifies_0 (h0 h1:mem) :Type0 = modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 (* This one is very generic: it says // * - some references have changed in the frame of b, but // * - among all buffers in this frame, b is the only one that changed. *) let modifies_1 (#a:Type) (b:buffer a) (h0 h1:mem) :Type0 = let rid = frameOf b in modifies_one rid h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 let modifies_2_1 (#a:Type) (b:buffer a) (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in ((rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 )))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Buffer.buffer a -> b': FStar.Buffer.buffer a' -> h0: FStar.Monotonic.HyperStack.mem -> h1: FStar.Monotonic.HyperStack.mem -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Buffer.buffer", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "FStar.Monotonic.HyperHeap.rid", "FStar.Monotonic.HyperStack.get_tip", "Prims.l_or", "FStar.Buffer.modifies_buf_2", "FStar.Monotonic.HyperStack.modifies_one", "Prims.l_not", "FStar.Monotonic.HyperStack.modifies", "FStar.Set.union", "FStar.Set.singleton", "FStar.Buffer.modifies_buf_1", "FStar.Buffer.frameOf" ]
[]
false
false
false
true
true
let modifies_2 (#a #a': Type) (b: buffer a) (b': buffer a') (h0 h1: mem) : Type0 =
HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= rid' /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1)))
false
FStar.Buffer.fst
FStar.Buffer.modifies_3
val modifies_3 (#a #a' #a'': Type) (b: buffer a) (b': buffer a') (b'': buffer a'') (h0 h1: mem) : Type0
val modifies_3 (#a #a' #a'': Type) (b: buffer a) (b': buffer a') (b'': buffer a'') (h0 h1: mem) : Type0
let modifies_3 (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in let rid'' = frameOf b'' in ((rid == rid' /\ rid' == rid'' /\ modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid =!= rid' /\ rid' == rid'' /\ modifies_buf_2 rid' b' b'' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid == rid'' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b'' h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= rid'' /\ rid =!= rid'' /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton rid'')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1)))
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 105, "end_line": 420, "start_col": 0, "start_line": 408 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b'''' let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) = frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r let disjoint_ref_2 a r r' = disjoint_ref_1 a r /\ disjoint_ref_1 a r' let disjoint_ref_3 a r r' r'' = disjoint_ref_1 a r /\ disjoint_ref_2 a r' r'' let disjoint_ref_4 a r r' r'' r''' = disjoint_ref_1 a r /\ disjoint_ref_3 a r' r'' r''' let disjoint_ref_5 a r r' r'' r''' r'''' = disjoint_ref_1 a r /\ disjoint_ref_4 a r' r'' r''' r'''' val disjoint_only_lemma: #a:Type -> #a':Type -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint b b')) (ensures (disjoint_from_bufs b (only b'))) let disjoint_only_lemma #a #a' b b' = () (* Fully general modifies clause *) let modifies_bufs_and_refs (bufs:TSet.set abuffer) (refs:Set.set nat) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (Set.union (arefs bufs) refs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs /\ disjoint_from_refs b refs) ==> equal h b h' b /\ live h' b))) (* Fully general modifies clause for buffer sets *) let modifies_buffers (bufs:TSet.set abuffer) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (arefs bufs) h h' /\ (forall (#a:Type) (b:buffer a). {:pattern (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs)} (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs ==> equal h b h' b /\ live h' b)))) (* General modifies clause for buffers only *) let modifies_bufs rid buffs h h' = modifies_ref rid (arefs buffs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b buffs) ==> equal h b h' b /\ live h' b) let modifies_none h h' = HS.get_tip h' == HS.get_tip h /\ HS.modifies_transitively Set.empty h h' (* Specialized clauses for small numbers of buffers *) let modifies_buf_0 rid h h' = modifies_ref rid (Set.empty #nat) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb) ==> equal h bb h' bb /\ live h' bb) let modifies_buf_1 (#t:Type) rid (b:buffer t) h h' = //would be good to drop the rid argument on these, since they can be computed from the buffers modifies_ref rid (Set.singleton (Heap.addr_of (as_ref b))) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb) ==> equal h bb h' bb /\ live h' bb) let to_set_2 (n1:nat) (n2:nat) :Set.set nat = Set.union (Set.singleton n1) (Set.singleton n2) let modifies_buf_2 (#t:Type) (#t':Type) rid (b:buffer t) (b':buffer t') h h' = modifies_ref rid (to_set_2 (as_addr b) (as_addr b')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_3 (n1:nat) (n2:nat) (n3:nat) :Set.set nat = Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3) let modifies_buf_3 (#t:Type) (#t':Type) (#t'':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') h h' = modifies_ref rid (to_set_3 (as_addr b) (as_addr b') (as_addr b'')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_4 (n1:nat) (n2:nat) (n3:nat) (n4:nat) :Set.set nat = Set.union (Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3)) (Set.singleton n4) let modifies_buf_4 (#t:Type) (#t':Type) (#t'':Type) (#t''':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') h h' = modifies_ref rid (to_set_4 (as_addr b) (as_addr b') (as_addr b'') (as_addr b''')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb /\ disjoint b''' bb) ==> equal h bb h' bb /\ live h' bb) (* General lemmas for the modifies_bufs clause *) let lemma_modifies_bufs_trans rid bufs h0 h1 h2 : Lemma (requires (modifies_bufs rid bufs h0 h1 /\ modifies_bufs rid bufs h1 h2)) (ensures (modifies_bufs rid bufs h0 h2)) [SMTPat (modifies_bufs rid bufs h0 h1); SMTPat (modifies_bufs rid bufs h1 h2)] = () let lemma_modifies_bufs_sub rid bufs subbufs h0 h1 : Lemma (requires (TSet.subset subbufs bufs /\ modifies_bufs rid subbufs h0 h1)) (ensures (modifies_bufs rid bufs h0 h1)) [SMTPat (modifies_bufs rid subbufs h0 h1); SMTPat (TSet.subset subbufs bufs)] = () val lemma_modifies_bufs_subset: #a:Type -> #a':Type -> h0:mem -> h1:mem -> bufs:TSet.set abuffer -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint_from_bufs b (bufs ++ (only b')) )) (ensures (disjoint_from_bufs b bufs)) [SMTPat (modifies_bufs (HS.get_tip h0) (bufs ++ (only b')) h0 h1); SMTPat (live h0 b)] let lemma_modifies_bufs_subset #a #a' h0 h1 bufs b b' = () val lemma_modifies_bufs_superset: #a:Type -> #a':Type -> h0:mem -> h1:mem -> bufs:TSet.set abuffer -> b:buffer a -> b':buffer a' -> Lemma (requires (b' `unused_in` h0 /\ live h0 b /\ disjoint_from_bufs b bufs)) (ensures (disjoint_from_bufs b (bufs ++ (only b')))) [SMTPat (modifies_bufs (HS.get_tip h0) bufs h0 h1); SMTPat (b' `unmapped_in` h0); SMTPat (live h0 b)] let lemma_modifies_bufs_superset #a #a' h0 h1 bufs b b' = () (* Specialized lemmas *) let modifies_trans_0_0 (rid:rid) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_0 rid h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_1_0 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_0_1 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_1_1 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_1_1' (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_1 rid b' h1 h2)] = () let modifies_trans_2_0 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_2_1 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_2_1' (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b' b h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b' b h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_0_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_1_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_2_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_3_3 (#t #t' #t'':Type) (rid:rid) (b:buffer t) (b':buffer t') (b'':buffer t'') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_buf_3 rid b b' b'' h1 h2)) (ensures (modifies_buf_3 rid b b' b'' h0 h2)) [SMTPat (modifies_buf_3 rid b b' b'' h0 h1); SMTPat (modifies_buf_3 rid b b' b'' h1 h2)] = () let modifies_trans_4_4 (#t #t' #t'' #t''':Type) (rid:rid) (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_4 rid b b' b'' b''' h0 h1 /\ modifies_buf_4 rid b b' b'' b''' h1 h2)) (ensures (modifies_buf_4 rid b b' b'' b''' h0 h2)) [SMTPat (modifies_buf_4 rid b b' b'' b''' h0 h1); SMTPat (modifies_buf_4 rid b b' b'' b''' h1 h2)] = () (* TODO: complete with specialized versions of every general lemma *) (* Modifies clauses that do not change the shape of the HyperStack ((HS.get_tip h1) = (HS.get_tip h0)) *) (* NB: those clauses are made abstract in order to make verification faster // Lemmas follow to allow the programmer to make use of the real definition // of those predicates in a general setting *) let modifies_0 (h0 h1:mem) :Type0 = modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 (* This one is very generic: it says // * - some references have changed in the frame of b, but // * - among all buffers in this frame, b is the only one that changed. *) let modifies_1 (#a:Type) (b:buffer a) (h0 h1:mem) :Type0 = let rid = frameOf b in modifies_one rid h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 let modifies_2_1 (#a:Type) (b:buffer a) (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in ((rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 ))) let modifies_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= rid' /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 )))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Buffer.buffer a -> b': FStar.Buffer.buffer a' -> b'': FStar.Buffer.buffer a'' -> h0: FStar.Monotonic.HyperStack.mem -> h1: FStar.Monotonic.HyperStack.mem -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Buffer.buffer", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "FStar.Monotonic.HyperHeap.rid", "FStar.Monotonic.HyperStack.get_tip", "Prims.l_or", "FStar.Buffer.modifies_buf_3", "FStar.Monotonic.HyperStack.modifies_one", "Prims.l_not", "FStar.Buffer.modifies_buf_2", "FStar.Buffer.modifies_buf_1", "FStar.Monotonic.HyperStack.modifies", "FStar.Set.union", "FStar.Set.singleton", "FStar.Buffer.frameOf" ]
[]
false
false
false
true
true
let modifies_3 (#a #a' #a'': Type) (b: buffer a) (b': buffer a') (b'': buffer a'') (h0 h1: mem) : Type0 =
HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in let rid'' = frameOf b'' in ((rid == rid' /\ rid' == rid'' /\ modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1) \/ (rid =!= rid' /\ rid' == rid'' /\ modifies_buf_2 rid' b' b'' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1) \/ (rid == rid'' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b'' h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1) \/ (rid =!= rid' /\ rid' =!= rid'' /\ rid =!= rid'' /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton rid'')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1)))
false
Pulse.JoinComp.fst
Pulse.JoinComp.lift_atomic_to_st
val lift_atomic_to_st (g: env) (e: st_term) (c: comp_st{C_STAtomic? c}) (d: st_typing g e c) : Pure (c': comp_st & st_typing g e c') (requires True) (ensures fun (| c' , _ |) -> st_comp_of_comp c' == st_comp_of_comp c /\ ctag_of_comp_st c' == STT)
val lift_atomic_to_st (g: env) (e: st_term) (c: comp_st{C_STAtomic? c}) (d: st_typing g e c) : Pure (c': comp_st & st_typing g e c') (requires True) (ensures fun (| c' , _ |) -> st_comp_of_comp c' == st_comp_of_comp c /\ ctag_of_comp_st c' == STT)
let lift_atomic_to_st (g : env) (e : st_term) (c : comp_st{C_STAtomic? c}) (d : st_typing g e c) : Pure (c':comp_st & st_typing g e c') (requires True) (ensures fun (| c', _ |) -> st_comp_of_comp c' == st_comp_of_comp c /\ ctag_of_comp_st c' == STT) = let C_STAtomic _ _ c_st = c in let c' = C_ST c_st in let d' : st_typing g e c' = T_Lift g e c c' d (Lift_STAtomic_ST g c) in (| c', d' |)
{ "file_name": "lib/steel/pulse/Pulse.JoinComp.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 14, "end_line": 51, "start_col": 0, "start_line": 36 }
(* 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.JoinComp open Pulse.Syntax open Pulse.Typing open Pulse.Typing.Combinators open Pulse.Checker.Pure open Pulse.Checker.Base open Pulse.Checker.Prover module T = FStar.Tactics.V2 module P = Pulse.Syntax.Printer module Metatheory = Pulse.Typing.Metatheory module RU = Pulse.RuntimeUtils (* For now we just create a term with the union, but this could potentially be smarter *) let compute_iname_join (is1 is2 : term) : term = tm_join_inames is1 is2
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.fst.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Checker.Pure.fsti.checked", "Pulse.Checker.Prover.fsti.checked", "Pulse.Checker.Base.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.BreakVC.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Pulse.JoinComp.fst" }
[ { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker.Prover", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse", "short_module": null }, { "abbrev": false, "full_module": "Pulse", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: Pulse.Typing.Env.env -> e: Pulse.Syntax.Base.st_term -> c: Pulse.Syntax.Base.comp_st{C_STAtomic? c} -> d: Pulse.Typing.st_typing g e c -> Prims.Pure (Prims.dtuple2 Pulse.Syntax.Base.comp_st (fun c' -> Pulse.Typing.st_typing g e c'))
Prims.Pure
[]
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.st_term", "Pulse.Syntax.Base.comp_st", "Prims.b2t", "Pulse.Syntax.Base.uu___is_C_STAtomic", "Pulse.Typing.st_typing", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.observability", "Pulse.Syntax.Base.st_comp", "Prims.Mkdtuple2", "Pulse.Typing.T_Lift", "Pulse.Typing.Lift_STAtomic_ST", "Pulse.Syntax.Base.comp", "Pulse.Syntax.Base.C_ST", "Prims.dtuple2", "Prims.l_True", "Prims.l_and", "Prims.eq2", "Pulse.Syntax.Base.st_comp_of_comp", "Pulse.Syntax.Base.ctag", "Pulse.Syntax.Base.ctag_of_comp_st", "Pulse.Syntax.Base.STT" ]
[]
false
false
false
false
false
let lift_atomic_to_st (g: env) (e: st_term) (c: comp_st{C_STAtomic? c}) (d: st_typing g e c) : Pure (c': comp_st & st_typing g e c') (requires True) (ensures fun (| c' , _ |) -> st_comp_of_comp c' == st_comp_of_comp c /\ ctag_of_comp_st c' == STT) =
let C_STAtomic _ _ c_st = c in let c' = C_ST c_st in let d':st_typing g e c' = T_Lift g e c c' d (Lift_STAtomic_ST g c) in (| c', d' |)
false
FStar.Buffer.fst
FStar.Buffer.modifies_region
val modifies_region (rid: rid) (bufs: TSet.set abuffer) (h0 h1: mem) : Type0
val modifies_region (rid: rid) (bufs: TSet.set abuffer) (h0 h1: mem) : Type0
let modifies_region (rid:rid) (bufs:TSet.set abuffer) (h0 h1:mem) :Type0 = modifies_one rid h0 h1 /\ modifies_bufs rid bufs h0 h1 /\ HS.get_tip h0 == HS.get_tip h1
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 90, "end_line": 437, "start_col": 0, "start_line": 436 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b'''' let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) = frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r let disjoint_ref_2 a r r' = disjoint_ref_1 a r /\ disjoint_ref_1 a r' let disjoint_ref_3 a r r' r'' = disjoint_ref_1 a r /\ disjoint_ref_2 a r' r'' let disjoint_ref_4 a r r' r'' r''' = disjoint_ref_1 a r /\ disjoint_ref_3 a r' r'' r''' let disjoint_ref_5 a r r' r'' r''' r'''' = disjoint_ref_1 a r /\ disjoint_ref_4 a r' r'' r''' r'''' val disjoint_only_lemma: #a:Type -> #a':Type -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint b b')) (ensures (disjoint_from_bufs b (only b'))) let disjoint_only_lemma #a #a' b b' = () (* Fully general modifies clause *) let modifies_bufs_and_refs (bufs:TSet.set abuffer) (refs:Set.set nat) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (Set.union (arefs bufs) refs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs /\ disjoint_from_refs b refs) ==> equal h b h' b /\ live h' b))) (* Fully general modifies clause for buffer sets *) let modifies_buffers (bufs:TSet.set abuffer) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (arefs bufs) h h' /\ (forall (#a:Type) (b:buffer a). {:pattern (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs)} (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs ==> equal h b h' b /\ live h' b)))) (* General modifies clause for buffers only *) let modifies_bufs rid buffs h h' = modifies_ref rid (arefs buffs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b buffs) ==> equal h b h' b /\ live h' b) let modifies_none h h' = HS.get_tip h' == HS.get_tip h /\ HS.modifies_transitively Set.empty h h' (* Specialized clauses for small numbers of buffers *) let modifies_buf_0 rid h h' = modifies_ref rid (Set.empty #nat) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb) ==> equal h bb h' bb /\ live h' bb) let modifies_buf_1 (#t:Type) rid (b:buffer t) h h' = //would be good to drop the rid argument on these, since they can be computed from the buffers modifies_ref rid (Set.singleton (Heap.addr_of (as_ref b))) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb) ==> equal h bb h' bb /\ live h' bb) let to_set_2 (n1:nat) (n2:nat) :Set.set nat = Set.union (Set.singleton n1) (Set.singleton n2) let modifies_buf_2 (#t:Type) (#t':Type) rid (b:buffer t) (b':buffer t') h h' = modifies_ref rid (to_set_2 (as_addr b) (as_addr b')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_3 (n1:nat) (n2:nat) (n3:nat) :Set.set nat = Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3) let modifies_buf_3 (#t:Type) (#t':Type) (#t'':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') h h' = modifies_ref rid (to_set_3 (as_addr b) (as_addr b') (as_addr b'')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_4 (n1:nat) (n2:nat) (n3:nat) (n4:nat) :Set.set nat = Set.union (Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3)) (Set.singleton n4) let modifies_buf_4 (#t:Type) (#t':Type) (#t'':Type) (#t''':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') h h' = modifies_ref rid (to_set_4 (as_addr b) (as_addr b') (as_addr b'') (as_addr b''')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb /\ disjoint b''' bb) ==> equal h bb h' bb /\ live h' bb) (* General lemmas for the modifies_bufs clause *) let lemma_modifies_bufs_trans rid bufs h0 h1 h2 : Lemma (requires (modifies_bufs rid bufs h0 h1 /\ modifies_bufs rid bufs h1 h2)) (ensures (modifies_bufs rid bufs h0 h2)) [SMTPat (modifies_bufs rid bufs h0 h1); SMTPat (modifies_bufs rid bufs h1 h2)] = () let lemma_modifies_bufs_sub rid bufs subbufs h0 h1 : Lemma (requires (TSet.subset subbufs bufs /\ modifies_bufs rid subbufs h0 h1)) (ensures (modifies_bufs rid bufs h0 h1)) [SMTPat (modifies_bufs rid subbufs h0 h1); SMTPat (TSet.subset subbufs bufs)] = () val lemma_modifies_bufs_subset: #a:Type -> #a':Type -> h0:mem -> h1:mem -> bufs:TSet.set abuffer -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint_from_bufs b (bufs ++ (only b')) )) (ensures (disjoint_from_bufs b bufs)) [SMTPat (modifies_bufs (HS.get_tip h0) (bufs ++ (only b')) h0 h1); SMTPat (live h0 b)] let lemma_modifies_bufs_subset #a #a' h0 h1 bufs b b' = () val lemma_modifies_bufs_superset: #a:Type -> #a':Type -> h0:mem -> h1:mem -> bufs:TSet.set abuffer -> b:buffer a -> b':buffer a' -> Lemma (requires (b' `unused_in` h0 /\ live h0 b /\ disjoint_from_bufs b bufs)) (ensures (disjoint_from_bufs b (bufs ++ (only b')))) [SMTPat (modifies_bufs (HS.get_tip h0) bufs h0 h1); SMTPat (b' `unmapped_in` h0); SMTPat (live h0 b)] let lemma_modifies_bufs_superset #a #a' h0 h1 bufs b b' = () (* Specialized lemmas *) let modifies_trans_0_0 (rid:rid) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_0 rid h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_1_0 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_0_1 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_1_1 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_1_1' (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_1 rid b' h1 h2)] = () let modifies_trans_2_0 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_2_1 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_2_1' (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b' b h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b' b h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_0_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_1_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_2_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_3_3 (#t #t' #t'':Type) (rid:rid) (b:buffer t) (b':buffer t') (b'':buffer t'') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_buf_3 rid b b' b'' h1 h2)) (ensures (modifies_buf_3 rid b b' b'' h0 h2)) [SMTPat (modifies_buf_3 rid b b' b'' h0 h1); SMTPat (modifies_buf_3 rid b b' b'' h1 h2)] = () let modifies_trans_4_4 (#t #t' #t'' #t''':Type) (rid:rid) (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_4 rid b b' b'' b''' h0 h1 /\ modifies_buf_4 rid b b' b'' b''' h1 h2)) (ensures (modifies_buf_4 rid b b' b'' b''' h0 h2)) [SMTPat (modifies_buf_4 rid b b' b'' b''' h0 h1); SMTPat (modifies_buf_4 rid b b' b'' b''' h1 h2)] = () (* TODO: complete with specialized versions of every general lemma *) (* Modifies clauses that do not change the shape of the HyperStack ((HS.get_tip h1) = (HS.get_tip h0)) *) (* NB: those clauses are made abstract in order to make verification faster // Lemmas follow to allow the programmer to make use of the real definition // of those predicates in a general setting *) let modifies_0 (h0 h1:mem) :Type0 = modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 (* This one is very generic: it says // * - some references have changed in the frame of b, but // * - among all buffers in this frame, b is the only one that changed. *) let modifies_1 (#a:Type) (b:buffer a) (h0 h1:mem) :Type0 = let rid = frameOf b in modifies_one rid h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 let modifies_2_1 (#a:Type) (b:buffer a) (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in ((rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 ))) let modifies_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= rid' /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 ))) let modifies_3 (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in let rid'' = frameOf b'' in ((rid == rid' /\ rid' == rid'' /\ modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid =!= rid' /\ rid' == rid'' /\ modifies_buf_2 rid' b' b'' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid == rid'' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b'' h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= rid'' /\ rid =!= rid'' /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton rid'')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1))) let modifies_3_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid') (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= HS.get_tip h0 /\ rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
rid: FStar.Monotonic.HyperHeap.rid -> bufs: FStar.TSet.set FStar.Buffer.abuffer -> h0: FStar.Monotonic.HyperStack.mem -> h1: FStar.Monotonic.HyperStack.mem -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Monotonic.HyperHeap.rid", "FStar.TSet.set", "FStar.Buffer.abuffer", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "FStar.Monotonic.HyperStack.modifies_one", "FStar.Buffer.modifies_bufs", "Prims.eq2", "FStar.Monotonic.HyperStack.get_tip" ]
[]
false
false
false
true
true
let modifies_region (rid: rid) (bufs: TSet.set abuffer) (h0 h1: mem) : Type0 =
modifies_one rid h0 h1 /\ modifies_bufs rid bufs h0 h1 /\ HS.get_tip h0 == HS.get_tip h1
false
FStar.Buffer.fst
FStar.Buffer.modifies_3_2
val modifies_3_2 (#a #a': Type) (b: buffer a) (b': buffer a') (h0 h1: mem) : Type0
val modifies_3_2 (#a #a': Type) (b: buffer a) (b': buffer a') (h0 h1: mem) : Type0
let modifies_3_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid') (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= HS.get_tip h0 /\ rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1)))
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 111, "end_line": 434, "start_col": 0, "start_line": 422 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b'''' let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) = frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r let disjoint_ref_2 a r r' = disjoint_ref_1 a r /\ disjoint_ref_1 a r' let disjoint_ref_3 a r r' r'' = disjoint_ref_1 a r /\ disjoint_ref_2 a r' r'' let disjoint_ref_4 a r r' r'' r''' = disjoint_ref_1 a r /\ disjoint_ref_3 a r' r'' r''' let disjoint_ref_5 a r r' r'' r''' r'''' = disjoint_ref_1 a r /\ disjoint_ref_4 a r' r'' r''' r'''' val disjoint_only_lemma: #a:Type -> #a':Type -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint b b')) (ensures (disjoint_from_bufs b (only b'))) let disjoint_only_lemma #a #a' b b' = () (* Fully general modifies clause *) let modifies_bufs_and_refs (bufs:TSet.set abuffer) (refs:Set.set nat) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (Set.union (arefs bufs) refs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs /\ disjoint_from_refs b refs) ==> equal h b h' b /\ live h' b))) (* Fully general modifies clause for buffer sets *) let modifies_buffers (bufs:TSet.set abuffer) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (arefs bufs) h h' /\ (forall (#a:Type) (b:buffer a). {:pattern (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs)} (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs ==> equal h b h' b /\ live h' b)))) (* General modifies clause for buffers only *) let modifies_bufs rid buffs h h' = modifies_ref rid (arefs buffs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b buffs) ==> equal h b h' b /\ live h' b) let modifies_none h h' = HS.get_tip h' == HS.get_tip h /\ HS.modifies_transitively Set.empty h h' (* Specialized clauses for small numbers of buffers *) let modifies_buf_0 rid h h' = modifies_ref rid (Set.empty #nat) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb) ==> equal h bb h' bb /\ live h' bb) let modifies_buf_1 (#t:Type) rid (b:buffer t) h h' = //would be good to drop the rid argument on these, since they can be computed from the buffers modifies_ref rid (Set.singleton (Heap.addr_of (as_ref b))) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb) ==> equal h bb h' bb /\ live h' bb) let to_set_2 (n1:nat) (n2:nat) :Set.set nat = Set.union (Set.singleton n1) (Set.singleton n2) let modifies_buf_2 (#t:Type) (#t':Type) rid (b:buffer t) (b':buffer t') h h' = modifies_ref rid (to_set_2 (as_addr b) (as_addr b')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_3 (n1:nat) (n2:nat) (n3:nat) :Set.set nat = Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3) let modifies_buf_3 (#t:Type) (#t':Type) (#t'':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') h h' = modifies_ref rid (to_set_3 (as_addr b) (as_addr b') (as_addr b'')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_4 (n1:nat) (n2:nat) (n3:nat) (n4:nat) :Set.set nat = Set.union (Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3)) (Set.singleton n4) let modifies_buf_4 (#t:Type) (#t':Type) (#t'':Type) (#t''':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') h h' = modifies_ref rid (to_set_4 (as_addr b) (as_addr b') (as_addr b'') (as_addr b''')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb /\ disjoint b''' bb) ==> equal h bb h' bb /\ live h' bb) (* General lemmas for the modifies_bufs clause *) let lemma_modifies_bufs_trans rid bufs h0 h1 h2 : Lemma (requires (modifies_bufs rid bufs h0 h1 /\ modifies_bufs rid bufs h1 h2)) (ensures (modifies_bufs rid bufs h0 h2)) [SMTPat (modifies_bufs rid bufs h0 h1); SMTPat (modifies_bufs rid bufs h1 h2)] = () let lemma_modifies_bufs_sub rid bufs subbufs h0 h1 : Lemma (requires (TSet.subset subbufs bufs /\ modifies_bufs rid subbufs h0 h1)) (ensures (modifies_bufs rid bufs h0 h1)) [SMTPat (modifies_bufs rid subbufs h0 h1); SMTPat (TSet.subset subbufs bufs)] = () val lemma_modifies_bufs_subset: #a:Type -> #a':Type -> h0:mem -> h1:mem -> bufs:TSet.set abuffer -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint_from_bufs b (bufs ++ (only b')) )) (ensures (disjoint_from_bufs b bufs)) [SMTPat (modifies_bufs (HS.get_tip h0) (bufs ++ (only b')) h0 h1); SMTPat (live h0 b)] let lemma_modifies_bufs_subset #a #a' h0 h1 bufs b b' = () val lemma_modifies_bufs_superset: #a:Type -> #a':Type -> h0:mem -> h1:mem -> bufs:TSet.set abuffer -> b:buffer a -> b':buffer a' -> Lemma (requires (b' `unused_in` h0 /\ live h0 b /\ disjoint_from_bufs b bufs)) (ensures (disjoint_from_bufs b (bufs ++ (only b')))) [SMTPat (modifies_bufs (HS.get_tip h0) bufs h0 h1); SMTPat (b' `unmapped_in` h0); SMTPat (live h0 b)] let lemma_modifies_bufs_superset #a #a' h0 h1 bufs b b' = () (* Specialized lemmas *) let modifies_trans_0_0 (rid:rid) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_0 rid h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_1_0 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_0_1 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_1_1 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_1_1' (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_1 rid b' h1 h2)] = () let modifies_trans_2_0 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_2_1 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_2_1' (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b' b h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b' b h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_0_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_1_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_2_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_3_3 (#t #t' #t'':Type) (rid:rid) (b:buffer t) (b':buffer t') (b'':buffer t'') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_buf_3 rid b b' b'' h1 h2)) (ensures (modifies_buf_3 rid b b' b'' h0 h2)) [SMTPat (modifies_buf_3 rid b b' b'' h0 h1); SMTPat (modifies_buf_3 rid b b' b'' h1 h2)] = () let modifies_trans_4_4 (#t #t' #t'' #t''':Type) (rid:rid) (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_4 rid b b' b'' b''' h0 h1 /\ modifies_buf_4 rid b b' b'' b''' h1 h2)) (ensures (modifies_buf_4 rid b b' b'' b''' h0 h2)) [SMTPat (modifies_buf_4 rid b b' b'' b''' h0 h1); SMTPat (modifies_buf_4 rid b b' b'' b''' h1 h2)] = () (* TODO: complete with specialized versions of every general lemma *) (* Modifies clauses that do not change the shape of the HyperStack ((HS.get_tip h1) = (HS.get_tip h0)) *) (* NB: those clauses are made abstract in order to make verification faster // Lemmas follow to allow the programmer to make use of the real definition // of those predicates in a general setting *) let modifies_0 (h0 h1:mem) :Type0 = modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 (* This one is very generic: it says // * - some references have changed in the frame of b, but // * - among all buffers in this frame, b is the only one that changed. *) let modifies_1 (#a:Type) (b:buffer a) (h0 h1:mem) :Type0 = let rid = frameOf b in modifies_one rid h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 let modifies_2_1 (#a:Type) (b:buffer a) (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in ((rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 ))) let modifies_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= rid' /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 ))) let modifies_3 (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in let rid'' = frameOf b'' in ((rid == rid' /\ rid' == rid'' /\ modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid =!= rid' /\ rid' == rid'' /\ modifies_buf_2 rid' b' b'' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid == rid'' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b'' h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= rid'' /\ rid =!= rid'' /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton rid'')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Buffer.buffer a -> b': FStar.Buffer.buffer a' -> h0: FStar.Monotonic.HyperStack.mem -> h1: FStar.Monotonic.HyperStack.mem -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Buffer.buffer", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "FStar.Monotonic.HyperHeap.rid", "FStar.Monotonic.HyperStack.get_tip", "Prims.l_or", "FStar.Buffer.modifies_buf_2", "FStar.Monotonic.HyperStack.modifies_one", "Prims.l_not", "FStar.Buffer.modifies_buf_0", "FStar.Monotonic.HyperStack.modifies", "FStar.Set.union", "FStar.Set.singleton", "FStar.Buffer.modifies_buf_1", "FStar.Buffer.frameOf" ]
[]
false
false
false
true
true
let modifies_3_2 (#a #a': Type) (b: buffer a) (b': buffer a') (h0 h1: mem) : Type0 =
HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1) \/ (rid =!= rid' /\ rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid') (Set.singleton (HS.get_tip h0))) h0 h1) \/ (rid =!= rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1) \/ (rid =!= rid' /\ rid' =!= HS.get_tip h0 /\ rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1)))
false
Hacl.Impl.Poly1305.Field32xN_256.fst
Hacl.Impl.Poly1305.Field32xN_256.load_acc4
val load_acc4: acc:felem 4 -> b:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h acc /\ live h b /\ disjoint acc b /\ felem_fits h acc (2, 2, 2, 2, 2)) (ensures fun h0 _ h1 -> modifies (loc acc) h0 h1 /\ felem_fits h1 acc (3, 3, 3, 3, 3) /\ feval h1 acc == Vec.load_acc4 (as_seq h0 b) (feval h0 acc).[0])
val load_acc4: acc:felem 4 -> b:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h acc /\ live h b /\ disjoint acc b /\ felem_fits h acc (2, 2, 2, 2, 2)) (ensures fun h0 _ h1 -> modifies (loc acc) h0 h1 /\ felem_fits h1 acc (3, 3, 3, 3, 3) /\ feval h1 acc == Vec.load_acc4 (as_seq h0 b) (feval h0 acc).[0])
let load_acc4 acc b = push_frame(); let e = create 5ul (zero 4) in load_blocks e b; let acc0 = acc.(0ul) in let acc1 = acc.(1ul) in let acc2 = acc.(2ul) in let acc3 = acc.(3ul) in let acc4 = acc.(4ul) in let e0 = e.(0ul) in let e1 = e.(1ul) in let e2 = e.(2ul) in let e3 = e.(3ul) in let e4 = e.(4ul) in let (acc0, acc1, acc2, acc3, acc4) = load_acc5_4 (acc0, acc1, acc2, acc3, acc4) (e0, e1, e2, e3, e4) in acc.(0ul) <- acc0; acc.(1ul) <- acc1; acc.(2ul) <- acc2; acc.(3ul) <- acc3; acc.(4ul) <- acc4; pop_frame()
{ "file_name": "code/poly1305/Hacl.Impl.Poly1305.Field32xN_256.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 13, "end_line": 71, "start_col": 0, "start_line": 48 }
module Hacl.Impl.Poly1305.Field32xN_256 open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer include Hacl.Spec.Poly1305.Field32xN open Hacl.Spec.Poly1305.Field32xN.Lemmas module Vec = Hacl.Spec.Poly1305.Vec module ST = FStar.HyperStack.ST open Hacl.Impl.Poly1305.Field32xN /// Note: on fstar-master, we extract everything in a single invocation of /// KaRaMeL. However, we cannot mix in the same C file functions that cannot /// assume avx2 and functions that demand it, because the compiler will optimize /// the fallback version with avx2 instructions, which will in turn generate /// illegal instruction errors on some target machines. /// /// The load_accN variants pose a problem, because they all end up in the same /// file when, really, they should be in separate files to allow compiling each /// C translation unit with the same flags. /// /// One way to solve this problem is to mark them noextract /// inline_for_extraction, as was done previously. Another way would be to fix /// KaRaMeL to allow moving functions in a given module to other modules. A /// third, more mundame fix is to split these functions in separate modules and /// package them with their top-level bundle file, which will achieve the same /// effect. #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50 --using_facts_from '* -FStar.Seq'" val load_acc4: acc:felem 4 -> b:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h acc /\ live h b /\ disjoint acc b /\ felem_fits h acc (2, 2, 2, 2, 2)) (ensures fun h0 _ h1 -> modifies (loc acc) h0 h1 /\ felem_fits h1 acc (3, 3, 3, 3, 3) /\
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.Lemmas.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "Hacl.Impl.Poly1305.Field32xN.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.Poly1305.Field32xN_256.fst" }
[ { "abbrev": false, "full_module": "Hacl.Impl.Poly1305.Field32xN", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": "Vec" }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "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.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
acc: Hacl.Impl.Poly1305.Field32xN.felem 4 -> b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 64ul -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.Poly1305.Field32xN.felem", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Lib.Buffer.op_Array_Assignment", "Hacl.Spec.Poly1305.Field32xN.felem5", "Hacl.Spec.Poly1305.Field32xN.load_acc5_4", "FStar.Pervasives.Native.Mktuple5", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "Hacl.Impl.Poly1305.Field32xN.load_blocks", "Lib.Buffer.lbuffer_t", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.create", "Hacl.Spec.Poly1305.Field32xN.zero", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let load_acc4 acc b =
push_frame (); let e = create 5ul (zero 4) in load_blocks e b; let acc0 = acc.(0ul) in let acc1 = acc.(1ul) in let acc2 = acc.(2ul) in let acc3 = acc.(3ul) in let acc4 = acc.(4ul) in let e0 = e.(0ul) in let e1 = e.(1ul) in let e2 = e.(2ul) in let e3 = e.(3ul) in let e4 = e.(4ul) in let acc0, acc1, acc2, acc3, acc4 = load_acc5_4 (acc0, acc1, acc2, acc3, acc4) (e0, e1, e2, e3, e4) in acc.(0ul) <- acc0; acc.(1ul) <- acc1; acc.(2ul) <- acc2; acc.(3ul) <- acc3; acc.(4ul) <- acc4; pop_frame ()
false
Steel.Channel.Simplex.fst
Steel.Channel.Simplex.mk_chan
val mk_chan (#p: prot) (send recv: ref chan_val) (v: init_chan_val p) : SteelT (chan_t_sr p send recv) ((pts_to send half v) `star` (pts_to recv half v)) (fun c -> chan_inv c)
val mk_chan (#p: prot) (send recv: ref chan_val) (v: init_chan_val p) : SteelT (chan_t_sr p send recv) ((pts_to send half v) `star` (pts_to recv half v)) (fun c -> chan_inv c)
let mk_chan (#p:prot) (send recv:ref chan_val) (v:init_chan_val p) : SteelT (chan_t_sr p send recv) (pts_to send half v `star` pts_to recv half v) (fun c -> chan_inv c) = let tr: trace_ref p = MRef.alloc (extended_to #p) (initial_trace p) in let c = Mkchan_t send recv tr in rewrite_slprop (MRef.pts_to tr full_perm (initial_trace p)) (MRef.pts_to c.trace full_perm (initial_trace p)) (fun _ -> ()); intro_trace_until_init c v; rewrite_slprop (pts_to send half v `star` pts_to recv half v) (pts_to c.send half v `star` pts_to c.recv half v) (fun _ -> ()); intro_chan_inv #p c v; let c' : chan_t_sr p send recv = c in rewrite_slprop (chan_inv c) (chan_inv c') (fun _ -> ()); return c'
{ "file_name": "lib/steel/Steel.Channel.Simplex.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 13, "end_line": 214, "start_col": 0, "start_line": 197 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Channel.Simplex module P = Steel.Channel.Protocol open Steel.SpinLock open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.HigherReference open Steel.FractionalPermission module MRef = Steel.MonotonicHigherReference module H = Steel.HigherReference let sprot = p:prot { more p } noeq type chan_val = { chan_prot : sprot; chan_msg : msg_t chan_prot; chan_ctr : nat } let mref a p = MRef.ref a p let trace_ref (p:prot) = mref (partial_trace_of p) extended_to noeq type chan_t (p:prot) = { send: ref chan_val; recv: ref chan_val; trace: trace_ref p; } let half : perm = half_perm full_perm let step (s:sprot) (x:msg_t s) = step s x let chan_inv_step_p (vrecv vsend:chan_val) : prop = (vsend.chan_prot == step vrecv.chan_prot vrecv.chan_msg /\ vsend.chan_ctr == vrecv.chan_ctr + 1) let chan_inv_step (vrecv vsend:chan_val) : vprop = pure (chan_inv_step_p vrecv vsend) let chan_inv_cond (vsend:chan_val) (vrecv:chan_val) : vprop = if vsend.chan_ctr = vrecv.chan_ctr then pure (vsend == vrecv) else chan_inv_step vrecv vsend let trace_until_prop #p (r:trace_ref p) (vr:chan_val) (tr: partial_trace_of p) : vprop = MRef.pts_to r full_perm tr `star` pure (until tr == step vr.chan_prot vr.chan_msg) let trace_until #p (r:trace_ref p) (vr:chan_val) = h_exists (trace_until_prop r vr) let chan_inv_recv #p (c:chan_t p) (vsend:chan_val) = h_exists (fun (vrecv:chan_val) -> pts_to c.recv half vrecv `star` trace_until c.trace vrecv `star` chan_inv_cond vsend vrecv) let chan_inv #p (c:chan_t p) : vprop = h_exists (fun (vsend:chan_val) -> pts_to c.send half vsend `star` chan_inv_recv c vsend) let intro_chan_inv_cond_eqT (vs vr:chan_val) : Steel unit emp (fun _ -> chan_inv_cond vs vr) (requires fun _ -> vs == vr) (ensures fun _ _ _ -> True) = intro_pure (vs == vs); rewrite_slprop (chan_inv_cond vs vs) (chan_inv_cond vs vr) (fun _ -> ()) let intro_chan_inv_cond_stepT (vs vr:chan_val) : SteelT unit (chan_inv_step vr vs) (fun _ -> chan_inv_cond vs vr) = Steel.Utils.extract_pure (chan_inv_step_p vr vs); rewrite_slprop (chan_inv_step vr vs) (chan_inv_cond vs vr) (fun _ -> ()) let intro_chan_inv_auxT #p (#vs : chan_val) (#vr : chan_val) (c:chan_t p) : SteelT unit (pts_to c.send half vs `star` pts_to c.recv half vr `star` trace_until c.trace vr `star` chan_inv_cond vs vr) (fun _ -> chan_inv c) = intro_exists _ (fun (vr:chan_val) -> pts_to c.recv half vr `star` trace_until c.trace vr `star` chan_inv_cond vs vr); intro_exists _ (fun (vs:chan_val) -> pts_to c.send half vs `star` chan_inv_recv c vs) let intro_chan_inv_stepT #p (c:chan_t p) (vs vr:chan_val) : SteelT unit (pts_to c.send half vs `star` pts_to c.recv half vr `star` trace_until c.trace vr `star` chan_inv_step vr vs) (fun _ -> chan_inv c) = intro_chan_inv_cond_stepT vs vr; intro_chan_inv_auxT c let intro_chan_inv_eqT #p (c:chan_t p) (vs vr:chan_val) : Steel unit (pts_to c.send half vs `star` pts_to c.recv half vr `star` trace_until c.trace vr) (fun _ -> chan_inv c) (requires fun _ -> vs == vr) (ensures fun _ _ _ -> True) = intro_chan_inv_cond_eqT vs vr; intro_chan_inv_auxT c noeq type chan p = { chan_chan : chan_t p; chan_lock : lock (chan_inv chan_chan) } let in_state_prop (p:prot) (vsend:chan_val) : prop = p == step vsend.chan_prot vsend.chan_msg irreducible let next_chan_val (#p:sprot) (x:msg_t p) (vs0:chan_val { in_state_prop p vs0 }) : Tot (vs:chan_val{in_state_prop (step p x) vs /\ chan_inv_step_p vs0 vs}) = { chan_prot = (step vs0.chan_prot vs0.chan_msg); chan_msg = x; chan_ctr = vs0.chan_ctr + 1 } [@@__reduce__] let in_state_slprop (p:prot) (vsend:chan_val) : vprop = pure (in_state_prop p vsend) let in_state (r:ref chan_val) (p:prot) = h_exists (fun (vsend:chan_val) -> pts_to r half vsend `star` in_state_slprop p vsend) let sender #q (c:chan q) (p:prot) = in_state c.chan_chan.send p let receiver #q (c:chan q) (p:prot) = in_state c.chan_chan.recv p let intro_chan_inv #p (c:chan_t p) (v:chan_val) : SteelT unit (pts_to c.send half v `star` pts_to c.recv half v `star` trace_until c.trace v) (fun _ -> chan_inv c) = intro_chan_inv_eqT c v v let chan_val_p (p:prot) = (vs0:chan_val { in_state_prop p vs0 }) let intro_in_state (r:ref chan_val) (p:prot) (v:chan_val_p p) : SteelT unit (pts_to r half v) (fun _ -> in_state r p) = intro_pure (in_state_prop p v); intro_exists v (fun (v:chan_val) -> pts_to r half v `star` in_state_slprop p v) let msg t p = Msg Send unit (fun _ -> p) let init_chan_val (p:prot) = v:chan_val {v.chan_prot == msg unit p} let initial_trace (p:prot) : (q:partial_trace_of p {until q == p}) = { to = p; tr=Waiting p} let intro_trace_until #q (r:trace_ref q) (tr:partial_trace_of q) (v:chan_val) : Steel unit (MRef.pts_to r full_perm tr) (fun _ -> trace_until r v) (requires fun _ -> until tr == step v.chan_prot v.chan_msg) (ensures fun _ _ _ -> True) = intro_pure (until tr == step v.chan_prot v.chan_msg); intro_exists tr (fun (tr:partial_trace_of q) -> MRef.pts_to r full_perm tr `star` pure (until tr == (step v.chan_prot v.chan_msg))); () let chan_t_sr (p:prot) (send recv:ref chan_val) = (c:chan_t p{c.send == send /\ c.recv == recv}) let intro_trace_until_init #p (c:chan_t p) (v:init_chan_val p) : SteelT unit (MRef.pts_to c.trace full_perm (initial_trace p)) (fun _ -> trace_until c.trace v) = intro_pure (until (initial_trace p) == step v.chan_prot v.chan_msg); //TODO: Not sure why I need this rewrite rewrite_slprop (MRef.pts_to c.trace full_perm (initial_trace p) `star` pure (until (initial_trace p) == step v.chan_prot v.chan_msg)) (MRef.pts_to c.trace full_perm (initial_trace p) `star` pure (until (initial_trace p) == step v.chan_prot v.chan_msg)) (fun _ -> ()); intro_exists (initial_trace p) (trace_until_prop c.trace v)
{ "checked_file": "/", "dependencies": [ "Steel.Utils.fst.checked", "Steel.SpinLock.fsti.checked", "Steel.MonotonicHigherReference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.HigherReference.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "Steel.Channel.Protocol.fst.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Steel.Channel.Simplex.fst" }
[ { "abbrev": true, "full_module": "Steel.HigherReference", "short_module": "H" }, { "abbrev": true, "full_module": "Steel.MonotonicHigherReference", "short_module": "MRef" }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.HigherReference", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.SpinLock", "short_module": null }, { "abbrev": true, "full_module": "Steel.Channel.Protocol", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel.Protocol", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
send: Steel.HigherReference.ref Steel.Channel.Simplex.chan_val -> recv: Steel.HigherReference.ref Steel.Channel.Simplex.chan_val -> v: Steel.Channel.Simplex.init_chan_val p -> Steel.Effect.SteelT (Steel.Channel.Simplex.chan_t_sr p send recv)
Steel.Effect.SteelT
[]
[]
[ "Steel.Channel.Simplex.prot", "Steel.HigherReference.ref", "Steel.Channel.Simplex.chan_val", "Steel.Channel.Simplex.init_chan_val", "Steel.Effect.Atomic.return", "Steel.Channel.Simplex.chan_t_sr", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.Channel.Simplex.chan_inv", "Steel.Effect.Common.vprop", "Prims.unit", "Steel.Effect.Atomic.rewrite_slprop", "Steel.Memory.mem", "Steel.Channel.Simplex.intro_chan_inv", "Steel.Effect.Common.star", "Steel.HigherReference.pts_to", "Steel.Channel.Simplex.half", "Steel.Channel.Simplex.__proj__Mkchan_t__item__send", "Steel.Channel.Simplex.__proj__Mkchan_t__item__recv", "Steel.Channel.Simplex.intro_trace_until_init", "Steel.MonotonicHigherReference.pts_to", "Steel.Channel.Protocol.partial_trace_of", "Steel.Channel.Protocol.extended_to", "Steel.FractionalPermission.full_perm", "Steel.Channel.Simplex.initial_trace", "Steel.Channel.Simplex.__proj__Mkchan_t__item__trace", "Steel.Channel.Simplex.chan_t", "Steel.Channel.Simplex.Mkchan_t", "Steel.Channel.Simplex.trace_ref", "Steel.MonotonicHigherReference.alloc", "Steel.MonotonicHigherReference.ref" ]
[]
false
true
false
false
false
let mk_chan (#p: prot) (send recv: ref chan_val) (v: init_chan_val p) : SteelT (chan_t_sr p send recv) ((pts_to send half v) `star` (pts_to recv half v)) (fun c -> chan_inv c) =
let tr:trace_ref p = MRef.alloc (extended_to #p) (initial_trace p) in let c = Mkchan_t send recv tr in rewrite_slprop (MRef.pts_to tr full_perm (initial_trace p)) (MRef.pts_to c.trace full_perm (initial_trace p)) (fun _ -> ()); intro_trace_until_init c v; rewrite_slprop ((pts_to send half v) `star` (pts_to recv half v)) ((pts_to c.send half v) `star` (pts_to c.recv half v)) (fun _ -> ()); intro_chan_inv #p c v; let c':chan_t_sr p send recv = c in rewrite_slprop (chan_inv c) (chan_inv c') (fun _ -> ()); return c'
false
Hacl.Impl.Poly1305.Field32xN_256.fst
Hacl.Impl.Poly1305.Field32xN_256.fmul_r4_normalize
val fmul_r4_normalize: out:felem 4 -> p:precomp_r 4 -> Stack unit (requires fun h -> live h out /\ live h p /\ felem_fits h out (3, 3, 3, 3, 3) /\ load_precompute_r_post h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ felem_fits h1 out (2, 2, 2, 2, 2) /\ (let r = feval h0 (gsub p 0ul 5ul) in (feval h1 out).[0] == Vec.normalize_4 r.[0] (feval h0 out)))
val fmul_r4_normalize: out:felem 4 -> p:precomp_r 4 -> Stack unit (requires fun h -> live h out /\ live h p /\ felem_fits h out (3, 3, 3, 3, 3) /\ load_precompute_r_post h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ felem_fits h1 out (2, 2, 2, 2, 2) /\ (let r = feval h0 (gsub p 0ul 5ul) in (feval h1 out).[0] == Vec.normalize_4 r.[0] (feval h0 out)))
let fmul_r4_normalize out p = let r = sub p 0ul 5ul in let r_5 = sub p 5ul 5ul in let r4 = sub p 10ul 5ul in let a0 = out.(0ul) in let a1 = out.(1ul) in let a2 = out.(2ul) in let a3 = out.(3ul) in let a4 = out.(4ul) in let r10 = r.(0ul) in let r11 = r.(1ul) in let r12 = r.(2ul) in let r13 = r.(3ul) in let r14 = r.(4ul) in let r150 = r_5.(0ul) in let r151 = r_5.(1ul) in let r152 = r_5.(2ul) in let r153 = r_5.(3ul) in let r154 = r_5.(4ul) in let r40 = r4.(0ul) in let r41 = r4.(1ul) in let r42 = r4.(2ul) in let r43 = r4.(3ul) in let r44 = r4.(4ul) in let (o0, o1, o2, o3, o4) = fmul_r4_normalize5 (a0, a1, a2, a3, a4) (r10, r11, r12, r13, r14) (r150, r151, r152, r153, r154) (r40, r41, r42, r43, r44) in out.(0ul) <- o0; out.(1ul) <- o1; out.(2ul) <- o2; out.(3ul) <- o3; out.(4ul) <- o4
{ "file_name": "code/poly1305/Hacl.Impl.Poly1305.Field32xN_256.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 17, "end_line": 123, "start_col": 0, "start_line": 87 }
module Hacl.Impl.Poly1305.Field32xN_256 open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer include Hacl.Spec.Poly1305.Field32xN open Hacl.Spec.Poly1305.Field32xN.Lemmas module Vec = Hacl.Spec.Poly1305.Vec module ST = FStar.HyperStack.ST open Hacl.Impl.Poly1305.Field32xN /// Note: on fstar-master, we extract everything in a single invocation of /// KaRaMeL. However, we cannot mix in the same C file functions that cannot /// assume avx2 and functions that demand it, because the compiler will optimize /// the fallback version with avx2 instructions, which will in turn generate /// illegal instruction errors on some target machines. /// /// The load_accN variants pose a problem, because they all end up in the same /// file when, really, they should be in separate files to allow compiling each /// C translation unit with the same flags. /// /// One way to solve this problem is to mark them noextract /// inline_for_extraction, as was done previously. Another way would be to fix /// KaRaMeL to allow moving functions in a given module to other modules. A /// third, more mundame fix is to split these functions in separate modules and /// package them with their top-level bundle file, which will achieve the same /// effect. #set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50 --using_facts_from '* -FStar.Seq'" val load_acc4: acc:felem 4 -> b:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h acc /\ live h b /\ disjoint acc b /\ felem_fits h acc (2, 2, 2, 2, 2)) (ensures fun h0 _ h1 -> modifies (loc acc) h0 h1 /\ felem_fits h1 acc (3, 3, 3, 3, 3) /\ feval h1 acc == Vec.load_acc4 (as_seq h0 b) (feval h0 acc).[0]) let load_acc4 acc b = push_frame(); let e = create 5ul (zero 4) in load_blocks e b; let acc0 = acc.(0ul) in let acc1 = acc.(1ul) in let acc2 = acc.(2ul) in let acc3 = acc.(3ul) in let acc4 = acc.(4ul) in let e0 = e.(0ul) in let e1 = e.(1ul) in let e2 = e.(2ul) in let e3 = e.(3ul) in let e4 = e.(4ul) in let (acc0, acc1, acc2, acc3, acc4) = load_acc5_4 (acc0, acc1, acc2, acc3, acc4) (e0, e1, e2, e3, e4) in acc.(0ul) <- acc0; acc.(1ul) <- acc1; acc.(2ul) <- acc2; acc.(3ul) <- acc3; acc.(4ul) <- acc4; pop_frame() val fmul_r4_normalize: out:felem 4 -> p:precomp_r 4 -> Stack unit (requires fun h -> live h out /\ live h p /\ felem_fits h out (3, 3, 3, 3, 3) /\ load_precompute_r_post h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ felem_fits h1 out (2, 2, 2, 2, 2) /\ (let r = feval h0 (gsub p 0ul 5ul) in
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.Lemmas.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "Hacl.Impl.Poly1305.Field32xN.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.Poly1305.Field32xN_256.fst" }
[ { "abbrev": false, "full_module": "Hacl.Impl.Poly1305.Field32xN", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": "Vec" }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "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.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
out: Hacl.Impl.Poly1305.Field32xN.felem 4 -> p: Hacl.Impl.Poly1305.Field32xN.precomp_r 4 -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.Poly1305.Field32xN.felem", "Hacl.Impl.Poly1305.Field32xN.precomp_r", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "Lib.Buffer.op_Array_Assignment", "FStar.UInt32.__uint_to_t", "Prims.unit", "Hacl.Spec.Poly1305.Field32xN.felem5", "Hacl.Spec.Poly1305.Field32xN.fmul_r4_normalize5", "FStar.Pervasives.Native.Mktuple5", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "Lib.Buffer.lbuffer_t", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub" ]
[]
false
true
false
false
false
let fmul_r4_normalize out p =
let r = sub p 0ul 5ul in let r_5 = sub p 5ul 5ul in let r4 = sub p 10ul 5ul in let a0 = out.(0ul) in let a1 = out.(1ul) in let a2 = out.(2ul) in let a3 = out.(3ul) in let a4 = out.(4ul) in let r10 = r.(0ul) in let r11 = r.(1ul) in let r12 = r.(2ul) in let r13 = r.(3ul) in let r14 = r.(4ul) in let r150 = r_5.(0ul) in let r151 = r_5.(1ul) in let r152 = r_5.(2ul) in let r153 = r_5.(3ul) in let r154 = r_5.(4ul) in let r40 = r4.(0ul) in let r41 = r4.(1ul) in let r42 = r4.(2ul) in let r43 = r4.(3ul) in let r44 = r4.(4ul) in let o0, o1, o2, o3, o4 = fmul_r4_normalize5 (a0, a1, a2, a3, a4) (r10, r11, r12, r13, r14) (r150, r151, r152, r153, r154) (r40, r41, r42, r43, r44) in out.(0ul) <- o0; out.(1ul) <- o1; out.(2ul) <- o2; out.(3ul) <- o3; out.(4ul) <- o4
false
MiniValeSemantics.fst
MiniValeSemantics.state_eq
val state_eq (s0 s1: state) : Ghost Type0 (requires True) (ensures fun b -> b ==> s0 `feq` s1)
val state_eq (s0 s1: state) : Ghost Type0 (requires True) (ensures fun b -> b ==> s0 `feq` s1)
let state_eq (s0 s1:state) : Ghost Type0 (requires True) (ensures fun b -> b ==> s0 `feq` s1) = s0 Rax == s1 Rax /\ s0 Rbx == s1 Rbx /\ s0 Rcx == s1 Rcx /\ s0 Rdx == s1 Rdx
{ "file_name": "examples/metatheory/MiniValeSemantics.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 18, "end_line": 969, "start_col": 0, "start_line": 962 }
(* 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. Authors: C. Hawblitzel, N. Swamy *) module MiniValeSemantics (* This is a highly-simplified model of Vale/F*, based on Section 3.1-3.3 of the paper of the POPL '19 paper. It is derived from the QuickRegs1 code in the popl-artifact-submit branch of Vale. *) /// We use this tag to mark certain definitions /// and control normalization based on it irreducible let qattr = () /// 2^64 let pow2_64 = 0x10000000000000000 /// Natural numbers representable in 64 bits type nat64 = i:int{0 <= i /\ i < pow2_64} /// We have 4 registers type reg = | Rax | Rbx | Rcx | Rdx /// An operand is either a register or a constant type operand = | OReg: r:reg -> operand | OConst: n:nat64 -> operand /// Only 2 instructions here: /// A move or an add type ins = | Mov64: dst:operand -> src:operand -> ins | Add64: dst:operand -> src:operand -> ins /// A program is /// - a single instruction /// - a block of instructions /// - or a while loop type code = | Ins: ins:ins -> code | Block: block:list code -> code | WhileLessThan: src1:operand -> src2:operand -> whileBody:code -> code /// The state of a program is the register file /// holiding a 64-bit value for each register type state = reg -> nat64 /// fuel: To prove the termination of while loops, we're going to /// instrument while loops with fuel type fuel = nat /// Evaluating an operand: /// -- marked for reduction /// -- Registers evaluated by state lookup [@@qattr] let eval_operand (o:operand) (s:state) : nat64 = match o with | OReg r -> s r | OConst n -> n /// updating a register state `s` at `r` with `v` [@@qattr] let update_reg (s:state) (r:reg) (v:nat64) : state = fun r' -> if r = r' then v else s r' /// updating a register state `s` at `r` with `s' r` [@@qattr] let update_state (r:reg) (s' s:state) : state = update_reg s r (s' r) // We don't have an "ok" flag, so errors just result an arbitrary state: assume val unknown_state (s:state) : state (*** A basic semantics using a big-step interpreter ***) /// Instruction evaluation: /// only some operands are valid let eval_ins (ins:ins) (s:state) : state = match ins with | Mov64 (OConst _) _ -> unknown_state s | Mov64 (OReg dst) src -> update_reg s dst (eval_operand src s) | Add64 (OConst _) _ -> unknown_state s | Add64 (OReg dst) src -> update_reg s dst ((s dst + eval_operand src s) % 0x10000000000000000) /// eval_code: /// A fueled big-step interpreter /// While lops return None when we're out of fuel let rec eval_code (c:code) (f:fuel) (s:state) : option state = match c with | Ins ins -> Some (eval_ins ins s) | Block cs -> eval_codes cs f s | WhileLessThan src1 src2 body -> if f = 0 then None else if eval_operand src1 s < eval_operand src2 s then match eval_code body f s with | None -> None | Some s -> eval_code c (f - 1) s else Some s and eval_codes (cs:list code) (f:fuel) (s:state) : option state = match cs with | [] -> Some s | c::cs -> match eval_code c f s with | None -> None | Some s -> eval_codes cs f s (*** END OF TRUSTED SEMANTICS ***) //////////////////////////////////////////////////////////////////////////////// /// 1. We prove that increasing the fuel is irrelevant to terminating executions val increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code c f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code c fN s0 == Some sN) (decreases %[f0; c]) val increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code (Block c) f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code (Block c) fN s0 == Some sN) (decreases %[f0; c]) let rec increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | Ins ins -> () | Block l -> increase_fuels l s0 f0 sN fN | WhileLessThan src1 src2 body -> if eval_operand src1 s0 < eval_operand src2 s0 then match eval_code body f0 s0 with | None -> () | Some s1 -> increase_fuel body s0 f0 s1 fN; increase_fuel c s1 (f0 - 1) sN (fN - 1) else () and increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | [] -> () | h::t -> let Some s1 = eval_code h f0 s0 in increase_fuel h s0 f0 s1 fN; increase_fuels t s1 f0 sN fN /// 2. We can compute the fuel needed to run a sequential composition /// as the max of the fuel to compute each piece of code in it let lemma_merge (c:code) (cs:list code) (s0:state) (f0:fuel) (sM:state) (fM:fuel) (sN:state) : Ghost fuel (requires eval_code c f0 s0 == Some sM /\ eval_code (Block cs) fM sM == Some sN) (ensures fun fN -> eval_code (Block (c::cs)) fN s0 == Some sN) = let f = if f0 > fM then f0 else fM in increase_fuel c s0 f0 sM f; increase_fuel (Block cs) sM fM sN f; f ///////////////////////////////////////////////////////////////// // Now, we're going to define a verification-condition generator // // The main idea is that we're going to: // // 1. define a kind of typeclass, that associates with a // piece of code a weakest-precondition rule for it // // 2. Define a WP-generator that computes WPs for each of the // control constructs of the language, given a program // represented as the raw code packaged with their typeclass // instances for computing their WPs ///////////////////////////////////////////////////////////////// [@@qattr] let t_post = state -> Type0 [@@qattr] let t_pre = state -> Type0 /// t_wp: The type of weakest preconditions let t_wp = t_post -> t_pre /// c `has_wp` wp: The main judgment in our program logic let has_wp (c:code) (wp:t_wp) : Type = k:t_post -> //for any post-condition s0:state -> //and initial state Ghost (state * fuel) (requires wp k s0) //Given the precondition (ensures fun (sM, f0) -> //we can compute the fuel f0 needed so that eval_code c f0 s0 == Some sM /\ //eval_code with that fuel returns sM k sM) //and the post-condition is true on sM /// An abbreviation for a thunked lemma let t_lemma (pre:Type0) (post:Type0) = unit -> Lemma (requires pre) (ensures post) /// `with_wp` : A typeclass for code packaged with its wp [@@qattr] noeq type with_wp : code -> Type = | QProc: c:code -> wp:t_wp -> hasWp:has_wp c wp -> with_wp c /// `with_wps`: A typclass for lists of code values packages with their wps noeq type with_wps : list code -> Type = | QEmpty: //empty list with_wps [] | QSeq: //cons #c:code -> #cs:list code -> hd:with_wp c -> tl:with_wps cs -> with_wps (c::cs) | QLemma: //augmenting an instruction sequence with a lemma #cs:list code -> pre:Type0 -> post:Type0 -> t_lemma pre post -> with_wps cs -> with_wps cs [@@qattr] let rec vc_gen (cs:list code) (qcs:with_wps cs) (k:t_post) : Tot (state -> Tot Type0 (decreases qcs)) = fun s0 -> match qcs with | QEmpty -> k s0 //no instructions; prove the postcondition right away | QSeq qc qcs -> // let pre_tl = //compute the VC generator for the tail, a precondition qc.wp (vc_gen (Cons?.tl cs) qcs k) s0 // in // qc.wp pre_tl s0 //apply the wp-generator to the precondition for the tail | QLemma pre post _ qcs -> pre /\ //prove the precondition of the lemma (post ==> vc_gen cs qcs k s0) //and assume its postcondition to verify the program /// The vc-generator is sound let rec vc_sound (cs:list code) (qcs:with_wps cs) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires vc_gen cs qcs k s0) (ensures fun (sN, fN) -> eval_code (Block cs) fN s0 == Some sN /\ k sN) = match qcs with | QEmpty -> (s0, 0) | QSeq qc qcs -> let Cons c cs' = cs in let (sM, fM) = qc.hasWp (vc_gen cs' qcs k) s0 in let (sN, fN) = vc_sound cs' qcs k sM in let fN' = lemma_merge c cs' s0 fM sM fN sN in (sN, fN') | QLemma pre post lem qcs' -> lem (); vc_sound cs qcs' k s0 let vc_sound' (cs:list code) (qcs:with_wps cs) : has_wp (Block cs) (vc_gen cs qcs) = vc_sound cs qcs (*** Instances of with_wp ***) //////////////////////////////////////////////////////////////////////////////// //Instance for Mov //////////////////////////////////////////////////////////////////////////////// let lemma_Move (s0:state) (dst:operand) (src:operand) : Ghost (state * fuel) (requires OReg? dst) (ensures fun (sM, fM) -> eval_code (Ins (Mov64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0 ) = let Some sM = eval_code (Ins (Mov64 dst src)) 0 s0 in (sM, 0) [@@qattr] let wp_Move (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Type0 = OReg? dst /\ (forall (x:nat64). let sM = update_reg s0 (OReg?.r dst) x in eval_operand dst sM == eval_operand src s0 ==> k sM ) let hasWp_Move (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires wp_Move dst src k s0) (ensures fun (sM, f0) -> eval_code (Ins (Mov64 dst src)) f0 s0 == Some sM /\ k sM) = lemma_Move s0 dst src [@@qattr] let inst_Move (dst:operand) (src:operand) : with_wp (Ins (Mov64 dst src)) = QProc (Ins (Mov64 dst src)) (wp_Move dst src) (hasWp_Move dst src) //////////////////////////////////////////////////////////////////////////////// //Instance for Add //////////////////////////////////////////////////////////////////////////////// let lemma_Add (s0:state) (dst:operand) (src:operand) : Ghost (state * fuel) (requires OReg? dst /\ eval_operand dst s0 + eval_operand src s0 < pow2_64) (ensures fun (sM, fM) -> eval_code (Ins (Add64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand dst s0 + eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0 ) = let Some sM = eval_code (Ins (Add64 dst src)) 0 s0 in (sM, 0) [@@qattr] let wp_Add (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Type0 = OReg? dst /\ eval_operand dst s0 + eval_operand src s0 < pow2_64 /\ (forall (x:nat64). let sM = update_reg s0 (OReg?.r dst) x in eval_operand dst sM == eval_operand dst s0 + eval_operand src s0 ==> k sM ) let hasWp_Add (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires wp_Add dst src k s0) (ensures fun (sM, f0) -> eval_code (Ins (Add64 dst src)) f0 s0 == Some sM /\ k sM) = lemma_Add s0 dst src [@@qattr] let inst_Add (dst:operand) (src:operand) : with_wp (Ins (Add64 dst src)) = QProc (Ins (Add64 dst src)) (wp_Add dst src) (hasWp_Add dst src) //////////////////////////////////////////////////////////////////////////////// //Running the VC generator using the F* normalizer //////////////////////////////////////////////////////////////////////////////// unfold let normal_steps : list string = [ `%OReg?; `%OReg?.r; `%QProc?.wp; ] unfold let normal (x:Type0) : Type0 = norm [nbe; iota; zeta; simplify; primops; delta_attr [`%qattr]; delta_only normal_steps] x let vc_sound_norm (cs:list code) (qcs:with_wps cs) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires normal (vc_gen cs qcs k s0)) (ensures fun (sN, fN) -> eval_code (Block cs) fN s0 == Some sN /\ k sN) = vc_sound cs qcs k s0 //////////////////////////////////////////////////////////////////////////////// // Verifying a simple program //////////////////////////////////////////////////////////////////////////////// [@@qattr] let codes_Triple : list code = [Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //1 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //2 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //3 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //4 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //5 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //6 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //7 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //8 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //9 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //10 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //11 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //1 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //2 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //3 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //4 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //5 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //6 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //7 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //8 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //9 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //10 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //11 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //1 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //2 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //3 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //4 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //5 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //6 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //7 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //8 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //9 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //10 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //11 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //1 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //2 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //3 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //4 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //5 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //6 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //7 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //8 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //9 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //10 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //11 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //1 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //2 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //3 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //4 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //5 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //6 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //7 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //8 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //9 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //10 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //11 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //1 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //2 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //3 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //4 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //5 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //6 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //7 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //8 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //9 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //10 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //11 Ins (Add64 (OReg Rax) (OReg Rbx)); //add rax rbx; Ins (Add64 (OReg Rbx) (OReg Rax))] //add rbx rax [@@qattr] let inst_Triple : with_wps codes_Triple = //A typeclass instance for our program QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Add (OReg Rax) (OReg Rbx)) ( QSeq (inst_Add (OReg Rbx) (OReg Rax)) ( QEmpty)) )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) open FStar.FunctionalExtensionality open FStar.Mul (* procedure Triple() modifies rax; rbx; requires rax < 100; ensures rbx == 3 * old(rax); { Mov(rbx, rax); Add(rax, rbx); Add(rbx, rax); } *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "MiniValeSemantics.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
s0: MiniValeSemantics.state -> s1: MiniValeSemantics.state -> Prims.Ghost Type0
Prims.Ghost
[]
[]
[ "MiniValeSemantics.state", "Prims.l_and", "Prims.eq2", "MiniValeSemantics.nat64", "MiniValeSemantics.Rax", "MiniValeSemantics.Rbx", "MiniValeSemantics.Rcx", "MiniValeSemantics.Rdx", "Prims.l_True", "Prims.l_imp", "FStar.FunctionalExtensionality.feq", "MiniValeSemantics.reg" ]
[]
false
false
false
false
true
let state_eq (s0 s1: state) : Ghost Type0 (requires True) (ensures fun b -> b ==> s0 `feq` s1) =
s0 Rax == s1 Rax /\ s0 Rbx == s1 Rbx /\ s0 Rcx == s1 Rcx /\ s0 Rdx == s1 Rdx
false
Pulse.JoinComp.fst
Pulse.JoinComp.lift_ghost_to_atomic
val lift_ghost_to_atomic (g: env) (e: st_term) (c: comp_st{C_STGhost? c}) (d: st_typing g e c) : TacS (c': comp_st & st_typing g e c') (requires True) (ensures fun (| c' , _ |) -> st_comp_of_comp c' == st_comp_of_comp c /\ ctag_of_comp_st c' == STT_Atomic /\ tm_emp_inames == C_STAtomic?.inames c')
val lift_ghost_to_atomic (g: env) (e: st_term) (c: comp_st{C_STGhost? c}) (d: st_typing g e c) : TacS (c': comp_st & st_typing g e c') (requires True) (ensures fun (| c' , _ |) -> st_comp_of_comp c' == st_comp_of_comp c /\ ctag_of_comp_st c' == STT_Atomic /\ tm_emp_inames == C_STAtomic?.inames c')
let lift_ghost_to_atomic (g : env) (e : st_term) (c : comp_st{C_STGhost? c}) (d : st_typing g e c) : TacS (c':comp_st & st_typing g e c') (requires True) (ensures fun (| c', _ |) -> st_comp_of_comp c' == st_comp_of_comp c /\ ctag_of_comp_st c' == STT_Atomic /\ tm_emp_inames == C_STAtomic?.inames c') = let C_STGhost c_st = c in let w : non_informative_c g c = get_non_informative_witness g (comp_u c) (comp_res c) in FStar.Tactics.BreakVC.break_vc(); // somehow this proof is unstable, this helps let c' = C_STAtomic tm_emp_inames Neutral c_st in let d' : st_typing g e c' = T_Lift g e c c' d (Lift_Ghost_Neutral g c w) in assert (st_comp_of_comp c' == st_comp_of_comp c); assert (ctag_of_comp_st c' == STT_Atomic); assert (tm_emp_inames == C_STAtomic?.inames c'); (| c', d' |)
{ "file_name": "lib/steel/pulse/Pulse.JoinComp.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 14, "end_line": 74, "start_col": 0, "start_line": 53 }
(* 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.JoinComp open Pulse.Syntax open Pulse.Typing open Pulse.Typing.Combinators open Pulse.Checker.Pure open Pulse.Checker.Base open Pulse.Checker.Prover module T = FStar.Tactics.V2 module P = Pulse.Syntax.Printer module Metatheory = Pulse.Typing.Metatheory module RU = Pulse.RuntimeUtils (* For now we just create a term with the union, but this could potentially be smarter *) let compute_iname_join (is1 is2 : term) : term = tm_join_inames is1 is2 let lift_atomic_to_st (g : env) (e : st_term) (c : comp_st{C_STAtomic? c}) (d : st_typing g e c) : Pure (c':comp_st & st_typing g e c') (requires True) (ensures fun (| c', _ |) -> st_comp_of_comp c' == st_comp_of_comp c /\ ctag_of_comp_st c' == STT) = let C_STAtomic _ _ c_st = c in let c' = C_ST c_st in let d' : st_typing g e c' = T_Lift g e c c' d (Lift_STAtomic_ST g c) in (| c', d' |)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.fst.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Checker.Pure.fsti.checked", "Pulse.Checker.Prover.fsti.checked", "Pulse.Checker.Base.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.BreakVC.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Pulse.JoinComp.fst" }
[ { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker.Prover", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse", "short_module": null }, { "abbrev": false, "full_module": "Pulse", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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: Pulse.Typing.Env.env -> e: Pulse.Syntax.Base.st_term -> c: Pulse.Syntax.Base.comp_st{C_STGhost? c} -> d: Pulse.Typing.st_typing g e c -> Pulse.JoinComp.TacS (Prims.dtuple2 Pulse.Syntax.Base.comp_st (fun c' -> Pulse.Typing.st_typing g e c'))
Pulse.JoinComp.TacS
[]
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.st_term", "Pulse.Syntax.Base.comp_st", "Prims.b2t", "Pulse.Syntax.Base.uu___is_C_STGhost", "Pulse.Typing.st_typing", "Pulse.Syntax.Base.st_comp", "Prims.Mkdtuple2", "Prims.unit", "Prims._assert", "Prims.eq2", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.tm_emp_inames", "Pulse.Syntax.Base.__proj__C_STAtomic__item__inames", "Pulse.Syntax.Base.ctag", "Pulse.Syntax.Base.ctag_of_comp_st", "Pulse.Syntax.Base.STT_Atomic", "Pulse.Syntax.Base.st_comp_of_comp", "Pulse.Typing.T_Lift", "Pulse.Typing.Lift_Ghost_Neutral", "Pulse.Syntax.Base.comp", "Pulse.Syntax.Base.C_STAtomic", "Pulse.Syntax.Base.Neutral", "Prims.dtuple2", "FStar.Tactics.BreakVC.break_vc", "Pulse.Typing.non_informative_c", "Pulse.Checker.Pure.get_non_informative_witness", "Pulse.Syntax.Base.comp_u", "Pulse.Syntax.Base.comp_res", "Pulse.Typing.non_informative_t", "Prims.l_True", "Prims.l_and" ]
[]
false
true
false
false
false
let lift_ghost_to_atomic (g: env) (e: st_term) (c: comp_st{C_STGhost? c}) (d: st_typing g e c) : TacS (c': comp_st & st_typing g e c') (requires True) (ensures fun (| c' , _ |) -> st_comp_of_comp c' == st_comp_of_comp c /\ ctag_of_comp_st c' == STT_Atomic /\ tm_emp_inames == C_STAtomic?.inames c') =
let C_STGhost c_st = c in let w:non_informative_c g c = get_non_informative_witness g (comp_u c) (comp_res c) in FStar.Tactics.BreakVC.break_vc (); let c' = C_STAtomic tm_emp_inames Neutral c_st in let d':st_typing g e c' = T_Lift g e c c' d (Lift_Ghost_Neutral g c w) in assert (st_comp_of_comp c' == st_comp_of_comp c); assert (ctag_of_comp_st c' == STT_Atomic); assert (tm_emp_inames == C_STAtomic?.inames c'); (| c', d' |)
false
MiniValeSemantics.fst
MiniValeSemantics.lemma_Triple_opt
val lemma_Triple_opt (s0: state) : Ghost (state & fuel) (requires s0 Rax < 100) (ensures fun (sM, f0) -> eval_code (Block codes_Triple) f0 s0 == Some sM /\ sM Rbx == 3 * s0 Rax /\ sM `feq` (update_state Rax sM (update_state Rbx sM s0)))
val lemma_Triple_opt (s0: state) : Ghost (state & fuel) (requires s0 Rax < 100) (ensures fun (sM, f0) -> eval_code (Block codes_Triple) f0 s0 == Some sM /\ sM Rbx == 3 * s0 Rax /\ sM `feq` (update_state Rax sM (update_state Rbx sM s0)))
let lemma_Triple_opt (s0:state) : Ghost (state & fuel) (requires s0 Rax < 100) (ensures fun (sM, f0) -> eval_code (Block codes_Triple) f0 s0 == Some sM /\ sM Rbx == 3 * s0 Rax /\ sM `feq` update_state Rax sM (update_state Rbx sM s0)) = // Optimized VC generation: vc_sound_norm codes_Triple inst_Triple (fun sM -> sM Rbx == 3 * s0 Rax /\ state_eq sM (update_state Rax sM (update_state Rbx sM s0))) s0
{ "file_name": "examples/metatheory/MiniValeSemantics.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 6, "end_line": 1005, "start_col": 0, "start_line": 992 }
(* 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. Authors: C. Hawblitzel, N. Swamy *) module MiniValeSemantics (* This is a highly-simplified model of Vale/F*, based on Section 3.1-3.3 of the paper of the POPL '19 paper. It is derived from the QuickRegs1 code in the popl-artifact-submit branch of Vale. *) /// We use this tag to mark certain definitions /// and control normalization based on it irreducible let qattr = () /// 2^64 let pow2_64 = 0x10000000000000000 /// Natural numbers representable in 64 bits type nat64 = i:int{0 <= i /\ i < pow2_64} /// We have 4 registers type reg = | Rax | Rbx | Rcx | Rdx /// An operand is either a register or a constant type operand = | OReg: r:reg -> operand | OConst: n:nat64 -> operand /// Only 2 instructions here: /// A move or an add type ins = | Mov64: dst:operand -> src:operand -> ins | Add64: dst:operand -> src:operand -> ins /// A program is /// - a single instruction /// - a block of instructions /// - or a while loop type code = | Ins: ins:ins -> code | Block: block:list code -> code | WhileLessThan: src1:operand -> src2:operand -> whileBody:code -> code /// The state of a program is the register file /// holiding a 64-bit value for each register type state = reg -> nat64 /// fuel: To prove the termination of while loops, we're going to /// instrument while loops with fuel type fuel = nat /// Evaluating an operand: /// -- marked for reduction /// -- Registers evaluated by state lookup [@@qattr] let eval_operand (o:operand) (s:state) : nat64 = match o with | OReg r -> s r | OConst n -> n /// updating a register state `s` at `r` with `v` [@@qattr] let update_reg (s:state) (r:reg) (v:nat64) : state = fun r' -> if r = r' then v else s r' /// updating a register state `s` at `r` with `s' r` [@@qattr] let update_state (r:reg) (s' s:state) : state = update_reg s r (s' r) // We don't have an "ok" flag, so errors just result an arbitrary state: assume val unknown_state (s:state) : state (*** A basic semantics using a big-step interpreter ***) /// Instruction evaluation: /// only some operands are valid let eval_ins (ins:ins) (s:state) : state = match ins with | Mov64 (OConst _) _ -> unknown_state s | Mov64 (OReg dst) src -> update_reg s dst (eval_operand src s) | Add64 (OConst _) _ -> unknown_state s | Add64 (OReg dst) src -> update_reg s dst ((s dst + eval_operand src s) % 0x10000000000000000) /// eval_code: /// A fueled big-step interpreter /// While lops return None when we're out of fuel let rec eval_code (c:code) (f:fuel) (s:state) : option state = match c with | Ins ins -> Some (eval_ins ins s) | Block cs -> eval_codes cs f s | WhileLessThan src1 src2 body -> if f = 0 then None else if eval_operand src1 s < eval_operand src2 s then match eval_code body f s with | None -> None | Some s -> eval_code c (f - 1) s else Some s and eval_codes (cs:list code) (f:fuel) (s:state) : option state = match cs with | [] -> Some s | c::cs -> match eval_code c f s with | None -> None | Some s -> eval_codes cs f s (*** END OF TRUSTED SEMANTICS ***) //////////////////////////////////////////////////////////////////////////////// /// 1. We prove that increasing the fuel is irrelevant to terminating executions val increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code c f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code c fN s0 == Some sN) (decreases %[f0; c]) val increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) : Lemma (requires eval_code (Block c) f0 s0 == Some sN /\ f0 <= fN) (ensures eval_code (Block c) fN s0 == Some sN) (decreases %[f0; c]) let rec increase_fuel (c:code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | Ins ins -> () | Block l -> increase_fuels l s0 f0 sN fN | WhileLessThan src1 src2 body -> if eval_operand src1 s0 < eval_operand src2 s0 then match eval_code body f0 s0 with | None -> () | Some s1 -> increase_fuel body s0 f0 s1 fN; increase_fuel c s1 (f0 - 1) sN (fN - 1) else () and increase_fuels (c:list code) (s0:state) (f0:fuel) (sN:state) (fN:fuel) = match c with | [] -> () | h::t -> let Some s1 = eval_code h f0 s0 in increase_fuel h s0 f0 s1 fN; increase_fuels t s1 f0 sN fN /// 2. We can compute the fuel needed to run a sequential composition /// as the max of the fuel to compute each piece of code in it let lemma_merge (c:code) (cs:list code) (s0:state) (f0:fuel) (sM:state) (fM:fuel) (sN:state) : Ghost fuel (requires eval_code c f0 s0 == Some sM /\ eval_code (Block cs) fM sM == Some sN) (ensures fun fN -> eval_code (Block (c::cs)) fN s0 == Some sN) = let f = if f0 > fM then f0 else fM in increase_fuel c s0 f0 sM f; increase_fuel (Block cs) sM fM sN f; f ///////////////////////////////////////////////////////////////// // Now, we're going to define a verification-condition generator // // The main idea is that we're going to: // // 1. define a kind of typeclass, that associates with a // piece of code a weakest-precondition rule for it // // 2. Define a WP-generator that computes WPs for each of the // control constructs of the language, given a program // represented as the raw code packaged with their typeclass // instances for computing their WPs ///////////////////////////////////////////////////////////////// [@@qattr] let t_post = state -> Type0 [@@qattr] let t_pre = state -> Type0 /// t_wp: The type of weakest preconditions let t_wp = t_post -> t_pre /// c `has_wp` wp: The main judgment in our program logic let has_wp (c:code) (wp:t_wp) : Type = k:t_post -> //for any post-condition s0:state -> //and initial state Ghost (state * fuel) (requires wp k s0) //Given the precondition (ensures fun (sM, f0) -> //we can compute the fuel f0 needed so that eval_code c f0 s0 == Some sM /\ //eval_code with that fuel returns sM k sM) //and the post-condition is true on sM /// An abbreviation for a thunked lemma let t_lemma (pre:Type0) (post:Type0) = unit -> Lemma (requires pre) (ensures post) /// `with_wp` : A typeclass for code packaged with its wp [@@qattr] noeq type with_wp : code -> Type = | QProc: c:code -> wp:t_wp -> hasWp:has_wp c wp -> with_wp c /// `with_wps`: A typclass for lists of code values packages with their wps noeq type with_wps : list code -> Type = | QEmpty: //empty list with_wps [] | QSeq: //cons #c:code -> #cs:list code -> hd:with_wp c -> tl:with_wps cs -> with_wps (c::cs) | QLemma: //augmenting an instruction sequence with a lemma #cs:list code -> pre:Type0 -> post:Type0 -> t_lemma pre post -> with_wps cs -> with_wps cs [@@qattr] let rec vc_gen (cs:list code) (qcs:with_wps cs) (k:t_post) : Tot (state -> Tot Type0 (decreases qcs)) = fun s0 -> match qcs with | QEmpty -> k s0 //no instructions; prove the postcondition right away | QSeq qc qcs -> // let pre_tl = //compute the VC generator for the tail, a precondition qc.wp (vc_gen (Cons?.tl cs) qcs k) s0 // in // qc.wp pre_tl s0 //apply the wp-generator to the precondition for the tail | QLemma pre post _ qcs -> pre /\ //prove the precondition of the lemma (post ==> vc_gen cs qcs k s0) //and assume its postcondition to verify the program /// The vc-generator is sound let rec vc_sound (cs:list code) (qcs:with_wps cs) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires vc_gen cs qcs k s0) (ensures fun (sN, fN) -> eval_code (Block cs) fN s0 == Some sN /\ k sN) = match qcs with | QEmpty -> (s0, 0) | QSeq qc qcs -> let Cons c cs' = cs in let (sM, fM) = qc.hasWp (vc_gen cs' qcs k) s0 in let (sN, fN) = vc_sound cs' qcs k sM in let fN' = lemma_merge c cs' s0 fM sM fN sN in (sN, fN') | QLemma pre post lem qcs' -> lem (); vc_sound cs qcs' k s0 let vc_sound' (cs:list code) (qcs:with_wps cs) : has_wp (Block cs) (vc_gen cs qcs) = vc_sound cs qcs (*** Instances of with_wp ***) //////////////////////////////////////////////////////////////////////////////// //Instance for Mov //////////////////////////////////////////////////////////////////////////////// let lemma_Move (s0:state) (dst:operand) (src:operand) : Ghost (state * fuel) (requires OReg? dst) (ensures fun (sM, fM) -> eval_code (Ins (Mov64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0 ) = let Some sM = eval_code (Ins (Mov64 dst src)) 0 s0 in (sM, 0) [@@qattr] let wp_Move (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Type0 = OReg? dst /\ (forall (x:nat64). let sM = update_reg s0 (OReg?.r dst) x in eval_operand dst sM == eval_operand src s0 ==> k sM ) let hasWp_Move (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires wp_Move dst src k s0) (ensures fun (sM, f0) -> eval_code (Ins (Mov64 dst src)) f0 s0 == Some sM /\ k sM) = lemma_Move s0 dst src [@@qattr] let inst_Move (dst:operand) (src:operand) : with_wp (Ins (Mov64 dst src)) = QProc (Ins (Mov64 dst src)) (wp_Move dst src) (hasWp_Move dst src) //////////////////////////////////////////////////////////////////////////////// //Instance for Add //////////////////////////////////////////////////////////////////////////////// let lemma_Add (s0:state) (dst:operand) (src:operand) : Ghost (state * fuel) (requires OReg? dst /\ eval_operand dst s0 + eval_operand src s0 < pow2_64) (ensures fun (sM, fM) -> eval_code (Ins (Add64 dst src)) fM s0 == Some sM /\ eval_operand dst sM == eval_operand dst s0 + eval_operand src s0 /\ sM == update_state (OReg?.r dst) sM s0 ) = let Some sM = eval_code (Ins (Add64 dst src)) 0 s0 in (sM, 0) [@@qattr] let wp_Add (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Type0 = OReg? dst /\ eval_operand dst s0 + eval_operand src s0 < pow2_64 /\ (forall (x:nat64). let sM = update_reg s0 (OReg?.r dst) x in eval_operand dst sM == eval_operand dst s0 + eval_operand src s0 ==> k sM ) let hasWp_Add (dst:operand) (src:operand) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires wp_Add dst src k s0) (ensures fun (sM, f0) -> eval_code (Ins (Add64 dst src)) f0 s0 == Some sM /\ k sM) = lemma_Add s0 dst src [@@qattr] let inst_Add (dst:operand) (src:operand) : with_wp (Ins (Add64 dst src)) = QProc (Ins (Add64 dst src)) (wp_Add dst src) (hasWp_Add dst src) //////////////////////////////////////////////////////////////////////////////// //Running the VC generator using the F* normalizer //////////////////////////////////////////////////////////////////////////////// unfold let normal_steps : list string = [ `%OReg?; `%OReg?.r; `%QProc?.wp; ] unfold let normal (x:Type0) : Type0 = norm [nbe; iota; zeta; simplify; primops; delta_attr [`%qattr]; delta_only normal_steps] x let vc_sound_norm (cs:list code) (qcs:with_wps cs) (k:state -> Type0) (s0:state) : Ghost (state * fuel) (requires normal (vc_gen cs qcs k s0)) (ensures fun (sN, fN) -> eval_code (Block cs) fN s0 == Some sN /\ k sN) = vc_sound cs qcs k s0 //////////////////////////////////////////////////////////////////////////////// // Verifying a simple program //////////////////////////////////////////////////////////////////////////////// [@@qattr] let codes_Triple : list code = [Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //1 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //2 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //3 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //4 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //5 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //6 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //7 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //8 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //9 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //10 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //11 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //1 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //2 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //3 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //4 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //5 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //6 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //7 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //8 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //9 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //10 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //11 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //1 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //2 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //3 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //4 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //5 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //6 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //7 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //8 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //9 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //10 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //11 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //1 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //2 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //3 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //4 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //5 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //6 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //7 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //8 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //9 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //10 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //11 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //1 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //2 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //3 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //4 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //5 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //6 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //7 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //8 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //9 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //10 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //11 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //1 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //2 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //3 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //4 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //5 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //6 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //7 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //8 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //9 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //10 Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; Ins (Mov64 (OReg Rbx) (OReg Rax)); //mov rbx rax; //11 Ins (Add64 (OReg Rax) (OReg Rbx)); //add rax rbx; Ins (Add64 (OReg Rbx) (OReg Rax))] //add rbx rax [@@qattr] let inst_Triple : with_wps codes_Triple = //A typeclass instance for our program QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Move (OReg Rbx) (OReg Rax)) ( QSeq (inst_Add (OReg Rax) (OReg Rbx)) ( QSeq (inst_Add (OReg Rbx) (OReg Rax)) ( QEmpty)) )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) open FStar.FunctionalExtensionality open FStar.Mul (* procedure Triple() modifies rax; rbx; requires rax < 100; ensures rbx == 3 * old(rax); { Mov(rbx, rax); Add(rax, rbx); Add(rbx, rax); } *) [@@qattr] let state_eq (s0 s1:state) : Ghost Type0 (requires True) (ensures fun b -> b ==> s0 `feq` s1) = s0 Rax == s1 Rax /\ s0 Rbx == s1 Rbx /\ s0 Rcx == s1 Rcx /\ s0 Rdx == s1 Rdx #reset-options // let lemma_Triple (s0:state) // : Ghost (state & fuel) // (requires // s0 Rax < 100) // (ensures fun (sM, f0) -> // eval_code (Block codes_Triple) f0 s0 == Some sM /\ // sM Rbx == 3 * s0 Rax /\ // sM `feq` update_state Rax sM (update_state Rbx sM s0)) = // // Naive proof: // let b1 = codes_Triple in // let (s2, fc2) = lemma_Move s0 (OReg Rbx) (OReg Rax) in let b2 = Cons?.tl b1 in // let (s3, fc3) = lemma_Add s2 (OReg Rax) (OReg Rbx) in let b3 = Cons?.tl b2 in // let (s4, fc4) = lemma_Add s3 (OReg Rbx) (OReg Rax) in let b4 = Cons?.tl b3 in // let (sM, f4) = (s4, 0) in // let f3 = lemma_merge (Cons?.hd b3) b4 s3 fc4 s4 f4 sM in // let f2 = lemma_merge (Cons?.hd b2) b3 s2 fc3 s3 f3 sM in // let fM = lemma_merge (Cons?.hd b1) b2 s0 fc2 s2 f2 sM in // (sM, fM)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "MiniValeSemantics.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
s0: MiniValeSemantics.state -> Prims.Ghost (MiniValeSemantics.state * MiniValeSemantics.fuel)
Prims.Ghost
[]
[]
[ "MiniValeSemantics.state", "MiniValeSemantics.vc_sound_norm", "MiniValeSemantics.codes_Triple", "MiniValeSemantics.inst_Triple", "Prims.l_and", "Prims.eq2", "Prims.int", "MiniValeSemantics.Rbx", "FStar.Mul.op_Star", "MiniValeSemantics.Rax", "MiniValeSemantics.state_eq", "MiniValeSemantics.update_state", "FStar.Pervasives.Native.tuple2", "MiniValeSemantics.fuel", "Prims.b2t", "Prims.op_LessThan", "FStar.Pervasives.Native.option", "MiniValeSemantics.eval_code", "MiniValeSemantics.Block", "FStar.Pervasives.Native.Some", "FStar.FunctionalExtensionality.feq", "MiniValeSemantics.reg", "MiniValeSemantics.nat64" ]
[]
false
false
false
false
false
let lemma_Triple_opt (s0: state) : Ghost (state & fuel) (requires s0 Rax < 100) (ensures fun (sM, f0) -> eval_code (Block codes_Triple) f0 s0 == Some sM /\ sM Rbx == 3 * s0 Rax /\ sM `feq` (update_state Rax sM (update_state Rbx sM s0))) =
vc_sound_norm codes_Triple inst_Triple (fun sM -> sM Rbx == 3 * s0 Rax /\ state_eq sM (update_state Rax sM (update_state Rbx sM s0))) s0
false
FStar.Buffer.fst
FStar.Buffer.p
val p (#a: Type0) (init: list a) : GTot Type0
val p (#a: Type0) (init: list a) : GTot Type0
let p (#a:Type0) (init:list a) : GTot Type0 = normalize (0 < FStar.List.Tot.length init) /\ normalize (FStar.List.Tot.length init <= UInt.max_int 32)
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 59, "end_line": 828, "start_col": 7, "start_line": 826 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b'''' let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) = frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r let disjoint_ref_2 a r r' = disjoint_ref_1 a r /\ disjoint_ref_1 a r' let disjoint_ref_3 a r r' r'' = disjoint_ref_1 a r /\ disjoint_ref_2 a r' r'' let disjoint_ref_4 a r r' r'' r''' = disjoint_ref_1 a r /\ disjoint_ref_3 a r' r'' r''' let disjoint_ref_5 a r r' r'' r''' r'''' = disjoint_ref_1 a r /\ disjoint_ref_4 a r' r'' r''' r'''' val disjoint_only_lemma: #a:Type -> #a':Type -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint b b')) (ensures (disjoint_from_bufs b (only b'))) let disjoint_only_lemma #a #a' b b' = () (* Fully general modifies clause *) let modifies_bufs_and_refs (bufs:TSet.set abuffer) (refs:Set.set nat) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (Set.union (arefs bufs) refs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs /\ disjoint_from_refs b refs) ==> equal h b h' b /\ live h' b))) (* Fully general modifies clause for buffer sets *) let modifies_buffers (bufs:TSet.set abuffer) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (arefs bufs) h h' /\ (forall (#a:Type) (b:buffer a). {:pattern (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs)} (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs ==> equal h b h' b /\ live h' b)))) (* General modifies clause for buffers only *) let modifies_bufs rid buffs h h' = modifies_ref rid (arefs buffs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b buffs) ==> equal h b h' b /\ live h' b) let modifies_none h h' = HS.get_tip h' == HS.get_tip h /\ HS.modifies_transitively Set.empty h h' (* Specialized clauses for small numbers of buffers *) let modifies_buf_0 rid h h' = modifies_ref rid (Set.empty #nat) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb) ==> equal h bb h' bb /\ live h' bb) let modifies_buf_1 (#t:Type) rid (b:buffer t) h h' = //would be good to drop the rid argument on these, since they can be computed from the buffers modifies_ref rid (Set.singleton (Heap.addr_of (as_ref b))) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb) ==> equal h bb h' bb /\ live h' bb) let to_set_2 (n1:nat) (n2:nat) :Set.set nat = Set.union (Set.singleton n1) (Set.singleton n2) let modifies_buf_2 (#t:Type) (#t':Type) rid (b:buffer t) (b':buffer t') h h' = modifies_ref rid (to_set_2 (as_addr b) (as_addr b')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_3 (n1:nat) (n2:nat) (n3:nat) :Set.set nat = Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3) let modifies_buf_3 (#t:Type) (#t':Type) (#t'':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') h h' = modifies_ref rid (to_set_3 (as_addr b) (as_addr b') (as_addr b'')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_4 (n1:nat) (n2:nat) (n3:nat) (n4:nat) :Set.set nat = Set.union (Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3)) (Set.singleton n4) let modifies_buf_4 (#t:Type) (#t':Type) (#t'':Type) (#t''':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') h h' = modifies_ref rid (to_set_4 (as_addr b) (as_addr b') (as_addr b'') (as_addr b''')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb /\ disjoint b''' bb) ==> equal h bb h' bb /\ live h' bb) (* General lemmas for the modifies_bufs clause *) let lemma_modifies_bufs_trans rid bufs h0 h1 h2 : Lemma (requires (modifies_bufs rid bufs h0 h1 /\ modifies_bufs rid bufs h1 h2)) (ensures (modifies_bufs rid bufs h0 h2)) [SMTPat (modifies_bufs rid bufs h0 h1); SMTPat (modifies_bufs rid bufs h1 h2)] = () let lemma_modifies_bufs_sub rid bufs subbufs h0 h1 : Lemma (requires (TSet.subset subbufs bufs /\ modifies_bufs rid subbufs h0 h1)) (ensures (modifies_bufs rid bufs h0 h1)) [SMTPat (modifies_bufs rid subbufs h0 h1); SMTPat (TSet.subset subbufs bufs)] = () val lemma_modifies_bufs_subset: #a:Type -> #a':Type -> h0:mem -> h1:mem -> bufs:TSet.set abuffer -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint_from_bufs b (bufs ++ (only b')) )) (ensures (disjoint_from_bufs b bufs)) [SMTPat (modifies_bufs (HS.get_tip h0) (bufs ++ (only b')) h0 h1); SMTPat (live h0 b)] let lemma_modifies_bufs_subset #a #a' h0 h1 bufs b b' = () val lemma_modifies_bufs_superset: #a:Type -> #a':Type -> h0:mem -> h1:mem -> bufs:TSet.set abuffer -> b:buffer a -> b':buffer a' -> Lemma (requires (b' `unused_in` h0 /\ live h0 b /\ disjoint_from_bufs b bufs)) (ensures (disjoint_from_bufs b (bufs ++ (only b')))) [SMTPat (modifies_bufs (HS.get_tip h0) bufs h0 h1); SMTPat (b' `unmapped_in` h0); SMTPat (live h0 b)] let lemma_modifies_bufs_superset #a #a' h0 h1 bufs b b' = () (* Specialized lemmas *) let modifies_trans_0_0 (rid:rid) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_0 rid h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_1_0 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_0_1 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_1_1 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_1_1' (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_1 rid b' h1 h2)] = () let modifies_trans_2_0 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_2_1 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_2_1' (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b' b h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b' b h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_0_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_1_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_2_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_3_3 (#t #t' #t'':Type) (rid:rid) (b:buffer t) (b':buffer t') (b'':buffer t'') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_buf_3 rid b b' b'' h1 h2)) (ensures (modifies_buf_3 rid b b' b'' h0 h2)) [SMTPat (modifies_buf_3 rid b b' b'' h0 h1); SMTPat (modifies_buf_3 rid b b' b'' h1 h2)] = () let modifies_trans_4_4 (#t #t' #t'' #t''':Type) (rid:rid) (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_4 rid b b' b'' b''' h0 h1 /\ modifies_buf_4 rid b b' b'' b''' h1 h2)) (ensures (modifies_buf_4 rid b b' b'' b''' h0 h2)) [SMTPat (modifies_buf_4 rid b b' b'' b''' h0 h1); SMTPat (modifies_buf_4 rid b b' b'' b''' h1 h2)] = () (* TODO: complete with specialized versions of every general lemma *) (* Modifies clauses that do not change the shape of the HyperStack ((HS.get_tip h1) = (HS.get_tip h0)) *) (* NB: those clauses are made abstract in order to make verification faster // Lemmas follow to allow the programmer to make use of the real definition // of those predicates in a general setting *) let modifies_0 (h0 h1:mem) :Type0 = modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 (* This one is very generic: it says // * - some references have changed in the frame of b, but // * - among all buffers in this frame, b is the only one that changed. *) let modifies_1 (#a:Type) (b:buffer a) (h0 h1:mem) :Type0 = let rid = frameOf b in modifies_one rid h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 let modifies_2_1 (#a:Type) (b:buffer a) (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in ((rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 ))) let modifies_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= rid' /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 ))) let modifies_3 (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in let rid'' = frameOf b'' in ((rid == rid' /\ rid' == rid'' /\ modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid =!= rid' /\ rid' == rid'' /\ modifies_buf_2 rid' b' b'' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid == rid'' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b'' h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= rid'' /\ rid =!= rid'' /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton rid'')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1))) let modifies_3_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid') (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= HS.get_tip h0 /\ rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1))) let modifies_region (rid:rid) (bufs:TSet.set abuffer) (h0 h1:mem) :Type0 = modifies_one rid h0 h1 /\ modifies_bufs rid bufs h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 (* Lemmas introducing the 'modifies' predicates *) let lemma_intro_modifies_0 h0 h1 : Lemma (requires (modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) (ensures (modifies_0 h0 h1)) = () let lemma_intro_modifies_1 (#a:Type) (b:buffer a) h0 h1 : Lemma (requires (let rid = frameOf b in modifies_one rid h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) (ensures (modifies_1 b h0 h1)) = () let lemma_intro_modifies_2_1 (#a:Type) (b:buffer a) h0 h1 : Lemma (requires ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in ((rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 ))))) (ensures (modifies_2_1 b h0 h1)) = () let lemma_intro_modifies_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= rid' /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 ))))) (ensures (modifies_2 b b' h0 h1)) = () let lemma_intro_modifies_3 (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') h0 h1 : Lemma (requires ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in let rid'' = frameOf b'' in ((rid == rid' /\ rid' == rid'' /\ modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid =!= rid' /\ rid' == rid'' /\ modifies_buf_2 rid' b' b'' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid == rid'' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b'' h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= rid'' /\ rid =!= rid'' /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton rid'')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1))))) (ensures (modifies_3 b b' b'' h0 h1)) = () let lemma_intro_modifies_3_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid') (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= HS.get_tip h0 /\ rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1))))) (ensures (modifies_3_2 b b' h0 h1)) = () let lemma_intro_modifies_region (rid:rid) bufs h0 h1 : Lemma (requires (modifies_one rid h0 h1 /\ modifies_bufs rid bufs h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) (ensures (modifies_region rid bufs h0 h1)) = () (* Lemmas revealing the content of the specialized modifies clauses in order to // be able to generalize them if needs be. *) let lemma_reveal_modifies_0 h0 h1 : Lemma (requires (modifies_0 h0 h1)) (ensures (modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) = () let lemma_reveal_modifies_1 (#a:Type) (b:buffer a) h0 h1 : Lemma (requires (modifies_1 b h0 h1)) (ensures (let rid = frameOf b in modifies_one rid h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) = () let lemma_reveal_modifies_2_1 (#a:Type) (b:buffer a) h0 h1 : Lemma (requires (modifies_2_1 b h0 h1)) (ensures ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in ((rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 ))))) = () let lemma_reveal_modifies_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires (modifies_2 b b' h0 h1)) (ensures ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= rid' /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 )) ))) = () let lemma_reveal_modifies_3 (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') h0 h1 : Lemma (requires (modifies_3 b b' b'' h0 h1)) (ensures ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in let rid'' = frameOf b'' in ((rid == rid' /\ rid' == rid'' /\ modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid =!= rid' /\ rid' == rid'' /\ modifies_buf_2 rid' b' b'' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid == rid'' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b'' h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= rid'' /\ rid =!= rid'' /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton rid'')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1)) ))) = () let lemma_reveal_modifies_3_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires (modifies_3_2 b b' h0 h1)) (ensures ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid') (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= HS.get_tip h0 /\ rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1)) ))) = () let lemma_reveal_modifies_region (rid:rid) bufs h0 h1 : Lemma (requires (modifies_region rid bufs h0 h1)) (ensures (modifies_one rid h0 h1 /\ modifies_bufs rid bufs h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) = () #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0" (* Stack effect specific lemmas *) let lemma_stack_1 (#a:Type) (b:buffer a) h0 h1 h2 h3 : Lemma (requires (live h0 b /\ fresh_frame h0 h1 /\ modifies_1 b h1 h2 /\ popped h2 h3)) (ensures (modifies_buf_1 (frameOf b) b h0 h3)) [SMTPat (modifies_1 b h1 h2); SMTPat (fresh_frame h0 h1); SMTPat (popped h2 h3)] = () let lemma_stack_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 h3 : Lemma (requires (live h0 b /\ live h0 b' /\ fresh_frame h0 h1 /\ modifies_2 b b' h1 h2 /\ popped h2 h3)) (ensures (modifies_2 b b' h0 h3)) [SMTPat (modifies_2 b b' h1 h2); SMTPat (fresh_frame h0 h1); SMTPat (popped h2 h3)] = () (* Specialized modifies clauses lemmas + associated SMTPatterns. Those are critical for // verification as the specialized modifies clauses are abstract from outside the // module *) (** Commutativity lemmas *) let lemma_modifies_2_comm (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires True) (ensures (modifies_2 b b' h0 h1 <==> modifies_2 b' b h0 h1)) [SMTPat (modifies_2 b b' h0 h1)] = () let lemma_modifies_3_2_comm (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires True) (ensures (modifies_3_2 b b' h0 h1 <==> modifies_3_2 b' b h0 h1)) [SMTPat (modifies_3_2 b b' h0 h1)] = () (* TODO: add commutativity lemmas for modifies_3 *) #reset-options "--z3rlimit 20" (** Transitivity lemmas *) let lemma_modifies_0_trans h0 h1 h2 : Lemma (requires (modifies_0 h0 h1 /\ modifies_0 h1 h2)) (ensures (modifies_0 h0 h2)) [SMTPat (modifies_0 h0 h1); SMTPat (modifies_0 h1 h2)] = () let lemma_modifies_1_trans (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (modifies_1 b h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_1 b h1 h2)] = () let lemma_modifies_2_1_trans (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (modifies_2_1 b h0 h1 /\ modifies_2_1 b h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_2_1 b h0 h1); SMTPat (modifies_2_1 b h1 h2)] = () let lemma_modifies_2_trans (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (modifies_2 b b' h0 h1 /\ modifies_2 b b' h1 h2)) (ensures (modifies_2 b b' h0 h2)) (* TODO: Make the following work and merge with the following lemma *) (* [SMTPatOr [ *) (* [SMTPat (modifies_2 b b' h0 h1); *) (* SMTPat (modifies_2 b' b h0 h1)]]; *) (* SMTPat (modifies_2 b' b h1 h2)] *) [SMTPat (modifies_2 b b' h0 h1); SMTPat (modifies_2 b b' h1 h2)] = () let lemma_modifies_2_trans' (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (modifies_2 b b' h0 h1 /\ modifies_2 b b' h1 h2)) (ensures (modifies_2 b b' h0 h2)) [SMTPat (modifies_2 b' b h0 h1); SMTPat (modifies_2 b b' h1 h2)] = () #reset-options "--z3rlimit 40" let lemma_modifies_3_trans (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') h0 h1 h2 : Lemma (requires (modifies_3 b b' b'' h0 h1 /\ modifies_3 b b' b'' h1 h2)) (ensures (modifies_3 b b' b'' h0 h2)) (* TODO: add the appropriate SMTPatOr patterns so as not to rewrite X times the same lemma *) [SMTPat (modifies_3 b b' b'' h0 h1); SMTPat (modifies_3 b b' b'' h1 h2)] = () #reset-options "--z3rlimit 200" let lemma_modifies_3_2_trans (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (modifies_3_2 b b' h0 h1 /\ modifies_3_2 b b' h1 h2)) (ensures (modifies_3_2 b b' h0 h2)) [SMTPat (modifies_3_2 b b' h0 h1); SMTPat (modifies_3_2 b b' h1 h2)] = () let lemma_modifies_3_2_trans' (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (modifies_3_2 b' b h0 h1 /\ modifies_3_2 b b' h1 h2)) (ensures (modifies_3_2 b b' h0 h2)) [SMTPat (modifies_3_2 b' b h0 h1); SMTPat (modifies_3_2 b b' h1 h2)] = () #reset-options "--z3rlimit 20" (* Specific modifies clause lemmas *) val lemma_modifies_0_0: h0:mem -> h1:mem -> h2:mem -> Lemma (requires (modifies_0 h0 h1 /\ modifies_0 h1 h2)) (ensures (modifies_0 h0 h2)) [SMTPat (modifies_0 h0 h1); SMTPat (modifies_0 h1 h2)] let lemma_modifies_0_0 h0 h1 h2 = () #reset-options "--z3rlimit 20 --initial_fuel 0 --max_fuel 0" let lemma_modifies_1_0 (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_1 b h0 h1 /\ modifies_0 h1 h2)) (ensures (live h2 b /\ modifies_2_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_0 h1 h2)] = () let lemma_modifies_0_1 (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_0 h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_0 h0 h1); SMTPat (modifies_1 b h1 h2)] = () let lemma_modifies_0_1' (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (b `unused_in` h0 /\ modifies_0 h0 h1 /\ live h1 b /\ modifies_1 b h1 h2)) (ensures (modifies_0 h0 h2)) [SMTPat (modifies_0 h0 h1); SMTPat (modifies_1 b h1 h2)] = () #reset-options "--z3rlimit 100 --initial_fuel 0 --max_fuel 0" let lemma_modifies_1_1 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_1 b h0 h1 /\ modifies_1 b' h1 h2)) (ensures (modifies_2 b b' h0 h2 /\ modifies_2 b' b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_1 b' h1 h2)] = if frameOf b = frameOf b' then modifies_trans_1_1' (frameOf b) b b' h0 h1 h2 else () #reset-options "--z3rlimit 200 --initial_fuel 0 --max_fuel 0" let lemma_modifies_0_2 (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ b' `unused_in` h0 /\ modifies_0 h0 h1 /\ live h1 b' /\ modifies_2 b b' h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_2 b b' h1 h2); SMTPat (modifies_0 h0 h1)] = () let lemma_modifies_0_2' (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ b' `unused_in` h0 /\ modifies_0 h0 h1 /\ live h1 b' /\ modifies_2 b' b h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_2 b' b h1 h2); SMTPat (modifies_0 h0 h1)] = () let lemma_modifies_1_2 (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_1 b h0 h1 /\ b' `unused_in` h0 /\ live h1 b' /\ modifies_2 b b' h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_2 b b' h1 h2)] = () let lemma_modifies_1_2' (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_1 b h0 h1 /\ b' `unused_in` h0 /\ live h1 b' /\ modifies_2 b' b h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_2 b' b h1 h2)] = () let lemma_modifies_1_2'' (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_1 b h0 h1 /\ modifies_2 b b' h1 h2)) (ensures (modifies_2 b b' h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_2 b b' h1 h2)] = () let lemma_modifies_1_2''' (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_1 b h0 h1 /\ modifies_2 b' b h1 h2)) (ensures (modifies_2 b' b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_2 b' b h1 h2)] = () let lemma_modifies_1_1_prime (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_1 b h0 h1 /\ b' `unused_in` h0 /\ live h1 b' /\ modifies_1 b' h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_1 b' h1 h2)] = () let lemma_modifies_2_1 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_2 b b' h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_2 b b' h0 h2)) [SMTPat (modifies_2 b b' h0 h1); SMTPat (modifies_1 b h1 h2)] = () let lemma_modifies_2_1' (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_2 b' b h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_2 b' b h0 h2)) [SMTPat (modifies_2 b' b h0 h1); SMTPat (modifies_1 b h1 h2)] = () let lemma_modifies_2_1'' (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_2_1 b h0 h1 /\ modifies_1 b' h1 h2)) (ensures (modifies_3_2 b b' h0 h2)) [SMTPat (modifies_2_1 b h0 h1); SMTPat (modifies_1 b' h1 h2)] = () (* TODO: lemmas for modifies_3 *) let lemma_modifies_0_unalloc (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (b `unused_in` h0 /\ frameOf b == HS.get_tip h0 /\ modifies_0 h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_0 h0 h2)) = () let lemma_modifies_none_1_trans (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (modifies_none h0 h1 /\ live h0 b /\ modifies_1 b h1 h2)) (ensures (modifies_1 b h0 h2)) = () let lemma_modifies_0_none_trans h0 h1 h2 : Lemma (requires (modifies_0 h0 h1 /\ modifies_none h1 h2)) (ensures (modifies_0 h0 h2)) = () #reset-options "--initial_fuel 0 --max_fuel 0" (** Concrete getters and setters *) val create: #a:Type -> init:a -> len:UInt32.t -> StackInline (buffer a) (requires (fun h -> True)) (ensures (fun (h0:mem) b h1 -> b `unused_in` h0 /\ live h1 b /\ idx b == 0 /\ length b == v len /\ frameOf b == HS.get_tip h0 /\ Map.domain (HS.get_hmap h1) == Map.domain (HS.get_hmap h0) /\ modifies_0 h0 h1 /\ as_seq h1 b == Seq.create (v len) init)) let create #a init len = let content: reference (lseq a (v len)) = salloc (Seq.create (v len) init) in let b = MkBuffer len content 0ul len in let h = HST.get() in assert (Seq.equal (as_seq h b) (sel h b)); b #reset-options "--initial_fuel 0 --max_fuel 0"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
init: Prims.list a -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "Prims.list", "Prims.l_and", "FStar.Pervasives.normalize", "Prims.b2t", "Prims.op_LessThan", "FStar.List.Tot.Base.length", "Prims.op_LessThanOrEqual", "FStar.UInt.max_int" ]
[]
false
false
false
false
true
let p (#a: Type0) (init: list a) : GTot Type0 =
normalize (0 < FStar.List.Tot.length init) /\ normalize (FStar.List.Tot.length init <= UInt.max_int 32)
false
FStar.Buffer.fst
FStar.Buffer.q
val q (#a: Type0) (len: nat) (buf: buffer a) : GTot Type0
val q (#a: Type0) (len: nat) (buf: buffer a) : GTot Type0
let q (#a:Type0) (len:nat) (buf:buffer a) : GTot Type0 = normalize (length buf == len)
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 31, "end_line": 831, "start_col": 7, "start_line": 830 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b'''' let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) = frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r let disjoint_ref_2 a r r' = disjoint_ref_1 a r /\ disjoint_ref_1 a r' let disjoint_ref_3 a r r' r'' = disjoint_ref_1 a r /\ disjoint_ref_2 a r' r'' let disjoint_ref_4 a r r' r'' r''' = disjoint_ref_1 a r /\ disjoint_ref_3 a r' r'' r''' let disjoint_ref_5 a r r' r'' r''' r'''' = disjoint_ref_1 a r /\ disjoint_ref_4 a r' r'' r''' r'''' val disjoint_only_lemma: #a:Type -> #a':Type -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint b b')) (ensures (disjoint_from_bufs b (only b'))) let disjoint_only_lemma #a #a' b b' = () (* Fully general modifies clause *) let modifies_bufs_and_refs (bufs:TSet.set abuffer) (refs:Set.set nat) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (Set.union (arefs bufs) refs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs /\ disjoint_from_refs b refs) ==> equal h b h' b /\ live h' b))) (* Fully general modifies clause for buffer sets *) let modifies_buffers (bufs:TSet.set abuffer) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (arefs bufs) h h' /\ (forall (#a:Type) (b:buffer a). {:pattern (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs)} (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs ==> equal h b h' b /\ live h' b)))) (* General modifies clause for buffers only *) let modifies_bufs rid buffs h h' = modifies_ref rid (arefs buffs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b buffs) ==> equal h b h' b /\ live h' b) let modifies_none h h' = HS.get_tip h' == HS.get_tip h /\ HS.modifies_transitively Set.empty h h' (* Specialized clauses for small numbers of buffers *) let modifies_buf_0 rid h h' = modifies_ref rid (Set.empty #nat) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb) ==> equal h bb h' bb /\ live h' bb) let modifies_buf_1 (#t:Type) rid (b:buffer t) h h' = //would be good to drop the rid argument on these, since they can be computed from the buffers modifies_ref rid (Set.singleton (Heap.addr_of (as_ref b))) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb) ==> equal h bb h' bb /\ live h' bb) let to_set_2 (n1:nat) (n2:nat) :Set.set nat = Set.union (Set.singleton n1) (Set.singleton n2) let modifies_buf_2 (#t:Type) (#t':Type) rid (b:buffer t) (b':buffer t') h h' = modifies_ref rid (to_set_2 (as_addr b) (as_addr b')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_3 (n1:nat) (n2:nat) (n3:nat) :Set.set nat = Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3) let modifies_buf_3 (#t:Type) (#t':Type) (#t'':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') h h' = modifies_ref rid (to_set_3 (as_addr b) (as_addr b') (as_addr b'')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_4 (n1:nat) (n2:nat) (n3:nat) (n4:nat) :Set.set nat = Set.union (Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3)) (Set.singleton n4) let modifies_buf_4 (#t:Type) (#t':Type) (#t'':Type) (#t''':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') h h' = modifies_ref rid (to_set_4 (as_addr b) (as_addr b') (as_addr b'') (as_addr b''')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb /\ disjoint b''' bb) ==> equal h bb h' bb /\ live h' bb) (* General lemmas for the modifies_bufs clause *) let lemma_modifies_bufs_trans rid bufs h0 h1 h2 : Lemma (requires (modifies_bufs rid bufs h0 h1 /\ modifies_bufs rid bufs h1 h2)) (ensures (modifies_bufs rid bufs h0 h2)) [SMTPat (modifies_bufs rid bufs h0 h1); SMTPat (modifies_bufs rid bufs h1 h2)] = () let lemma_modifies_bufs_sub rid bufs subbufs h0 h1 : Lemma (requires (TSet.subset subbufs bufs /\ modifies_bufs rid subbufs h0 h1)) (ensures (modifies_bufs rid bufs h0 h1)) [SMTPat (modifies_bufs rid subbufs h0 h1); SMTPat (TSet.subset subbufs bufs)] = () val lemma_modifies_bufs_subset: #a:Type -> #a':Type -> h0:mem -> h1:mem -> bufs:TSet.set abuffer -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint_from_bufs b (bufs ++ (only b')) )) (ensures (disjoint_from_bufs b bufs)) [SMTPat (modifies_bufs (HS.get_tip h0) (bufs ++ (only b')) h0 h1); SMTPat (live h0 b)] let lemma_modifies_bufs_subset #a #a' h0 h1 bufs b b' = () val lemma_modifies_bufs_superset: #a:Type -> #a':Type -> h0:mem -> h1:mem -> bufs:TSet.set abuffer -> b:buffer a -> b':buffer a' -> Lemma (requires (b' `unused_in` h0 /\ live h0 b /\ disjoint_from_bufs b bufs)) (ensures (disjoint_from_bufs b (bufs ++ (only b')))) [SMTPat (modifies_bufs (HS.get_tip h0) bufs h0 h1); SMTPat (b' `unmapped_in` h0); SMTPat (live h0 b)] let lemma_modifies_bufs_superset #a #a' h0 h1 bufs b b' = () (* Specialized lemmas *) let modifies_trans_0_0 (rid:rid) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_0 rid h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_1_0 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_0_1 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_1_1 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_1_1' (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_1 rid b' h1 h2)] = () let modifies_trans_2_0 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_2_1 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_2_1' (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b' b h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b' b h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_0_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_1_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_2_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_3_3 (#t #t' #t'':Type) (rid:rid) (b:buffer t) (b':buffer t') (b'':buffer t'') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_buf_3 rid b b' b'' h1 h2)) (ensures (modifies_buf_3 rid b b' b'' h0 h2)) [SMTPat (modifies_buf_3 rid b b' b'' h0 h1); SMTPat (modifies_buf_3 rid b b' b'' h1 h2)] = () let modifies_trans_4_4 (#t #t' #t'' #t''':Type) (rid:rid) (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_4 rid b b' b'' b''' h0 h1 /\ modifies_buf_4 rid b b' b'' b''' h1 h2)) (ensures (modifies_buf_4 rid b b' b'' b''' h0 h2)) [SMTPat (modifies_buf_4 rid b b' b'' b''' h0 h1); SMTPat (modifies_buf_4 rid b b' b'' b''' h1 h2)] = () (* TODO: complete with specialized versions of every general lemma *) (* Modifies clauses that do not change the shape of the HyperStack ((HS.get_tip h1) = (HS.get_tip h0)) *) (* NB: those clauses are made abstract in order to make verification faster // Lemmas follow to allow the programmer to make use of the real definition // of those predicates in a general setting *) let modifies_0 (h0 h1:mem) :Type0 = modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 (* This one is very generic: it says // * - some references have changed in the frame of b, but // * - among all buffers in this frame, b is the only one that changed. *) let modifies_1 (#a:Type) (b:buffer a) (h0 h1:mem) :Type0 = let rid = frameOf b in modifies_one rid h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 let modifies_2_1 (#a:Type) (b:buffer a) (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in ((rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 ))) let modifies_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= rid' /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 ))) let modifies_3 (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in let rid'' = frameOf b'' in ((rid == rid' /\ rid' == rid'' /\ modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid =!= rid' /\ rid' == rid'' /\ modifies_buf_2 rid' b' b'' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid == rid'' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b'' h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= rid'' /\ rid =!= rid'' /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton rid'')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1))) let modifies_3_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid') (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= HS.get_tip h0 /\ rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1))) let modifies_region (rid:rid) (bufs:TSet.set abuffer) (h0 h1:mem) :Type0 = modifies_one rid h0 h1 /\ modifies_bufs rid bufs h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 (* Lemmas introducing the 'modifies' predicates *) let lemma_intro_modifies_0 h0 h1 : Lemma (requires (modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) (ensures (modifies_0 h0 h1)) = () let lemma_intro_modifies_1 (#a:Type) (b:buffer a) h0 h1 : Lemma (requires (let rid = frameOf b in modifies_one rid h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) (ensures (modifies_1 b h0 h1)) = () let lemma_intro_modifies_2_1 (#a:Type) (b:buffer a) h0 h1 : Lemma (requires ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in ((rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 ))))) (ensures (modifies_2_1 b h0 h1)) = () let lemma_intro_modifies_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= rid' /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 ))))) (ensures (modifies_2 b b' h0 h1)) = () let lemma_intro_modifies_3 (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') h0 h1 : Lemma (requires ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in let rid'' = frameOf b'' in ((rid == rid' /\ rid' == rid'' /\ modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid =!= rid' /\ rid' == rid'' /\ modifies_buf_2 rid' b' b'' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid == rid'' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b'' h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= rid'' /\ rid =!= rid'' /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton rid'')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1))))) (ensures (modifies_3 b b' b'' h0 h1)) = () let lemma_intro_modifies_3_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid') (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= HS.get_tip h0 /\ rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1))))) (ensures (modifies_3_2 b b' h0 h1)) = () let lemma_intro_modifies_region (rid:rid) bufs h0 h1 : Lemma (requires (modifies_one rid h0 h1 /\ modifies_bufs rid bufs h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) (ensures (modifies_region rid bufs h0 h1)) = () (* Lemmas revealing the content of the specialized modifies clauses in order to // be able to generalize them if needs be. *) let lemma_reveal_modifies_0 h0 h1 : Lemma (requires (modifies_0 h0 h1)) (ensures (modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) = () let lemma_reveal_modifies_1 (#a:Type) (b:buffer a) h0 h1 : Lemma (requires (modifies_1 b h0 h1)) (ensures (let rid = frameOf b in modifies_one rid h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) = () let lemma_reveal_modifies_2_1 (#a:Type) (b:buffer a) h0 h1 : Lemma (requires (modifies_2_1 b h0 h1)) (ensures ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in ((rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 ))))) = () let lemma_reveal_modifies_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires (modifies_2 b b' h0 h1)) (ensures ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= rid' /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 )) ))) = () let lemma_reveal_modifies_3 (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') h0 h1 : Lemma (requires (modifies_3 b b' b'' h0 h1)) (ensures ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in let rid'' = frameOf b'' in ((rid == rid' /\ rid' == rid'' /\ modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid =!= rid' /\ rid' == rid'' /\ modifies_buf_2 rid' b' b'' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid == rid'' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b'' h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= rid'' /\ rid =!= rid'' /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton rid'')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1)) ))) = () let lemma_reveal_modifies_3_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires (modifies_3_2 b b' h0 h1)) (ensures ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid') (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= HS.get_tip h0 /\ rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1)) ))) = () let lemma_reveal_modifies_region (rid:rid) bufs h0 h1 : Lemma (requires (modifies_region rid bufs h0 h1)) (ensures (modifies_one rid h0 h1 /\ modifies_bufs rid bufs h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) = () #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0" (* Stack effect specific lemmas *) let lemma_stack_1 (#a:Type) (b:buffer a) h0 h1 h2 h3 : Lemma (requires (live h0 b /\ fresh_frame h0 h1 /\ modifies_1 b h1 h2 /\ popped h2 h3)) (ensures (modifies_buf_1 (frameOf b) b h0 h3)) [SMTPat (modifies_1 b h1 h2); SMTPat (fresh_frame h0 h1); SMTPat (popped h2 h3)] = () let lemma_stack_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 h3 : Lemma (requires (live h0 b /\ live h0 b' /\ fresh_frame h0 h1 /\ modifies_2 b b' h1 h2 /\ popped h2 h3)) (ensures (modifies_2 b b' h0 h3)) [SMTPat (modifies_2 b b' h1 h2); SMTPat (fresh_frame h0 h1); SMTPat (popped h2 h3)] = () (* Specialized modifies clauses lemmas + associated SMTPatterns. Those are critical for // verification as the specialized modifies clauses are abstract from outside the // module *) (** Commutativity lemmas *) let lemma_modifies_2_comm (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires True) (ensures (modifies_2 b b' h0 h1 <==> modifies_2 b' b h0 h1)) [SMTPat (modifies_2 b b' h0 h1)] = () let lemma_modifies_3_2_comm (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires True) (ensures (modifies_3_2 b b' h0 h1 <==> modifies_3_2 b' b h0 h1)) [SMTPat (modifies_3_2 b b' h0 h1)] = () (* TODO: add commutativity lemmas for modifies_3 *) #reset-options "--z3rlimit 20" (** Transitivity lemmas *) let lemma_modifies_0_trans h0 h1 h2 : Lemma (requires (modifies_0 h0 h1 /\ modifies_0 h1 h2)) (ensures (modifies_0 h0 h2)) [SMTPat (modifies_0 h0 h1); SMTPat (modifies_0 h1 h2)] = () let lemma_modifies_1_trans (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (modifies_1 b h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_1 b h1 h2)] = () let lemma_modifies_2_1_trans (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (modifies_2_1 b h0 h1 /\ modifies_2_1 b h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_2_1 b h0 h1); SMTPat (modifies_2_1 b h1 h2)] = () let lemma_modifies_2_trans (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (modifies_2 b b' h0 h1 /\ modifies_2 b b' h1 h2)) (ensures (modifies_2 b b' h0 h2)) (* TODO: Make the following work and merge with the following lemma *) (* [SMTPatOr [ *) (* [SMTPat (modifies_2 b b' h0 h1); *) (* SMTPat (modifies_2 b' b h0 h1)]]; *) (* SMTPat (modifies_2 b' b h1 h2)] *) [SMTPat (modifies_2 b b' h0 h1); SMTPat (modifies_2 b b' h1 h2)] = () let lemma_modifies_2_trans' (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (modifies_2 b b' h0 h1 /\ modifies_2 b b' h1 h2)) (ensures (modifies_2 b b' h0 h2)) [SMTPat (modifies_2 b' b h0 h1); SMTPat (modifies_2 b b' h1 h2)] = () #reset-options "--z3rlimit 40" let lemma_modifies_3_trans (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') h0 h1 h2 : Lemma (requires (modifies_3 b b' b'' h0 h1 /\ modifies_3 b b' b'' h1 h2)) (ensures (modifies_3 b b' b'' h0 h2)) (* TODO: add the appropriate SMTPatOr patterns so as not to rewrite X times the same lemma *) [SMTPat (modifies_3 b b' b'' h0 h1); SMTPat (modifies_3 b b' b'' h1 h2)] = () #reset-options "--z3rlimit 200" let lemma_modifies_3_2_trans (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (modifies_3_2 b b' h0 h1 /\ modifies_3_2 b b' h1 h2)) (ensures (modifies_3_2 b b' h0 h2)) [SMTPat (modifies_3_2 b b' h0 h1); SMTPat (modifies_3_2 b b' h1 h2)] = () let lemma_modifies_3_2_trans' (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (modifies_3_2 b' b h0 h1 /\ modifies_3_2 b b' h1 h2)) (ensures (modifies_3_2 b b' h0 h2)) [SMTPat (modifies_3_2 b' b h0 h1); SMTPat (modifies_3_2 b b' h1 h2)] = () #reset-options "--z3rlimit 20" (* Specific modifies clause lemmas *) val lemma_modifies_0_0: h0:mem -> h1:mem -> h2:mem -> Lemma (requires (modifies_0 h0 h1 /\ modifies_0 h1 h2)) (ensures (modifies_0 h0 h2)) [SMTPat (modifies_0 h0 h1); SMTPat (modifies_0 h1 h2)] let lemma_modifies_0_0 h0 h1 h2 = () #reset-options "--z3rlimit 20 --initial_fuel 0 --max_fuel 0" let lemma_modifies_1_0 (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_1 b h0 h1 /\ modifies_0 h1 h2)) (ensures (live h2 b /\ modifies_2_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_0 h1 h2)] = () let lemma_modifies_0_1 (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_0 h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_0 h0 h1); SMTPat (modifies_1 b h1 h2)] = () let lemma_modifies_0_1' (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (b `unused_in` h0 /\ modifies_0 h0 h1 /\ live h1 b /\ modifies_1 b h1 h2)) (ensures (modifies_0 h0 h2)) [SMTPat (modifies_0 h0 h1); SMTPat (modifies_1 b h1 h2)] = () #reset-options "--z3rlimit 100 --initial_fuel 0 --max_fuel 0" let lemma_modifies_1_1 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_1 b h0 h1 /\ modifies_1 b' h1 h2)) (ensures (modifies_2 b b' h0 h2 /\ modifies_2 b' b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_1 b' h1 h2)] = if frameOf b = frameOf b' then modifies_trans_1_1' (frameOf b) b b' h0 h1 h2 else () #reset-options "--z3rlimit 200 --initial_fuel 0 --max_fuel 0" let lemma_modifies_0_2 (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ b' `unused_in` h0 /\ modifies_0 h0 h1 /\ live h1 b' /\ modifies_2 b b' h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_2 b b' h1 h2); SMTPat (modifies_0 h0 h1)] = () let lemma_modifies_0_2' (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ b' `unused_in` h0 /\ modifies_0 h0 h1 /\ live h1 b' /\ modifies_2 b' b h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_2 b' b h1 h2); SMTPat (modifies_0 h0 h1)] = () let lemma_modifies_1_2 (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_1 b h0 h1 /\ b' `unused_in` h0 /\ live h1 b' /\ modifies_2 b b' h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_2 b b' h1 h2)] = () let lemma_modifies_1_2' (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_1 b h0 h1 /\ b' `unused_in` h0 /\ live h1 b' /\ modifies_2 b' b h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_2 b' b h1 h2)] = () let lemma_modifies_1_2'' (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_1 b h0 h1 /\ modifies_2 b b' h1 h2)) (ensures (modifies_2 b b' h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_2 b b' h1 h2)] = () let lemma_modifies_1_2''' (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_1 b h0 h1 /\ modifies_2 b' b h1 h2)) (ensures (modifies_2 b' b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_2 b' b h1 h2)] = () let lemma_modifies_1_1_prime (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_1 b h0 h1 /\ b' `unused_in` h0 /\ live h1 b' /\ modifies_1 b' h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_1 b' h1 h2)] = () let lemma_modifies_2_1 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_2 b b' h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_2 b b' h0 h2)) [SMTPat (modifies_2 b b' h0 h1); SMTPat (modifies_1 b h1 h2)] = () let lemma_modifies_2_1' (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_2 b' b h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_2 b' b h0 h2)) [SMTPat (modifies_2 b' b h0 h1); SMTPat (modifies_1 b h1 h2)] = () let lemma_modifies_2_1'' (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_2_1 b h0 h1 /\ modifies_1 b' h1 h2)) (ensures (modifies_3_2 b b' h0 h2)) [SMTPat (modifies_2_1 b h0 h1); SMTPat (modifies_1 b' h1 h2)] = () (* TODO: lemmas for modifies_3 *) let lemma_modifies_0_unalloc (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (b `unused_in` h0 /\ frameOf b == HS.get_tip h0 /\ modifies_0 h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_0 h0 h2)) = () let lemma_modifies_none_1_trans (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (modifies_none h0 h1 /\ live h0 b /\ modifies_1 b h1 h2)) (ensures (modifies_1 b h0 h2)) = () let lemma_modifies_0_none_trans h0 h1 h2 : Lemma (requires (modifies_0 h0 h1 /\ modifies_none h1 h2)) (ensures (modifies_0 h0 h2)) = () #reset-options "--initial_fuel 0 --max_fuel 0" (** Concrete getters and setters *) val create: #a:Type -> init:a -> len:UInt32.t -> StackInline (buffer a) (requires (fun h -> True)) (ensures (fun (h0:mem) b h1 -> b `unused_in` h0 /\ live h1 b /\ idx b == 0 /\ length b == v len /\ frameOf b == HS.get_tip h0 /\ Map.domain (HS.get_hmap h1) == Map.domain (HS.get_hmap h0) /\ modifies_0 h0 h1 /\ as_seq h1 b == Seq.create (v len) init)) let create #a init len = let content: reference (lseq a (v len)) = salloc (Seq.create (v len) init) in let b = MkBuffer len content 0ul len in let h = HST.get() in assert (Seq.equal (as_seq h b) (sel h b)); b #reset-options "--initial_fuel 0 --max_fuel 0" unfold let p (#a:Type0) (init:list a) : GTot Type0 = normalize (0 < FStar.List.Tot.length init) /\ normalize (FStar.List.Tot.length init <= UInt.max_int 32)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
len: Prims.nat -> buf: FStar.Buffer.buffer a -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "Prims.nat", "FStar.Buffer.buffer", "FStar.Pervasives.normalize", "Prims.eq2", "FStar.Buffer.length" ]
[]
false
false
false
false
true
let q (#a: Type0) (len: nat) (buf: buffer a) : GTot Type0 =
normalize (length buf == len)
false
FStar.Buffer.fst
FStar.Buffer.lemma_modifies_1_1
val lemma_modifies_1_1 (#a #a': Type) (b: buffer a) (b': buffer a') (h0 h1 h2: _) : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_1 b h0 h1 /\ modifies_1 b' h1 h2)) (ensures (modifies_2 b b' h0 h2 /\ modifies_2 b' b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_1 b' h1 h2)]
val lemma_modifies_1_1 (#a #a': Type) (b: buffer a) (b': buffer a') (h0 h1 h2: _) : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_1 b h0 h1 /\ modifies_1 b' h1 h2)) (ensures (modifies_2 b b' h0 h2 /\ modifies_2 b' b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_1 b' h1 h2)]
let lemma_modifies_1_1 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_1 b h0 h1 /\ modifies_1 b' h1 h2)) (ensures (modifies_2 b b' h0 h2 /\ modifies_2 b' b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_1 b' h1 h2)] = if frameOf b = frameOf b' then modifies_trans_1_1' (frameOf b) b b' h0 h1 h2 else ()
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 11, "end_line": 713, "start_col": 0, "start_line": 708 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b'''' let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) = frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r let disjoint_ref_2 a r r' = disjoint_ref_1 a r /\ disjoint_ref_1 a r' let disjoint_ref_3 a r r' r'' = disjoint_ref_1 a r /\ disjoint_ref_2 a r' r'' let disjoint_ref_4 a r r' r'' r''' = disjoint_ref_1 a r /\ disjoint_ref_3 a r' r'' r''' let disjoint_ref_5 a r r' r'' r''' r'''' = disjoint_ref_1 a r /\ disjoint_ref_4 a r' r'' r''' r'''' val disjoint_only_lemma: #a:Type -> #a':Type -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint b b')) (ensures (disjoint_from_bufs b (only b'))) let disjoint_only_lemma #a #a' b b' = () (* Fully general modifies clause *) let modifies_bufs_and_refs (bufs:TSet.set abuffer) (refs:Set.set nat) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (Set.union (arefs bufs) refs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs /\ disjoint_from_refs b refs) ==> equal h b h' b /\ live h' b))) (* Fully general modifies clause for buffer sets *) let modifies_buffers (bufs:TSet.set abuffer) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (arefs bufs) h h' /\ (forall (#a:Type) (b:buffer a). {:pattern (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs)} (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs ==> equal h b h' b /\ live h' b)))) (* General modifies clause for buffers only *) let modifies_bufs rid buffs h h' = modifies_ref rid (arefs buffs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b buffs) ==> equal h b h' b /\ live h' b) let modifies_none h h' = HS.get_tip h' == HS.get_tip h /\ HS.modifies_transitively Set.empty h h' (* Specialized clauses for small numbers of buffers *) let modifies_buf_0 rid h h' = modifies_ref rid (Set.empty #nat) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb) ==> equal h bb h' bb /\ live h' bb) let modifies_buf_1 (#t:Type) rid (b:buffer t) h h' = //would be good to drop the rid argument on these, since they can be computed from the buffers modifies_ref rid (Set.singleton (Heap.addr_of (as_ref b))) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb) ==> equal h bb h' bb /\ live h' bb) let to_set_2 (n1:nat) (n2:nat) :Set.set nat = Set.union (Set.singleton n1) (Set.singleton n2) let modifies_buf_2 (#t:Type) (#t':Type) rid (b:buffer t) (b':buffer t') h h' = modifies_ref rid (to_set_2 (as_addr b) (as_addr b')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_3 (n1:nat) (n2:nat) (n3:nat) :Set.set nat = Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3) let modifies_buf_3 (#t:Type) (#t':Type) (#t'':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') h h' = modifies_ref rid (to_set_3 (as_addr b) (as_addr b') (as_addr b'')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_4 (n1:nat) (n2:nat) (n3:nat) (n4:nat) :Set.set nat = Set.union (Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3)) (Set.singleton n4) let modifies_buf_4 (#t:Type) (#t':Type) (#t'':Type) (#t''':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') h h' = modifies_ref rid (to_set_4 (as_addr b) (as_addr b') (as_addr b'') (as_addr b''')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb /\ disjoint b''' bb) ==> equal h bb h' bb /\ live h' bb) (* General lemmas for the modifies_bufs clause *) let lemma_modifies_bufs_trans rid bufs h0 h1 h2 : Lemma (requires (modifies_bufs rid bufs h0 h1 /\ modifies_bufs rid bufs h1 h2)) (ensures (modifies_bufs rid bufs h0 h2)) [SMTPat (modifies_bufs rid bufs h0 h1); SMTPat (modifies_bufs rid bufs h1 h2)] = () let lemma_modifies_bufs_sub rid bufs subbufs h0 h1 : Lemma (requires (TSet.subset subbufs bufs /\ modifies_bufs rid subbufs h0 h1)) (ensures (modifies_bufs rid bufs h0 h1)) [SMTPat (modifies_bufs rid subbufs h0 h1); SMTPat (TSet.subset subbufs bufs)] = () val lemma_modifies_bufs_subset: #a:Type -> #a':Type -> h0:mem -> h1:mem -> bufs:TSet.set abuffer -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint_from_bufs b (bufs ++ (only b')) )) (ensures (disjoint_from_bufs b bufs)) [SMTPat (modifies_bufs (HS.get_tip h0) (bufs ++ (only b')) h0 h1); SMTPat (live h0 b)] let lemma_modifies_bufs_subset #a #a' h0 h1 bufs b b' = () val lemma_modifies_bufs_superset: #a:Type -> #a':Type -> h0:mem -> h1:mem -> bufs:TSet.set abuffer -> b:buffer a -> b':buffer a' -> Lemma (requires (b' `unused_in` h0 /\ live h0 b /\ disjoint_from_bufs b bufs)) (ensures (disjoint_from_bufs b (bufs ++ (only b')))) [SMTPat (modifies_bufs (HS.get_tip h0) bufs h0 h1); SMTPat (b' `unmapped_in` h0); SMTPat (live h0 b)] let lemma_modifies_bufs_superset #a #a' h0 h1 bufs b b' = () (* Specialized lemmas *) let modifies_trans_0_0 (rid:rid) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_0 rid h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_1_0 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_0_1 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_1_1 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_1_1' (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_1 rid b' h1 h2)] = () let modifies_trans_2_0 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_2_1 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_2_1' (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b' b h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b' b h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_0_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_1_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_2_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_3_3 (#t #t' #t'':Type) (rid:rid) (b:buffer t) (b':buffer t') (b'':buffer t'') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_buf_3 rid b b' b'' h1 h2)) (ensures (modifies_buf_3 rid b b' b'' h0 h2)) [SMTPat (modifies_buf_3 rid b b' b'' h0 h1); SMTPat (modifies_buf_3 rid b b' b'' h1 h2)] = () let modifies_trans_4_4 (#t #t' #t'' #t''':Type) (rid:rid) (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_4 rid b b' b'' b''' h0 h1 /\ modifies_buf_4 rid b b' b'' b''' h1 h2)) (ensures (modifies_buf_4 rid b b' b'' b''' h0 h2)) [SMTPat (modifies_buf_4 rid b b' b'' b''' h0 h1); SMTPat (modifies_buf_4 rid b b' b'' b''' h1 h2)] = () (* TODO: complete with specialized versions of every general lemma *) (* Modifies clauses that do not change the shape of the HyperStack ((HS.get_tip h1) = (HS.get_tip h0)) *) (* NB: those clauses are made abstract in order to make verification faster // Lemmas follow to allow the programmer to make use of the real definition // of those predicates in a general setting *) let modifies_0 (h0 h1:mem) :Type0 = modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 (* This one is very generic: it says // * - some references have changed in the frame of b, but // * - among all buffers in this frame, b is the only one that changed. *) let modifies_1 (#a:Type) (b:buffer a) (h0 h1:mem) :Type0 = let rid = frameOf b in modifies_one rid h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 let modifies_2_1 (#a:Type) (b:buffer a) (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in ((rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 ))) let modifies_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= rid' /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 ))) let modifies_3 (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in let rid'' = frameOf b'' in ((rid == rid' /\ rid' == rid'' /\ modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid =!= rid' /\ rid' == rid'' /\ modifies_buf_2 rid' b' b'' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid == rid'' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b'' h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= rid'' /\ rid =!= rid'' /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton rid'')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1))) let modifies_3_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid') (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= HS.get_tip h0 /\ rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1))) let modifies_region (rid:rid) (bufs:TSet.set abuffer) (h0 h1:mem) :Type0 = modifies_one rid h0 h1 /\ modifies_bufs rid bufs h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 (* Lemmas introducing the 'modifies' predicates *) let lemma_intro_modifies_0 h0 h1 : Lemma (requires (modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) (ensures (modifies_0 h0 h1)) = () let lemma_intro_modifies_1 (#a:Type) (b:buffer a) h0 h1 : Lemma (requires (let rid = frameOf b in modifies_one rid h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) (ensures (modifies_1 b h0 h1)) = () let lemma_intro_modifies_2_1 (#a:Type) (b:buffer a) h0 h1 : Lemma (requires ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in ((rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 ))))) (ensures (modifies_2_1 b h0 h1)) = () let lemma_intro_modifies_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= rid' /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 ))))) (ensures (modifies_2 b b' h0 h1)) = () let lemma_intro_modifies_3 (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') h0 h1 : Lemma (requires ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in let rid'' = frameOf b'' in ((rid == rid' /\ rid' == rid'' /\ modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid =!= rid' /\ rid' == rid'' /\ modifies_buf_2 rid' b' b'' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid == rid'' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b'' h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= rid'' /\ rid =!= rid'' /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton rid'')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1))))) (ensures (modifies_3 b b' b'' h0 h1)) = () let lemma_intro_modifies_3_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid') (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= HS.get_tip h0 /\ rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1))))) (ensures (modifies_3_2 b b' h0 h1)) = () let lemma_intro_modifies_region (rid:rid) bufs h0 h1 : Lemma (requires (modifies_one rid h0 h1 /\ modifies_bufs rid bufs h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) (ensures (modifies_region rid bufs h0 h1)) = () (* Lemmas revealing the content of the specialized modifies clauses in order to // be able to generalize them if needs be. *) let lemma_reveal_modifies_0 h0 h1 : Lemma (requires (modifies_0 h0 h1)) (ensures (modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) = () let lemma_reveal_modifies_1 (#a:Type) (b:buffer a) h0 h1 : Lemma (requires (modifies_1 b h0 h1)) (ensures (let rid = frameOf b in modifies_one rid h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) = () let lemma_reveal_modifies_2_1 (#a:Type) (b:buffer a) h0 h1 : Lemma (requires (modifies_2_1 b h0 h1)) (ensures ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in ((rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 ))))) = () let lemma_reveal_modifies_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires (modifies_2 b b' h0 h1)) (ensures ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= rid' /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 )) ))) = () let lemma_reveal_modifies_3 (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') h0 h1 : Lemma (requires (modifies_3 b b' b'' h0 h1)) (ensures ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in let rid'' = frameOf b'' in ((rid == rid' /\ rid' == rid'' /\ modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid =!= rid' /\ rid' == rid'' /\ modifies_buf_2 rid' b' b'' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid == rid'' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b'' h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= rid'' /\ rid =!= rid'' /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton rid'')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1)) ))) = () let lemma_reveal_modifies_3_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires (modifies_3_2 b b' h0 h1)) (ensures ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid') (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= HS.get_tip h0 /\ rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1)) ))) = () let lemma_reveal_modifies_region (rid:rid) bufs h0 h1 : Lemma (requires (modifies_region rid bufs h0 h1)) (ensures (modifies_one rid h0 h1 /\ modifies_bufs rid bufs h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) = () #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0" (* Stack effect specific lemmas *) let lemma_stack_1 (#a:Type) (b:buffer a) h0 h1 h2 h3 : Lemma (requires (live h0 b /\ fresh_frame h0 h1 /\ modifies_1 b h1 h2 /\ popped h2 h3)) (ensures (modifies_buf_1 (frameOf b) b h0 h3)) [SMTPat (modifies_1 b h1 h2); SMTPat (fresh_frame h0 h1); SMTPat (popped h2 h3)] = () let lemma_stack_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 h3 : Lemma (requires (live h0 b /\ live h0 b' /\ fresh_frame h0 h1 /\ modifies_2 b b' h1 h2 /\ popped h2 h3)) (ensures (modifies_2 b b' h0 h3)) [SMTPat (modifies_2 b b' h1 h2); SMTPat (fresh_frame h0 h1); SMTPat (popped h2 h3)] = () (* Specialized modifies clauses lemmas + associated SMTPatterns. Those are critical for // verification as the specialized modifies clauses are abstract from outside the // module *) (** Commutativity lemmas *) let lemma_modifies_2_comm (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires True) (ensures (modifies_2 b b' h0 h1 <==> modifies_2 b' b h0 h1)) [SMTPat (modifies_2 b b' h0 h1)] = () let lemma_modifies_3_2_comm (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires True) (ensures (modifies_3_2 b b' h0 h1 <==> modifies_3_2 b' b h0 h1)) [SMTPat (modifies_3_2 b b' h0 h1)] = () (* TODO: add commutativity lemmas for modifies_3 *) #reset-options "--z3rlimit 20" (** Transitivity lemmas *) let lemma_modifies_0_trans h0 h1 h2 : Lemma (requires (modifies_0 h0 h1 /\ modifies_0 h1 h2)) (ensures (modifies_0 h0 h2)) [SMTPat (modifies_0 h0 h1); SMTPat (modifies_0 h1 h2)] = () let lemma_modifies_1_trans (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (modifies_1 b h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_1 b h1 h2)] = () let lemma_modifies_2_1_trans (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (modifies_2_1 b h0 h1 /\ modifies_2_1 b h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_2_1 b h0 h1); SMTPat (modifies_2_1 b h1 h2)] = () let lemma_modifies_2_trans (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (modifies_2 b b' h0 h1 /\ modifies_2 b b' h1 h2)) (ensures (modifies_2 b b' h0 h2)) (* TODO: Make the following work and merge with the following lemma *) (* [SMTPatOr [ *) (* [SMTPat (modifies_2 b b' h0 h1); *) (* SMTPat (modifies_2 b' b h0 h1)]]; *) (* SMTPat (modifies_2 b' b h1 h2)] *) [SMTPat (modifies_2 b b' h0 h1); SMTPat (modifies_2 b b' h1 h2)] = () let lemma_modifies_2_trans' (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (modifies_2 b b' h0 h1 /\ modifies_2 b b' h1 h2)) (ensures (modifies_2 b b' h0 h2)) [SMTPat (modifies_2 b' b h0 h1); SMTPat (modifies_2 b b' h1 h2)] = () #reset-options "--z3rlimit 40" let lemma_modifies_3_trans (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') h0 h1 h2 : Lemma (requires (modifies_3 b b' b'' h0 h1 /\ modifies_3 b b' b'' h1 h2)) (ensures (modifies_3 b b' b'' h0 h2)) (* TODO: add the appropriate SMTPatOr patterns so as not to rewrite X times the same lemma *) [SMTPat (modifies_3 b b' b'' h0 h1); SMTPat (modifies_3 b b' b'' h1 h2)] = () #reset-options "--z3rlimit 200" let lemma_modifies_3_2_trans (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (modifies_3_2 b b' h0 h1 /\ modifies_3_2 b b' h1 h2)) (ensures (modifies_3_2 b b' h0 h2)) [SMTPat (modifies_3_2 b b' h0 h1); SMTPat (modifies_3_2 b b' h1 h2)] = () let lemma_modifies_3_2_trans' (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (modifies_3_2 b' b h0 h1 /\ modifies_3_2 b b' h1 h2)) (ensures (modifies_3_2 b b' h0 h2)) [SMTPat (modifies_3_2 b' b h0 h1); SMTPat (modifies_3_2 b b' h1 h2)] = () #reset-options "--z3rlimit 20" (* Specific modifies clause lemmas *) val lemma_modifies_0_0: h0:mem -> h1:mem -> h2:mem -> Lemma (requires (modifies_0 h0 h1 /\ modifies_0 h1 h2)) (ensures (modifies_0 h0 h2)) [SMTPat (modifies_0 h0 h1); SMTPat (modifies_0 h1 h2)] let lemma_modifies_0_0 h0 h1 h2 = () #reset-options "--z3rlimit 20 --initial_fuel 0 --max_fuel 0" let lemma_modifies_1_0 (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_1 b h0 h1 /\ modifies_0 h1 h2)) (ensures (live h2 b /\ modifies_2_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_0 h1 h2)] = () let lemma_modifies_0_1 (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_0 h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_0 h0 h1); SMTPat (modifies_1 b h1 h2)] = () let lemma_modifies_0_1' (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (b `unused_in` h0 /\ modifies_0 h0 h1 /\ live h1 b /\ modifies_1 b h1 h2)) (ensures (modifies_0 h0 h2)) [SMTPat (modifies_0 h0 h1); SMTPat (modifies_1 b h1 h2)] = () #reset-options "--z3rlimit 100 --initial_fuel 0 --max_fuel 0"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Buffer.buffer a -> b': FStar.Buffer.buffer a' -> h0: FStar.Monotonic.HyperStack.mem -> h1: FStar.Monotonic.HyperStack.mem -> h2: FStar.Monotonic.HyperStack.mem -> FStar.Pervasives.Lemma (requires FStar.Buffer.live h0 b /\ FStar.Buffer.live h0 b' /\ FStar.Buffer.modifies_1 b h0 h1 /\ FStar.Buffer.modifies_1 b' h1 h2) (ensures FStar.Buffer.modifies_2 b b' h0 h2 /\ FStar.Buffer.modifies_2 b' b h0 h2) [SMTPat (FStar.Buffer.modifies_1 b h0 h1); SMTPat (FStar.Buffer.modifies_1 b' h1 h2)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Buffer.buffer", "FStar.Monotonic.HyperStack.mem", "Prims.op_Equality", "FStar.Monotonic.HyperHeap.rid", "FStar.Buffer.frameOf", "FStar.Buffer.modifies_trans_1_1'", "Prims.bool", "Prims.unit", "Prims.l_and", "FStar.Buffer.live", "FStar.Buffer.modifies_1", "Prims.squash", "FStar.Buffer.modifies_2", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
false
false
true
false
false
let lemma_modifies_1_1 (#a: Type) (#a': Type) (b: buffer a) (b': buffer a') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_1 b h0 h1 /\ modifies_1 b' h1 h2)) (ensures (modifies_2 b b' h0 h2 /\ modifies_2 b' b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_1 b' h1 h2)] =
if frameOf b = frameOf b' then modifies_trans_1_1' (frameOf b) b b' h0 h1 h2
false
FStar.Buffer.fst
FStar.Buffer.rcreate_post_common
val rcreate_post_common (#a: Type) (r: rid) (init: a) (len: UInt32.t) (b: buffer a) (h0 h1: mem) : Type0
val rcreate_post_common (#a: Type) (r: rid) (init: a) (len: UInt32.t) (b: buffer a) (h0 h1: mem) : Type0
let rcreate_post_common (#a:Type) (r:rid) (init:a) (len:UInt32.t) (b:buffer a) (h0 h1:mem) :Type0 = b `unused_in` h0 /\ live h1 b /\ idx b == 0 /\ length b == v len /\ Map.domain (HS.get_hmap h1) == Map.domain (HS.get_hmap h0) /\ HS.get_tip h1 == HS.get_tip h0 /\ modifies (Set.singleton r) h0 h1 /\ modifies_ref r Set.empty h0 h1 /\ as_seq h1 b == Seq.create (v len) init
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 45, "end_line": 874, "start_col": 7, "start_line": 867 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b'''' let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) = frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r let disjoint_ref_2 a r r' = disjoint_ref_1 a r /\ disjoint_ref_1 a r' let disjoint_ref_3 a r r' r'' = disjoint_ref_1 a r /\ disjoint_ref_2 a r' r'' let disjoint_ref_4 a r r' r'' r''' = disjoint_ref_1 a r /\ disjoint_ref_3 a r' r'' r''' let disjoint_ref_5 a r r' r'' r''' r'''' = disjoint_ref_1 a r /\ disjoint_ref_4 a r' r'' r''' r'''' val disjoint_only_lemma: #a:Type -> #a':Type -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint b b')) (ensures (disjoint_from_bufs b (only b'))) let disjoint_only_lemma #a #a' b b' = () (* Fully general modifies clause *) let modifies_bufs_and_refs (bufs:TSet.set abuffer) (refs:Set.set nat) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (Set.union (arefs bufs) refs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs /\ disjoint_from_refs b refs) ==> equal h b h' b /\ live h' b))) (* Fully general modifies clause for buffer sets *) let modifies_buffers (bufs:TSet.set abuffer) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (arefs bufs) h h' /\ (forall (#a:Type) (b:buffer a). {:pattern (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs)} (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs ==> equal h b h' b /\ live h' b)))) (* General modifies clause for buffers only *) let modifies_bufs rid buffs h h' = modifies_ref rid (arefs buffs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b buffs) ==> equal h b h' b /\ live h' b) let modifies_none h h' = HS.get_tip h' == HS.get_tip h /\ HS.modifies_transitively Set.empty h h' (* Specialized clauses for small numbers of buffers *) let modifies_buf_0 rid h h' = modifies_ref rid (Set.empty #nat) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb) ==> equal h bb h' bb /\ live h' bb) let modifies_buf_1 (#t:Type) rid (b:buffer t) h h' = //would be good to drop the rid argument on these, since they can be computed from the buffers modifies_ref rid (Set.singleton (Heap.addr_of (as_ref b))) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb) ==> equal h bb h' bb /\ live h' bb) let to_set_2 (n1:nat) (n2:nat) :Set.set nat = Set.union (Set.singleton n1) (Set.singleton n2) let modifies_buf_2 (#t:Type) (#t':Type) rid (b:buffer t) (b':buffer t') h h' = modifies_ref rid (to_set_2 (as_addr b) (as_addr b')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_3 (n1:nat) (n2:nat) (n3:nat) :Set.set nat = Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3) let modifies_buf_3 (#t:Type) (#t':Type) (#t'':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') h h' = modifies_ref rid (to_set_3 (as_addr b) (as_addr b') (as_addr b'')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_4 (n1:nat) (n2:nat) (n3:nat) (n4:nat) :Set.set nat = Set.union (Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3)) (Set.singleton n4) let modifies_buf_4 (#t:Type) (#t':Type) (#t'':Type) (#t''':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') h h' = modifies_ref rid (to_set_4 (as_addr b) (as_addr b') (as_addr b'') (as_addr b''')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb /\ disjoint b''' bb) ==> equal h bb h' bb /\ live h' bb) (* General lemmas for the modifies_bufs clause *) let lemma_modifies_bufs_trans rid bufs h0 h1 h2 : Lemma (requires (modifies_bufs rid bufs h0 h1 /\ modifies_bufs rid bufs h1 h2)) (ensures (modifies_bufs rid bufs h0 h2)) [SMTPat (modifies_bufs rid bufs h0 h1); SMTPat (modifies_bufs rid bufs h1 h2)] = () let lemma_modifies_bufs_sub rid bufs subbufs h0 h1 : Lemma (requires (TSet.subset subbufs bufs /\ modifies_bufs rid subbufs h0 h1)) (ensures (modifies_bufs rid bufs h0 h1)) [SMTPat (modifies_bufs rid subbufs h0 h1); SMTPat (TSet.subset subbufs bufs)] = () val lemma_modifies_bufs_subset: #a:Type -> #a':Type -> h0:mem -> h1:mem -> bufs:TSet.set abuffer -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint_from_bufs b (bufs ++ (only b')) )) (ensures (disjoint_from_bufs b bufs)) [SMTPat (modifies_bufs (HS.get_tip h0) (bufs ++ (only b')) h0 h1); SMTPat (live h0 b)] let lemma_modifies_bufs_subset #a #a' h0 h1 bufs b b' = () val lemma_modifies_bufs_superset: #a:Type -> #a':Type -> h0:mem -> h1:mem -> bufs:TSet.set abuffer -> b:buffer a -> b':buffer a' -> Lemma (requires (b' `unused_in` h0 /\ live h0 b /\ disjoint_from_bufs b bufs)) (ensures (disjoint_from_bufs b (bufs ++ (only b')))) [SMTPat (modifies_bufs (HS.get_tip h0) bufs h0 h1); SMTPat (b' `unmapped_in` h0); SMTPat (live h0 b)] let lemma_modifies_bufs_superset #a #a' h0 h1 bufs b b' = () (* Specialized lemmas *) let modifies_trans_0_0 (rid:rid) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_0 rid h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_1_0 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_0_1 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_1_1 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_1_1' (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_1 rid b' h1 h2)] = () let modifies_trans_2_0 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_2_1 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_2_1' (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b' b h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b' b h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_0_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_1_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_2_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_3_3 (#t #t' #t'':Type) (rid:rid) (b:buffer t) (b':buffer t') (b'':buffer t'') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_buf_3 rid b b' b'' h1 h2)) (ensures (modifies_buf_3 rid b b' b'' h0 h2)) [SMTPat (modifies_buf_3 rid b b' b'' h0 h1); SMTPat (modifies_buf_3 rid b b' b'' h1 h2)] = () let modifies_trans_4_4 (#t #t' #t'' #t''':Type) (rid:rid) (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_4 rid b b' b'' b''' h0 h1 /\ modifies_buf_4 rid b b' b'' b''' h1 h2)) (ensures (modifies_buf_4 rid b b' b'' b''' h0 h2)) [SMTPat (modifies_buf_4 rid b b' b'' b''' h0 h1); SMTPat (modifies_buf_4 rid b b' b'' b''' h1 h2)] = () (* TODO: complete with specialized versions of every general lemma *) (* Modifies clauses that do not change the shape of the HyperStack ((HS.get_tip h1) = (HS.get_tip h0)) *) (* NB: those clauses are made abstract in order to make verification faster // Lemmas follow to allow the programmer to make use of the real definition // of those predicates in a general setting *) let modifies_0 (h0 h1:mem) :Type0 = modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 (* This one is very generic: it says // * - some references have changed in the frame of b, but // * - among all buffers in this frame, b is the only one that changed. *) let modifies_1 (#a:Type) (b:buffer a) (h0 h1:mem) :Type0 = let rid = frameOf b in modifies_one rid h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 let modifies_2_1 (#a:Type) (b:buffer a) (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in ((rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 ))) let modifies_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= rid' /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 ))) let modifies_3 (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in let rid'' = frameOf b'' in ((rid == rid' /\ rid' == rid'' /\ modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid =!= rid' /\ rid' == rid'' /\ modifies_buf_2 rid' b' b'' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid == rid'' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b'' h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= rid'' /\ rid =!= rid'' /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton rid'')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1))) let modifies_3_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid') (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= HS.get_tip h0 /\ rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1))) let modifies_region (rid:rid) (bufs:TSet.set abuffer) (h0 h1:mem) :Type0 = modifies_one rid h0 h1 /\ modifies_bufs rid bufs h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 (* Lemmas introducing the 'modifies' predicates *) let lemma_intro_modifies_0 h0 h1 : Lemma (requires (modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) (ensures (modifies_0 h0 h1)) = () let lemma_intro_modifies_1 (#a:Type) (b:buffer a) h0 h1 : Lemma (requires (let rid = frameOf b in modifies_one rid h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) (ensures (modifies_1 b h0 h1)) = () let lemma_intro_modifies_2_1 (#a:Type) (b:buffer a) h0 h1 : Lemma (requires ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in ((rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 ))))) (ensures (modifies_2_1 b h0 h1)) = () let lemma_intro_modifies_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= rid' /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 ))))) (ensures (modifies_2 b b' h0 h1)) = () let lemma_intro_modifies_3 (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') h0 h1 : Lemma (requires ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in let rid'' = frameOf b'' in ((rid == rid' /\ rid' == rid'' /\ modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid =!= rid' /\ rid' == rid'' /\ modifies_buf_2 rid' b' b'' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid == rid'' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b'' h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= rid'' /\ rid =!= rid'' /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton rid'')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1))))) (ensures (modifies_3 b b' b'' h0 h1)) = () let lemma_intro_modifies_3_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid') (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= HS.get_tip h0 /\ rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1))))) (ensures (modifies_3_2 b b' h0 h1)) = () let lemma_intro_modifies_region (rid:rid) bufs h0 h1 : Lemma (requires (modifies_one rid h0 h1 /\ modifies_bufs rid bufs h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) (ensures (modifies_region rid bufs h0 h1)) = () (* Lemmas revealing the content of the specialized modifies clauses in order to // be able to generalize them if needs be. *) let lemma_reveal_modifies_0 h0 h1 : Lemma (requires (modifies_0 h0 h1)) (ensures (modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) = () let lemma_reveal_modifies_1 (#a:Type) (b:buffer a) h0 h1 : Lemma (requires (modifies_1 b h0 h1)) (ensures (let rid = frameOf b in modifies_one rid h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) = () let lemma_reveal_modifies_2_1 (#a:Type) (b:buffer a) h0 h1 : Lemma (requires (modifies_2_1 b h0 h1)) (ensures ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in ((rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 ))))) = () let lemma_reveal_modifies_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires (modifies_2 b b' h0 h1)) (ensures ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= rid' /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 )) ))) = () let lemma_reveal_modifies_3 (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') h0 h1 : Lemma (requires (modifies_3 b b' b'' h0 h1)) (ensures ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in let rid'' = frameOf b'' in ((rid == rid' /\ rid' == rid'' /\ modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid =!= rid' /\ rid' == rid'' /\ modifies_buf_2 rid' b' b'' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid == rid'' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b'' h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= rid'' /\ rid =!= rid'' /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton rid'')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1)) ))) = () let lemma_reveal_modifies_3_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires (modifies_3_2 b b' h0 h1)) (ensures ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid') (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= HS.get_tip h0 /\ rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1)) ))) = () let lemma_reveal_modifies_region (rid:rid) bufs h0 h1 : Lemma (requires (modifies_region rid bufs h0 h1)) (ensures (modifies_one rid h0 h1 /\ modifies_bufs rid bufs h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) = () #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0" (* Stack effect specific lemmas *) let lemma_stack_1 (#a:Type) (b:buffer a) h0 h1 h2 h3 : Lemma (requires (live h0 b /\ fresh_frame h0 h1 /\ modifies_1 b h1 h2 /\ popped h2 h3)) (ensures (modifies_buf_1 (frameOf b) b h0 h3)) [SMTPat (modifies_1 b h1 h2); SMTPat (fresh_frame h0 h1); SMTPat (popped h2 h3)] = () let lemma_stack_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 h3 : Lemma (requires (live h0 b /\ live h0 b' /\ fresh_frame h0 h1 /\ modifies_2 b b' h1 h2 /\ popped h2 h3)) (ensures (modifies_2 b b' h0 h3)) [SMTPat (modifies_2 b b' h1 h2); SMTPat (fresh_frame h0 h1); SMTPat (popped h2 h3)] = () (* Specialized modifies clauses lemmas + associated SMTPatterns. Those are critical for // verification as the specialized modifies clauses are abstract from outside the // module *) (** Commutativity lemmas *) let lemma_modifies_2_comm (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires True) (ensures (modifies_2 b b' h0 h1 <==> modifies_2 b' b h0 h1)) [SMTPat (modifies_2 b b' h0 h1)] = () let lemma_modifies_3_2_comm (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires True) (ensures (modifies_3_2 b b' h0 h1 <==> modifies_3_2 b' b h0 h1)) [SMTPat (modifies_3_2 b b' h0 h1)] = () (* TODO: add commutativity lemmas for modifies_3 *) #reset-options "--z3rlimit 20" (** Transitivity lemmas *) let lemma_modifies_0_trans h0 h1 h2 : Lemma (requires (modifies_0 h0 h1 /\ modifies_0 h1 h2)) (ensures (modifies_0 h0 h2)) [SMTPat (modifies_0 h0 h1); SMTPat (modifies_0 h1 h2)] = () let lemma_modifies_1_trans (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (modifies_1 b h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_1 b h1 h2)] = () let lemma_modifies_2_1_trans (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (modifies_2_1 b h0 h1 /\ modifies_2_1 b h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_2_1 b h0 h1); SMTPat (modifies_2_1 b h1 h2)] = () let lemma_modifies_2_trans (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (modifies_2 b b' h0 h1 /\ modifies_2 b b' h1 h2)) (ensures (modifies_2 b b' h0 h2)) (* TODO: Make the following work and merge with the following lemma *) (* [SMTPatOr [ *) (* [SMTPat (modifies_2 b b' h0 h1); *) (* SMTPat (modifies_2 b' b h0 h1)]]; *) (* SMTPat (modifies_2 b' b h1 h2)] *) [SMTPat (modifies_2 b b' h0 h1); SMTPat (modifies_2 b b' h1 h2)] = () let lemma_modifies_2_trans' (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (modifies_2 b b' h0 h1 /\ modifies_2 b b' h1 h2)) (ensures (modifies_2 b b' h0 h2)) [SMTPat (modifies_2 b' b h0 h1); SMTPat (modifies_2 b b' h1 h2)] = () #reset-options "--z3rlimit 40" let lemma_modifies_3_trans (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') h0 h1 h2 : Lemma (requires (modifies_3 b b' b'' h0 h1 /\ modifies_3 b b' b'' h1 h2)) (ensures (modifies_3 b b' b'' h0 h2)) (* TODO: add the appropriate SMTPatOr patterns so as not to rewrite X times the same lemma *) [SMTPat (modifies_3 b b' b'' h0 h1); SMTPat (modifies_3 b b' b'' h1 h2)] = () #reset-options "--z3rlimit 200" let lemma_modifies_3_2_trans (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (modifies_3_2 b b' h0 h1 /\ modifies_3_2 b b' h1 h2)) (ensures (modifies_3_2 b b' h0 h2)) [SMTPat (modifies_3_2 b b' h0 h1); SMTPat (modifies_3_2 b b' h1 h2)] = () let lemma_modifies_3_2_trans' (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (modifies_3_2 b' b h0 h1 /\ modifies_3_2 b b' h1 h2)) (ensures (modifies_3_2 b b' h0 h2)) [SMTPat (modifies_3_2 b' b h0 h1); SMTPat (modifies_3_2 b b' h1 h2)] = () #reset-options "--z3rlimit 20" (* Specific modifies clause lemmas *) val lemma_modifies_0_0: h0:mem -> h1:mem -> h2:mem -> Lemma (requires (modifies_0 h0 h1 /\ modifies_0 h1 h2)) (ensures (modifies_0 h0 h2)) [SMTPat (modifies_0 h0 h1); SMTPat (modifies_0 h1 h2)] let lemma_modifies_0_0 h0 h1 h2 = () #reset-options "--z3rlimit 20 --initial_fuel 0 --max_fuel 0" let lemma_modifies_1_0 (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_1 b h0 h1 /\ modifies_0 h1 h2)) (ensures (live h2 b /\ modifies_2_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_0 h1 h2)] = () let lemma_modifies_0_1 (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_0 h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_0 h0 h1); SMTPat (modifies_1 b h1 h2)] = () let lemma_modifies_0_1' (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (b `unused_in` h0 /\ modifies_0 h0 h1 /\ live h1 b /\ modifies_1 b h1 h2)) (ensures (modifies_0 h0 h2)) [SMTPat (modifies_0 h0 h1); SMTPat (modifies_1 b h1 h2)] = () #reset-options "--z3rlimit 100 --initial_fuel 0 --max_fuel 0" let lemma_modifies_1_1 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_1 b h0 h1 /\ modifies_1 b' h1 h2)) (ensures (modifies_2 b b' h0 h2 /\ modifies_2 b' b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_1 b' h1 h2)] = if frameOf b = frameOf b' then modifies_trans_1_1' (frameOf b) b b' h0 h1 h2 else () #reset-options "--z3rlimit 200 --initial_fuel 0 --max_fuel 0" let lemma_modifies_0_2 (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ b' `unused_in` h0 /\ modifies_0 h0 h1 /\ live h1 b' /\ modifies_2 b b' h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_2 b b' h1 h2); SMTPat (modifies_0 h0 h1)] = () let lemma_modifies_0_2' (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ b' `unused_in` h0 /\ modifies_0 h0 h1 /\ live h1 b' /\ modifies_2 b' b h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_2 b' b h1 h2); SMTPat (modifies_0 h0 h1)] = () let lemma_modifies_1_2 (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_1 b h0 h1 /\ b' `unused_in` h0 /\ live h1 b' /\ modifies_2 b b' h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_2 b b' h1 h2)] = () let lemma_modifies_1_2' (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_1 b h0 h1 /\ b' `unused_in` h0 /\ live h1 b' /\ modifies_2 b' b h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_2 b' b h1 h2)] = () let lemma_modifies_1_2'' (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_1 b h0 h1 /\ modifies_2 b b' h1 h2)) (ensures (modifies_2 b b' h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_2 b b' h1 h2)] = () let lemma_modifies_1_2''' (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_1 b h0 h1 /\ modifies_2 b' b h1 h2)) (ensures (modifies_2 b' b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_2 b' b h1 h2)] = () let lemma_modifies_1_1_prime (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_1 b h0 h1 /\ b' `unused_in` h0 /\ live h1 b' /\ modifies_1 b' h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_1 b' h1 h2)] = () let lemma_modifies_2_1 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_2 b b' h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_2 b b' h0 h2)) [SMTPat (modifies_2 b b' h0 h1); SMTPat (modifies_1 b h1 h2)] = () let lemma_modifies_2_1' (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_2 b' b h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_2 b' b h0 h2)) [SMTPat (modifies_2 b' b h0 h1); SMTPat (modifies_1 b h1 h2)] = () let lemma_modifies_2_1'' (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_2_1 b h0 h1 /\ modifies_1 b' h1 h2)) (ensures (modifies_3_2 b b' h0 h2)) [SMTPat (modifies_2_1 b h0 h1); SMTPat (modifies_1 b' h1 h2)] = () (* TODO: lemmas for modifies_3 *) let lemma_modifies_0_unalloc (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (b `unused_in` h0 /\ frameOf b == HS.get_tip h0 /\ modifies_0 h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_0 h0 h2)) = () let lemma_modifies_none_1_trans (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (modifies_none h0 h1 /\ live h0 b /\ modifies_1 b h1 h2)) (ensures (modifies_1 b h0 h2)) = () let lemma_modifies_0_none_trans h0 h1 h2 : Lemma (requires (modifies_0 h0 h1 /\ modifies_none h1 h2)) (ensures (modifies_0 h0 h2)) = () #reset-options "--initial_fuel 0 --max_fuel 0" (** Concrete getters and setters *) val create: #a:Type -> init:a -> len:UInt32.t -> StackInline (buffer a) (requires (fun h -> True)) (ensures (fun (h0:mem) b h1 -> b `unused_in` h0 /\ live h1 b /\ idx b == 0 /\ length b == v len /\ frameOf b == HS.get_tip h0 /\ Map.domain (HS.get_hmap h1) == Map.domain (HS.get_hmap h0) /\ modifies_0 h0 h1 /\ as_seq h1 b == Seq.create (v len) init)) let create #a init len = let content: reference (lseq a (v len)) = salloc (Seq.create (v len) init) in let b = MkBuffer len content 0ul len in let h = HST.get() in assert (Seq.equal (as_seq h b) (sel h b)); b #reset-options "--initial_fuel 0 --max_fuel 0" unfold let p (#a:Type0) (init:list a) : GTot Type0 = normalize (0 < FStar.List.Tot.length init) /\ normalize (FStar.List.Tot.length init <= UInt.max_int 32) unfold let q (#a:Type0) (len:nat) (buf:buffer a) : GTot Type0 = normalize (length buf == len) (** Concrete getters and setters *) val createL: #a:Type0 -> init:list a -> StackInline (buffer a) (requires (fun h -> p #a init)) (ensures (fun (h0:mem) b h1 -> let len = FStar.List.Tot.length init in len > 0 /\ b `unused_in` h0 /\ live h1 b /\ idx b == 0 /\ length b == len /\ frameOf b == (HS.get_tip h0) /\ Map.domain (HS.get_hmap h1) == Map.domain (HS.get_hmap h0) /\ modifies_0 h0 h1 /\ as_seq h1 b == Seq.seq_of_list init /\ q #a len b)) #set-options "--initial_fuel 1 --max_fuel 1" //the normalize_term (length init) in the pre-condition will be unfolded //whereas the L.length init below will not let createL #a init = let len = UInt32.uint_to_t (FStar.List.Tot.length init) in let s = Seq.seq_of_list init in let content: reference (lseq a (v len)) = salloc (Seq.seq_of_list init) in let b = MkBuffer len content 0ul len in let h = HST.get() in assert (Seq.equal (as_seq h b) (sel h b)); b #reset-options "--initial_fuel 0 --max_fuel 0" let lemma_upd (#a:Type) (h:mem) (x:reference a{live_region h (HS.frameOf x)}) (v:a) : Lemma (requires True) (ensures (Map.domain (HS.get_hmap h) == Map.domain (HS.get_hmap (upd h x v)))) = let m = HS.get_hmap h in let m' = Map.upd m (HS.frameOf x) (Heap.upd (Map.sel m (HS.frameOf x)) (HS.as_ref x) v) in Set.lemma_equal_intro (Map.domain m) (Map.domain m')
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Monotonic.HyperHeap.rid -> init: a -> len: FStar.UInt32.t -> b: FStar.Buffer.buffer a -> h0: FStar.Monotonic.HyperStack.mem -> h1: FStar.Monotonic.HyperStack.mem -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.Monotonic.HyperHeap.rid", "FStar.UInt32.t", "FStar.Buffer.buffer", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "FStar.Buffer.unused_in", "FStar.Buffer.live", "Prims.eq2", "Prims.int", "FStar.Buffer.idx", "Prims.l_or", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt.size", "FStar.UInt32.n", "FStar.Buffer.length", "FStar.UInt32.v", "FStar.Set.set", "FStar.Map.domain", "FStar.Monotonic.Heap.heap", "FStar.Monotonic.HyperStack.get_hmap", "FStar.Monotonic.HyperStack.get_tip", "FStar.Monotonic.HyperStack.modifies", "FStar.Set.singleton", "FStar.Monotonic.HyperStack.modifies_ref", "FStar.Set.empty", "Prims.nat", "FStar.Seq.Base.seq", "FStar.Buffer.as_seq", "FStar.Seq.Base.create" ]
[]
false
false
false
true
true
let rcreate_post_common (#a: Type) (r: rid) (init: a) (len: UInt32.t) (b: buffer a) (h0 h1: mem) : Type0 =
b `unused_in` h0 /\ live h1 b /\ idx b == 0 /\ length b == v len /\ Map.domain (HS.get_hmap h1) == Map.domain (HS.get_hmap h0) /\ HS.get_tip h1 == HS.get_tip h0 /\ modifies (Set.singleton r) h0 h1 /\ modifies_ref r Set.empty h0 h1 /\ as_seq h1 b == Seq.create (v len) init
false
FStar.Buffer.fst
FStar.Buffer.lemma_upd
val lemma_upd (#a: Type) (h: mem) (x: reference a {live_region h (HS.frameOf x)}) (v: a) : Lemma (requires True) (ensures (Map.domain (HS.get_hmap h) == Map.domain (HS.get_hmap (upd h x v))))
val lemma_upd (#a: Type) (h: mem) (x: reference a {live_region h (HS.frameOf x)}) (v: a) : Lemma (requires True) (ensures (Map.domain (HS.get_hmap h) == Map.domain (HS.get_hmap (upd h x v))))
let lemma_upd (#a:Type) (h:mem) (x:reference a{live_region h (HS.frameOf x)}) (v:a) : Lemma (requires True) (ensures (Map.domain (HS.get_hmap h) == Map.domain (HS.get_hmap (upd h x v)))) = let m = HS.get_hmap h in let m' = Map.upd m (HS.frameOf x) (Heap.upd (Map.sel m (HS.frameOf x)) (HS.as_ref x) v) in Set.lemma_equal_intro (Map.domain m) (Map.domain m')
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 56, "end_line": 865, "start_col": 0, "start_line": 860 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b'''' let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) = frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r let disjoint_ref_2 a r r' = disjoint_ref_1 a r /\ disjoint_ref_1 a r' let disjoint_ref_3 a r r' r'' = disjoint_ref_1 a r /\ disjoint_ref_2 a r' r'' let disjoint_ref_4 a r r' r'' r''' = disjoint_ref_1 a r /\ disjoint_ref_3 a r' r'' r''' let disjoint_ref_5 a r r' r'' r''' r'''' = disjoint_ref_1 a r /\ disjoint_ref_4 a r' r'' r''' r'''' val disjoint_only_lemma: #a:Type -> #a':Type -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint b b')) (ensures (disjoint_from_bufs b (only b'))) let disjoint_only_lemma #a #a' b b' = () (* Fully general modifies clause *) let modifies_bufs_and_refs (bufs:TSet.set abuffer) (refs:Set.set nat) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (Set.union (arefs bufs) refs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs /\ disjoint_from_refs b refs) ==> equal h b h' b /\ live h' b))) (* Fully general modifies clause for buffer sets *) let modifies_buffers (bufs:TSet.set abuffer) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (arefs bufs) h h' /\ (forall (#a:Type) (b:buffer a). {:pattern (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs)} (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs ==> equal h b h' b /\ live h' b)))) (* General modifies clause for buffers only *) let modifies_bufs rid buffs h h' = modifies_ref rid (arefs buffs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b buffs) ==> equal h b h' b /\ live h' b) let modifies_none h h' = HS.get_tip h' == HS.get_tip h /\ HS.modifies_transitively Set.empty h h' (* Specialized clauses for small numbers of buffers *) let modifies_buf_0 rid h h' = modifies_ref rid (Set.empty #nat) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb) ==> equal h bb h' bb /\ live h' bb) let modifies_buf_1 (#t:Type) rid (b:buffer t) h h' = //would be good to drop the rid argument on these, since they can be computed from the buffers modifies_ref rid (Set.singleton (Heap.addr_of (as_ref b))) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb) ==> equal h bb h' bb /\ live h' bb) let to_set_2 (n1:nat) (n2:nat) :Set.set nat = Set.union (Set.singleton n1) (Set.singleton n2) let modifies_buf_2 (#t:Type) (#t':Type) rid (b:buffer t) (b':buffer t') h h' = modifies_ref rid (to_set_2 (as_addr b) (as_addr b')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_3 (n1:nat) (n2:nat) (n3:nat) :Set.set nat = Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3) let modifies_buf_3 (#t:Type) (#t':Type) (#t'':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') h h' = modifies_ref rid (to_set_3 (as_addr b) (as_addr b') (as_addr b'')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_4 (n1:nat) (n2:nat) (n3:nat) (n4:nat) :Set.set nat = Set.union (Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3)) (Set.singleton n4) let modifies_buf_4 (#t:Type) (#t':Type) (#t'':Type) (#t''':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') h h' = modifies_ref rid (to_set_4 (as_addr b) (as_addr b') (as_addr b'') (as_addr b''')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb /\ disjoint b''' bb) ==> equal h bb h' bb /\ live h' bb) (* General lemmas for the modifies_bufs clause *) let lemma_modifies_bufs_trans rid bufs h0 h1 h2 : Lemma (requires (modifies_bufs rid bufs h0 h1 /\ modifies_bufs rid bufs h1 h2)) (ensures (modifies_bufs rid bufs h0 h2)) [SMTPat (modifies_bufs rid bufs h0 h1); SMTPat (modifies_bufs rid bufs h1 h2)] = () let lemma_modifies_bufs_sub rid bufs subbufs h0 h1 : Lemma (requires (TSet.subset subbufs bufs /\ modifies_bufs rid subbufs h0 h1)) (ensures (modifies_bufs rid bufs h0 h1)) [SMTPat (modifies_bufs rid subbufs h0 h1); SMTPat (TSet.subset subbufs bufs)] = () val lemma_modifies_bufs_subset: #a:Type -> #a':Type -> h0:mem -> h1:mem -> bufs:TSet.set abuffer -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint_from_bufs b (bufs ++ (only b')) )) (ensures (disjoint_from_bufs b bufs)) [SMTPat (modifies_bufs (HS.get_tip h0) (bufs ++ (only b')) h0 h1); SMTPat (live h0 b)] let lemma_modifies_bufs_subset #a #a' h0 h1 bufs b b' = () val lemma_modifies_bufs_superset: #a:Type -> #a':Type -> h0:mem -> h1:mem -> bufs:TSet.set abuffer -> b:buffer a -> b':buffer a' -> Lemma (requires (b' `unused_in` h0 /\ live h0 b /\ disjoint_from_bufs b bufs)) (ensures (disjoint_from_bufs b (bufs ++ (only b')))) [SMTPat (modifies_bufs (HS.get_tip h0) bufs h0 h1); SMTPat (b' `unmapped_in` h0); SMTPat (live h0 b)] let lemma_modifies_bufs_superset #a #a' h0 h1 bufs b b' = () (* Specialized lemmas *) let modifies_trans_0_0 (rid:rid) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_0 rid h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_1_0 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_0_1 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_1_1 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_1_1' (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_1 rid b' h1 h2)] = () let modifies_trans_2_0 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_2_1 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_2_1' (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b' b h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b' b h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_0_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_1_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_2_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_3_3 (#t #t' #t'':Type) (rid:rid) (b:buffer t) (b':buffer t') (b'':buffer t'') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_buf_3 rid b b' b'' h1 h2)) (ensures (modifies_buf_3 rid b b' b'' h0 h2)) [SMTPat (modifies_buf_3 rid b b' b'' h0 h1); SMTPat (modifies_buf_3 rid b b' b'' h1 h2)] = () let modifies_trans_4_4 (#t #t' #t'' #t''':Type) (rid:rid) (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_4 rid b b' b'' b''' h0 h1 /\ modifies_buf_4 rid b b' b'' b''' h1 h2)) (ensures (modifies_buf_4 rid b b' b'' b''' h0 h2)) [SMTPat (modifies_buf_4 rid b b' b'' b''' h0 h1); SMTPat (modifies_buf_4 rid b b' b'' b''' h1 h2)] = () (* TODO: complete with specialized versions of every general lemma *) (* Modifies clauses that do not change the shape of the HyperStack ((HS.get_tip h1) = (HS.get_tip h0)) *) (* NB: those clauses are made abstract in order to make verification faster // Lemmas follow to allow the programmer to make use of the real definition // of those predicates in a general setting *) let modifies_0 (h0 h1:mem) :Type0 = modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 (* This one is very generic: it says // * - some references have changed in the frame of b, but // * - among all buffers in this frame, b is the only one that changed. *) let modifies_1 (#a:Type) (b:buffer a) (h0 h1:mem) :Type0 = let rid = frameOf b in modifies_one rid h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 let modifies_2_1 (#a:Type) (b:buffer a) (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in ((rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 ))) let modifies_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= rid' /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 ))) let modifies_3 (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in let rid'' = frameOf b'' in ((rid == rid' /\ rid' == rid'' /\ modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid =!= rid' /\ rid' == rid'' /\ modifies_buf_2 rid' b' b'' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid == rid'' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b'' h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= rid'' /\ rid =!= rid'' /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton rid'')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1))) let modifies_3_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid') (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= HS.get_tip h0 /\ rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1))) let modifies_region (rid:rid) (bufs:TSet.set abuffer) (h0 h1:mem) :Type0 = modifies_one rid h0 h1 /\ modifies_bufs rid bufs h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 (* Lemmas introducing the 'modifies' predicates *) let lemma_intro_modifies_0 h0 h1 : Lemma (requires (modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) (ensures (modifies_0 h0 h1)) = () let lemma_intro_modifies_1 (#a:Type) (b:buffer a) h0 h1 : Lemma (requires (let rid = frameOf b in modifies_one rid h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) (ensures (modifies_1 b h0 h1)) = () let lemma_intro_modifies_2_1 (#a:Type) (b:buffer a) h0 h1 : Lemma (requires ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in ((rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 ))))) (ensures (modifies_2_1 b h0 h1)) = () let lemma_intro_modifies_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= rid' /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 ))))) (ensures (modifies_2 b b' h0 h1)) = () let lemma_intro_modifies_3 (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') h0 h1 : Lemma (requires ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in let rid'' = frameOf b'' in ((rid == rid' /\ rid' == rid'' /\ modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid =!= rid' /\ rid' == rid'' /\ modifies_buf_2 rid' b' b'' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid == rid'' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b'' h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= rid'' /\ rid =!= rid'' /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton rid'')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1))))) (ensures (modifies_3 b b' b'' h0 h1)) = () let lemma_intro_modifies_3_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid') (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= HS.get_tip h0 /\ rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1))))) (ensures (modifies_3_2 b b' h0 h1)) = () let lemma_intro_modifies_region (rid:rid) bufs h0 h1 : Lemma (requires (modifies_one rid h0 h1 /\ modifies_bufs rid bufs h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) (ensures (modifies_region rid bufs h0 h1)) = () (* Lemmas revealing the content of the specialized modifies clauses in order to // be able to generalize them if needs be. *) let lemma_reveal_modifies_0 h0 h1 : Lemma (requires (modifies_0 h0 h1)) (ensures (modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) = () let lemma_reveal_modifies_1 (#a:Type) (b:buffer a) h0 h1 : Lemma (requires (modifies_1 b h0 h1)) (ensures (let rid = frameOf b in modifies_one rid h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) = () let lemma_reveal_modifies_2_1 (#a:Type) (b:buffer a) h0 h1 : Lemma (requires (modifies_2_1 b h0 h1)) (ensures ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in ((rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 ))))) = () let lemma_reveal_modifies_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires (modifies_2 b b' h0 h1)) (ensures ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= rid' /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 )) ))) = () let lemma_reveal_modifies_3 (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') h0 h1 : Lemma (requires (modifies_3 b b' b'' h0 h1)) (ensures ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in let rid'' = frameOf b'' in ((rid == rid' /\ rid' == rid'' /\ modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid =!= rid' /\ rid' == rid'' /\ modifies_buf_2 rid' b' b'' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid == rid'' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b'' h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= rid'' /\ rid =!= rid'' /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton rid'')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1)) ))) = () let lemma_reveal_modifies_3_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires (modifies_3_2 b b' h0 h1)) (ensures ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid') (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= HS.get_tip h0 /\ rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1)) ))) = () let lemma_reveal_modifies_region (rid:rid) bufs h0 h1 : Lemma (requires (modifies_region rid bufs h0 h1)) (ensures (modifies_one rid h0 h1 /\ modifies_bufs rid bufs h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) = () #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0" (* Stack effect specific lemmas *) let lemma_stack_1 (#a:Type) (b:buffer a) h0 h1 h2 h3 : Lemma (requires (live h0 b /\ fresh_frame h0 h1 /\ modifies_1 b h1 h2 /\ popped h2 h3)) (ensures (modifies_buf_1 (frameOf b) b h0 h3)) [SMTPat (modifies_1 b h1 h2); SMTPat (fresh_frame h0 h1); SMTPat (popped h2 h3)] = () let lemma_stack_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 h3 : Lemma (requires (live h0 b /\ live h0 b' /\ fresh_frame h0 h1 /\ modifies_2 b b' h1 h2 /\ popped h2 h3)) (ensures (modifies_2 b b' h0 h3)) [SMTPat (modifies_2 b b' h1 h2); SMTPat (fresh_frame h0 h1); SMTPat (popped h2 h3)] = () (* Specialized modifies clauses lemmas + associated SMTPatterns. Those are critical for // verification as the specialized modifies clauses are abstract from outside the // module *) (** Commutativity lemmas *) let lemma_modifies_2_comm (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires True) (ensures (modifies_2 b b' h0 h1 <==> modifies_2 b' b h0 h1)) [SMTPat (modifies_2 b b' h0 h1)] = () let lemma_modifies_3_2_comm (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires True) (ensures (modifies_3_2 b b' h0 h1 <==> modifies_3_2 b' b h0 h1)) [SMTPat (modifies_3_2 b b' h0 h1)] = () (* TODO: add commutativity lemmas for modifies_3 *) #reset-options "--z3rlimit 20" (** Transitivity lemmas *) let lemma_modifies_0_trans h0 h1 h2 : Lemma (requires (modifies_0 h0 h1 /\ modifies_0 h1 h2)) (ensures (modifies_0 h0 h2)) [SMTPat (modifies_0 h0 h1); SMTPat (modifies_0 h1 h2)] = () let lemma_modifies_1_trans (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (modifies_1 b h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_1 b h1 h2)] = () let lemma_modifies_2_1_trans (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (modifies_2_1 b h0 h1 /\ modifies_2_1 b h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_2_1 b h0 h1); SMTPat (modifies_2_1 b h1 h2)] = () let lemma_modifies_2_trans (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (modifies_2 b b' h0 h1 /\ modifies_2 b b' h1 h2)) (ensures (modifies_2 b b' h0 h2)) (* TODO: Make the following work and merge with the following lemma *) (* [SMTPatOr [ *) (* [SMTPat (modifies_2 b b' h0 h1); *) (* SMTPat (modifies_2 b' b h0 h1)]]; *) (* SMTPat (modifies_2 b' b h1 h2)] *) [SMTPat (modifies_2 b b' h0 h1); SMTPat (modifies_2 b b' h1 h2)] = () let lemma_modifies_2_trans' (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (modifies_2 b b' h0 h1 /\ modifies_2 b b' h1 h2)) (ensures (modifies_2 b b' h0 h2)) [SMTPat (modifies_2 b' b h0 h1); SMTPat (modifies_2 b b' h1 h2)] = () #reset-options "--z3rlimit 40" let lemma_modifies_3_trans (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') h0 h1 h2 : Lemma (requires (modifies_3 b b' b'' h0 h1 /\ modifies_3 b b' b'' h1 h2)) (ensures (modifies_3 b b' b'' h0 h2)) (* TODO: add the appropriate SMTPatOr patterns so as not to rewrite X times the same lemma *) [SMTPat (modifies_3 b b' b'' h0 h1); SMTPat (modifies_3 b b' b'' h1 h2)] = () #reset-options "--z3rlimit 200" let lemma_modifies_3_2_trans (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (modifies_3_2 b b' h0 h1 /\ modifies_3_2 b b' h1 h2)) (ensures (modifies_3_2 b b' h0 h2)) [SMTPat (modifies_3_2 b b' h0 h1); SMTPat (modifies_3_2 b b' h1 h2)] = () let lemma_modifies_3_2_trans' (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (modifies_3_2 b' b h0 h1 /\ modifies_3_2 b b' h1 h2)) (ensures (modifies_3_2 b b' h0 h2)) [SMTPat (modifies_3_2 b' b h0 h1); SMTPat (modifies_3_2 b b' h1 h2)] = () #reset-options "--z3rlimit 20" (* Specific modifies clause lemmas *) val lemma_modifies_0_0: h0:mem -> h1:mem -> h2:mem -> Lemma (requires (modifies_0 h0 h1 /\ modifies_0 h1 h2)) (ensures (modifies_0 h0 h2)) [SMTPat (modifies_0 h0 h1); SMTPat (modifies_0 h1 h2)] let lemma_modifies_0_0 h0 h1 h2 = () #reset-options "--z3rlimit 20 --initial_fuel 0 --max_fuel 0" let lemma_modifies_1_0 (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_1 b h0 h1 /\ modifies_0 h1 h2)) (ensures (live h2 b /\ modifies_2_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_0 h1 h2)] = () let lemma_modifies_0_1 (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_0 h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_0 h0 h1); SMTPat (modifies_1 b h1 h2)] = () let lemma_modifies_0_1' (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (b `unused_in` h0 /\ modifies_0 h0 h1 /\ live h1 b /\ modifies_1 b h1 h2)) (ensures (modifies_0 h0 h2)) [SMTPat (modifies_0 h0 h1); SMTPat (modifies_1 b h1 h2)] = () #reset-options "--z3rlimit 100 --initial_fuel 0 --max_fuel 0" let lemma_modifies_1_1 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_1 b h0 h1 /\ modifies_1 b' h1 h2)) (ensures (modifies_2 b b' h0 h2 /\ modifies_2 b' b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_1 b' h1 h2)] = if frameOf b = frameOf b' then modifies_trans_1_1' (frameOf b) b b' h0 h1 h2 else () #reset-options "--z3rlimit 200 --initial_fuel 0 --max_fuel 0" let lemma_modifies_0_2 (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ b' `unused_in` h0 /\ modifies_0 h0 h1 /\ live h1 b' /\ modifies_2 b b' h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_2 b b' h1 h2); SMTPat (modifies_0 h0 h1)] = () let lemma_modifies_0_2' (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ b' `unused_in` h0 /\ modifies_0 h0 h1 /\ live h1 b' /\ modifies_2 b' b h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_2 b' b h1 h2); SMTPat (modifies_0 h0 h1)] = () let lemma_modifies_1_2 (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_1 b h0 h1 /\ b' `unused_in` h0 /\ live h1 b' /\ modifies_2 b b' h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_2 b b' h1 h2)] = () let lemma_modifies_1_2' (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_1 b h0 h1 /\ b' `unused_in` h0 /\ live h1 b' /\ modifies_2 b' b h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_2 b' b h1 h2)] = () let lemma_modifies_1_2'' (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_1 b h0 h1 /\ modifies_2 b b' h1 h2)) (ensures (modifies_2 b b' h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_2 b b' h1 h2)] = () let lemma_modifies_1_2''' (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_1 b h0 h1 /\ modifies_2 b' b h1 h2)) (ensures (modifies_2 b' b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_2 b' b h1 h2)] = () let lemma_modifies_1_1_prime (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_1 b h0 h1 /\ b' `unused_in` h0 /\ live h1 b' /\ modifies_1 b' h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_1 b' h1 h2)] = () let lemma_modifies_2_1 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_2 b b' h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_2 b b' h0 h2)) [SMTPat (modifies_2 b b' h0 h1); SMTPat (modifies_1 b h1 h2)] = () let lemma_modifies_2_1' (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_2 b' b h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_2 b' b h0 h2)) [SMTPat (modifies_2 b' b h0 h1); SMTPat (modifies_1 b h1 h2)] = () let lemma_modifies_2_1'' (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_2_1 b h0 h1 /\ modifies_1 b' h1 h2)) (ensures (modifies_3_2 b b' h0 h2)) [SMTPat (modifies_2_1 b h0 h1); SMTPat (modifies_1 b' h1 h2)] = () (* TODO: lemmas for modifies_3 *) let lemma_modifies_0_unalloc (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (b `unused_in` h0 /\ frameOf b == HS.get_tip h0 /\ modifies_0 h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_0 h0 h2)) = () let lemma_modifies_none_1_trans (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (modifies_none h0 h1 /\ live h0 b /\ modifies_1 b h1 h2)) (ensures (modifies_1 b h0 h2)) = () let lemma_modifies_0_none_trans h0 h1 h2 : Lemma (requires (modifies_0 h0 h1 /\ modifies_none h1 h2)) (ensures (modifies_0 h0 h2)) = () #reset-options "--initial_fuel 0 --max_fuel 0" (** Concrete getters and setters *) val create: #a:Type -> init:a -> len:UInt32.t -> StackInline (buffer a) (requires (fun h -> True)) (ensures (fun (h0:mem) b h1 -> b `unused_in` h0 /\ live h1 b /\ idx b == 0 /\ length b == v len /\ frameOf b == HS.get_tip h0 /\ Map.domain (HS.get_hmap h1) == Map.domain (HS.get_hmap h0) /\ modifies_0 h0 h1 /\ as_seq h1 b == Seq.create (v len) init)) let create #a init len = let content: reference (lseq a (v len)) = salloc (Seq.create (v len) init) in let b = MkBuffer len content 0ul len in let h = HST.get() in assert (Seq.equal (as_seq h b) (sel h b)); b #reset-options "--initial_fuel 0 --max_fuel 0" unfold let p (#a:Type0) (init:list a) : GTot Type0 = normalize (0 < FStar.List.Tot.length init) /\ normalize (FStar.List.Tot.length init <= UInt.max_int 32) unfold let q (#a:Type0) (len:nat) (buf:buffer a) : GTot Type0 = normalize (length buf == len) (** Concrete getters and setters *) val createL: #a:Type0 -> init:list a -> StackInline (buffer a) (requires (fun h -> p #a init)) (ensures (fun (h0:mem) b h1 -> let len = FStar.List.Tot.length init in len > 0 /\ b `unused_in` h0 /\ live h1 b /\ idx b == 0 /\ length b == len /\ frameOf b == (HS.get_tip h0) /\ Map.domain (HS.get_hmap h1) == Map.domain (HS.get_hmap h0) /\ modifies_0 h0 h1 /\ as_seq h1 b == Seq.seq_of_list init /\ q #a len b)) #set-options "--initial_fuel 1 --max_fuel 1" //the normalize_term (length init) in the pre-condition will be unfolded //whereas the L.length init below will not let createL #a init = let len = UInt32.uint_to_t (FStar.List.Tot.length init) in let s = Seq.seq_of_list init in let content: reference (lseq a (v len)) = salloc (Seq.seq_of_list init) in let b = MkBuffer len content 0ul len in let h = HST.get() in assert (Seq.equal (as_seq h b) (sel h b)); b
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
h: FStar.Monotonic.HyperStack.mem -> x: FStar.HyperStack.ST.reference a {FStar.Monotonic.HyperStack.live_region h (FStar.Monotonic.HyperStack.frameOf x)} -> v: a -> FStar.Pervasives.Lemma (ensures FStar.Map.domain (FStar.Monotonic.HyperStack.get_hmap h) == FStar.Map.domain (FStar.Monotonic.HyperStack.get_hmap (FStar.Monotonic.HyperStack.upd h x v)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.reference", "Prims.b2t", "FStar.Monotonic.HyperStack.live_region", "FStar.Monotonic.HyperStack.frameOf", "FStar.Heap.trivial_preorder", "FStar.Set.lemma_equal_intro", "FStar.Monotonic.HyperHeap.rid", "FStar.Map.domain", "FStar.Monotonic.Heap.heap", "FStar.Map.t", "FStar.Map.upd", "FStar.Monotonic.Heap.upd", "FStar.Map.sel", "FStar.Monotonic.HyperStack.as_ref", "FStar.Monotonic.HyperHeap.hmap", "FStar.Monotonic.HyperStack.get_hmap", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.Set.set", "FStar.Monotonic.HyperStack.upd", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let lemma_upd (#a: Type) (h: mem) (x: reference a {live_region h (HS.frameOf x)}) (v: a) : Lemma (requires True) (ensures (Map.domain (HS.get_hmap h) == Map.domain (HS.get_hmap (upd h x v)))) =
let m = HS.get_hmap h in let m' = Map.upd m (HS.frameOf x) (Heap.upd (Map.sel m (HS.frameOf x)) (HS.as_ref x) v) in Set.lemma_equal_intro (Map.domain m) (Map.domain m')
false
FStar.Buffer.fst
FStar.Buffer.rcreate_mm
val rcreate_mm (#a: Type) (r: rid) (init: a) (len: UInt32.t) : ST (buffer a) (requires (fun h0 -> is_eternal_region r)) (ensures (fun h0 b h1 -> rcreate_post_common r init len b h0 h1 /\ is_mm (content b) /\ freeable b))
val rcreate_mm (#a: Type) (r: rid) (init: a) (len: UInt32.t) : ST (buffer a) (requires (fun h0 -> is_eternal_region r)) (ensures (fun h0 b h1 -> rcreate_post_common r init len b h0 h1 /\ is_mm (content b) /\ freeable b))
let rcreate_mm (#a:Type) (r:rid) (init:a) (len:UInt32.t) :ST (buffer a) (requires (fun h0 -> is_eternal_region r)) (ensures (fun h0 b h1 -> rcreate_post_common r init len b h0 h1 /\ is_mm (content b) /\ freeable b)) = rcreate_common r init len true
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 34, "end_line": 913, "start_col": 0, "start_line": 910 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b'''' let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) = frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r let disjoint_ref_2 a r r' = disjoint_ref_1 a r /\ disjoint_ref_1 a r' let disjoint_ref_3 a r r' r'' = disjoint_ref_1 a r /\ disjoint_ref_2 a r' r'' let disjoint_ref_4 a r r' r'' r''' = disjoint_ref_1 a r /\ disjoint_ref_3 a r' r'' r''' let disjoint_ref_5 a r r' r'' r''' r'''' = disjoint_ref_1 a r /\ disjoint_ref_4 a r' r'' r''' r'''' val disjoint_only_lemma: #a:Type -> #a':Type -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint b b')) (ensures (disjoint_from_bufs b (only b'))) let disjoint_only_lemma #a #a' b b' = () (* Fully general modifies clause *) let modifies_bufs_and_refs (bufs:TSet.set abuffer) (refs:Set.set nat) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (Set.union (arefs bufs) refs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs /\ disjoint_from_refs b refs) ==> equal h b h' b /\ live h' b))) (* Fully general modifies clause for buffer sets *) let modifies_buffers (bufs:TSet.set abuffer) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (arefs bufs) h h' /\ (forall (#a:Type) (b:buffer a). {:pattern (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs)} (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs ==> equal h b h' b /\ live h' b)))) (* General modifies clause for buffers only *) let modifies_bufs rid buffs h h' = modifies_ref rid (arefs buffs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b buffs) ==> equal h b h' b /\ live h' b) let modifies_none h h' = HS.get_tip h' == HS.get_tip h /\ HS.modifies_transitively Set.empty h h' (* Specialized clauses for small numbers of buffers *) let modifies_buf_0 rid h h' = modifies_ref rid (Set.empty #nat) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb) ==> equal h bb h' bb /\ live h' bb) let modifies_buf_1 (#t:Type) rid (b:buffer t) h h' = //would be good to drop the rid argument on these, since they can be computed from the buffers modifies_ref rid (Set.singleton (Heap.addr_of (as_ref b))) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb) ==> equal h bb h' bb /\ live h' bb) let to_set_2 (n1:nat) (n2:nat) :Set.set nat = Set.union (Set.singleton n1) (Set.singleton n2) let modifies_buf_2 (#t:Type) (#t':Type) rid (b:buffer t) (b':buffer t') h h' = modifies_ref rid (to_set_2 (as_addr b) (as_addr b')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_3 (n1:nat) (n2:nat) (n3:nat) :Set.set nat = Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3) let modifies_buf_3 (#t:Type) (#t':Type) (#t'':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') h h' = modifies_ref rid (to_set_3 (as_addr b) (as_addr b') (as_addr b'')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_4 (n1:nat) (n2:nat) (n3:nat) (n4:nat) :Set.set nat = Set.union (Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3)) (Set.singleton n4) let modifies_buf_4 (#t:Type) (#t':Type) (#t'':Type) (#t''':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') h h' = modifies_ref rid (to_set_4 (as_addr b) (as_addr b') (as_addr b'') (as_addr b''')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb /\ disjoint b''' bb) ==> equal h bb h' bb /\ live h' bb) (* General lemmas for the modifies_bufs clause *) let lemma_modifies_bufs_trans rid bufs h0 h1 h2 : Lemma (requires (modifies_bufs rid bufs h0 h1 /\ modifies_bufs rid bufs h1 h2)) (ensures (modifies_bufs rid bufs h0 h2)) [SMTPat (modifies_bufs rid bufs h0 h1); SMTPat (modifies_bufs rid bufs h1 h2)] = () let lemma_modifies_bufs_sub rid bufs subbufs h0 h1 : Lemma (requires (TSet.subset subbufs bufs /\ modifies_bufs rid subbufs h0 h1)) (ensures (modifies_bufs rid bufs h0 h1)) [SMTPat (modifies_bufs rid subbufs h0 h1); SMTPat (TSet.subset subbufs bufs)] = () val lemma_modifies_bufs_subset: #a:Type -> #a':Type -> h0:mem -> h1:mem -> bufs:TSet.set abuffer -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint_from_bufs b (bufs ++ (only b')) )) (ensures (disjoint_from_bufs b bufs)) [SMTPat (modifies_bufs (HS.get_tip h0) (bufs ++ (only b')) h0 h1); SMTPat (live h0 b)] let lemma_modifies_bufs_subset #a #a' h0 h1 bufs b b' = () val lemma_modifies_bufs_superset: #a:Type -> #a':Type -> h0:mem -> h1:mem -> bufs:TSet.set abuffer -> b:buffer a -> b':buffer a' -> Lemma (requires (b' `unused_in` h0 /\ live h0 b /\ disjoint_from_bufs b bufs)) (ensures (disjoint_from_bufs b (bufs ++ (only b')))) [SMTPat (modifies_bufs (HS.get_tip h0) bufs h0 h1); SMTPat (b' `unmapped_in` h0); SMTPat (live h0 b)] let lemma_modifies_bufs_superset #a #a' h0 h1 bufs b b' = () (* Specialized lemmas *) let modifies_trans_0_0 (rid:rid) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_0 rid h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_1_0 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_0_1 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_1_1 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_1_1' (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_1 rid b' h1 h2)] = () let modifies_trans_2_0 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_2_1 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_2_1' (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b' b h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b' b h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_0_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_1_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_2_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_3_3 (#t #t' #t'':Type) (rid:rid) (b:buffer t) (b':buffer t') (b'':buffer t'') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_buf_3 rid b b' b'' h1 h2)) (ensures (modifies_buf_3 rid b b' b'' h0 h2)) [SMTPat (modifies_buf_3 rid b b' b'' h0 h1); SMTPat (modifies_buf_3 rid b b' b'' h1 h2)] = () let modifies_trans_4_4 (#t #t' #t'' #t''':Type) (rid:rid) (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_4 rid b b' b'' b''' h0 h1 /\ modifies_buf_4 rid b b' b'' b''' h1 h2)) (ensures (modifies_buf_4 rid b b' b'' b''' h0 h2)) [SMTPat (modifies_buf_4 rid b b' b'' b''' h0 h1); SMTPat (modifies_buf_4 rid b b' b'' b''' h1 h2)] = () (* TODO: complete with specialized versions of every general lemma *) (* Modifies clauses that do not change the shape of the HyperStack ((HS.get_tip h1) = (HS.get_tip h0)) *) (* NB: those clauses are made abstract in order to make verification faster // Lemmas follow to allow the programmer to make use of the real definition // of those predicates in a general setting *) let modifies_0 (h0 h1:mem) :Type0 = modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 (* This one is very generic: it says // * - some references have changed in the frame of b, but // * - among all buffers in this frame, b is the only one that changed. *) let modifies_1 (#a:Type) (b:buffer a) (h0 h1:mem) :Type0 = let rid = frameOf b in modifies_one rid h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 let modifies_2_1 (#a:Type) (b:buffer a) (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in ((rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 ))) let modifies_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= rid' /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 ))) let modifies_3 (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in let rid'' = frameOf b'' in ((rid == rid' /\ rid' == rid'' /\ modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid =!= rid' /\ rid' == rid'' /\ modifies_buf_2 rid' b' b'' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid == rid'' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b'' h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= rid'' /\ rid =!= rid'' /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton rid'')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1))) let modifies_3_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid') (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= HS.get_tip h0 /\ rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1))) let modifies_region (rid:rid) (bufs:TSet.set abuffer) (h0 h1:mem) :Type0 = modifies_one rid h0 h1 /\ modifies_bufs rid bufs h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 (* Lemmas introducing the 'modifies' predicates *) let lemma_intro_modifies_0 h0 h1 : Lemma (requires (modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) (ensures (modifies_0 h0 h1)) = () let lemma_intro_modifies_1 (#a:Type) (b:buffer a) h0 h1 : Lemma (requires (let rid = frameOf b in modifies_one rid h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) (ensures (modifies_1 b h0 h1)) = () let lemma_intro_modifies_2_1 (#a:Type) (b:buffer a) h0 h1 : Lemma (requires ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in ((rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 ))))) (ensures (modifies_2_1 b h0 h1)) = () let lemma_intro_modifies_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= rid' /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 ))))) (ensures (modifies_2 b b' h0 h1)) = () let lemma_intro_modifies_3 (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') h0 h1 : Lemma (requires ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in let rid'' = frameOf b'' in ((rid == rid' /\ rid' == rid'' /\ modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid =!= rid' /\ rid' == rid'' /\ modifies_buf_2 rid' b' b'' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid == rid'' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b'' h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= rid'' /\ rid =!= rid'' /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton rid'')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1))))) (ensures (modifies_3 b b' b'' h0 h1)) = () let lemma_intro_modifies_3_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid') (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= HS.get_tip h0 /\ rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1))))) (ensures (modifies_3_2 b b' h0 h1)) = () let lemma_intro_modifies_region (rid:rid) bufs h0 h1 : Lemma (requires (modifies_one rid h0 h1 /\ modifies_bufs rid bufs h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) (ensures (modifies_region rid bufs h0 h1)) = () (* Lemmas revealing the content of the specialized modifies clauses in order to // be able to generalize them if needs be. *) let lemma_reveal_modifies_0 h0 h1 : Lemma (requires (modifies_0 h0 h1)) (ensures (modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) = () let lemma_reveal_modifies_1 (#a:Type) (b:buffer a) h0 h1 : Lemma (requires (modifies_1 b h0 h1)) (ensures (let rid = frameOf b in modifies_one rid h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) = () let lemma_reveal_modifies_2_1 (#a:Type) (b:buffer a) h0 h1 : Lemma (requires (modifies_2_1 b h0 h1)) (ensures ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in ((rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 ))))) = () let lemma_reveal_modifies_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires (modifies_2 b b' h0 h1)) (ensures ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= rid' /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 )) ))) = () let lemma_reveal_modifies_3 (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') h0 h1 : Lemma (requires (modifies_3 b b' b'' h0 h1)) (ensures ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in let rid'' = frameOf b'' in ((rid == rid' /\ rid' == rid'' /\ modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid =!= rid' /\ rid' == rid'' /\ modifies_buf_2 rid' b' b'' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid == rid'' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b'' h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= rid'' /\ rid =!= rid'' /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton rid'')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1)) ))) = () let lemma_reveal_modifies_3_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires (modifies_3_2 b b' h0 h1)) (ensures ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid') (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= HS.get_tip h0 /\ rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1)) ))) = () let lemma_reveal_modifies_region (rid:rid) bufs h0 h1 : Lemma (requires (modifies_region rid bufs h0 h1)) (ensures (modifies_one rid h0 h1 /\ modifies_bufs rid bufs h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) = () #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0" (* Stack effect specific lemmas *) let lemma_stack_1 (#a:Type) (b:buffer a) h0 h1 h2 h3 : Lemma (requires (live h0 b /\ fresh_frame h0 h1 /\ modifies_1 b h1 h2 /\ popped h2 h3)) (ensures (modifies_buf_1 (frameOf b) b h0 h3)) [SMTPat (modifies_1 b h1 h2); SMTPat (fresh_frame h0 h1); SMTPat (popped h2 h3)] = () let lemma_stack_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 h3 : Lemma (requires (live h0 b /\ live h0 b' /\ fresh_frame h0 h1 /\ modifies_2 b b' h1 h2 /\ popped h2 h3)) (ensures (modifies_2 b b' h0 h3)) [SMTPat (modifies_2 b b' h1 h2); SMTPat (fresh_frame h0 h1); SMTPat (popped h2 h3)] = () (* Specialized modifies clauses lemmas + associated SMTPatterns. Those are critical for // verification as the specialized modifies clauses are abstract from outside the // module *) (** Commutativity lemmas *) let lemma_modifies_2_comm (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires True) (ensures (modifies_2 b b' h0 h1 <==> modifies_2 b' b h0 h1)) [SMTPat (modifies_2 b b' h0 h1)] = () let lemma_modifies_3_2_comm (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires True) (ensures (modifies_3_2 b b' h0 h1 <==> modifies_3_2 b' b h0 h1)) [SMTPat (modifies_3_2 b b' h0 h1)] = () (* TODO: add commutativity lemmas for modifies_3 *) #reset-options "--z3rlimit 20" (** Transitivity lemmas *) let lemma_modifies_0_trans h0 h1 h2 : Lemma (requires (modifies_0 h0 h1 /\ modifies_0 h1 h2)) (ensures (modifies_0 h0 h2)) [SMTPat (modifies_0 h0 h1); SMTPat (modifies_0 h1 h2)] = () let lemma_modifies_1_trans (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (modifies_1 b h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_1 b h1 h2)] = () let lemma_modifies_2_1_trans (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (modifies_2_1 b h0 h1 /\ modifies_2_1 b h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_2_1 b h0 h1); SMTPat (modifies_2_1 b h1 h2)] = () let lemma_modifies_2_trans (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (modifies_2 b b' h0 h1 /\ modifies_2 b b' h1 h2)) (ensures (modifies_2 b b' h0 h2)) (* TODO: Make the following work and merge with the following lemma *) (* [SMTPatOr [ *) (* [SMTPat (modifies_2 b b' h0 h1); *) (* SMTPat (modifies_2 b' b h0 h1)]]; *) (* SMTPat (modifies_2 b' b h1 h2)] *) [SMTPat (modifies_2 b b' h0 h1); SMTPat (modifies_2 b b' h1 h2)] = () let lemma_modifies_2_trans' (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (modifies_2 b b' h0 h1 /\ modifies_2 b b' h1 h2)) (ensures (modifies_2 b b' h0 h2)) [SMTPat (modifies_2 b' b h0 h1); SMTPat (modifies_2 b b' h1 h2)] = () #reset-options "--z3rlimit 40" let lemma_modifies_3_trans (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') h0 h1 h2 : Lemma (requires (modifies_3 b b' b'' h0 h1 /\ modifies_3 b b' b'' h1 h2)) (ensures (modifies_3 b b' b'' h0 h2)) (* TODO: add the appropriate SMTPatOr patterns so as not to rewrite X times the same lemma *) [SMTPat (modifies_3 b b' b'' h0 h1); SMTPat (modifies_3 b b' b'' h1 h2)] = () #reset-options "--z3rlimit 200" let lemma_modifies_3_2_trans (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (modifies_3_2 b b' h0 h1 /\ modifies_3_2 b b' h1 h2)) (ensures (modifies_3_2 b b' h0 h2)) [SMTPat (modifies_3_2 b b' h0 h1); SMTPat (modifies_3_2 b b' h1 h2)] = () let lemma_modifies_3_2_trans' (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (modifies_3_2 b' b h0 h1 /\ modifies_3_2 b b' h1 h2)) (ensures (modifies_3_2 b b' h0 h2)) [SMTPat (modifies_3_2 b' b h0 h1); SMTPat (modifies_3_2 b b' h1 h2)] = () #reset-options "--z3rlimit 20" (* Specific modifies clause lemmas *) val lemma_modifies_0_0: h0:mem -> h1:mem -> h2:mem -> Lemma (requires (modifies_0 h0 h1 /\ modifies_0 h1 h2)) (ensures (modifies_0 h0 h2)) [SMTPat (modifies_0 h0 h1); SMTPat (modifies_0 h1 h2)] let lemma_modifies_0_0 h0 h1 h2 = () #reset-options "--z3rlimit 20 --initial_fuel 0 --max_fuel 0" let lemma_modifies_1_0 (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_1 b h0 h1 /\ modifies_0 h1 h2)) (ensures (live h2 b /\ modifies_2_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_0 h1 h2)] = () let lemma_modifies_0_1 (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_0 h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_0 h0 h1); SMTPat (modifies_1 b h1 h2)] = () let lemma_modifies_0_1' (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (b `unused_in` h0 /\ modifies_0 h0 h1 /\ live h1 b /\ modifies_1 b h1 h2)) (ensures (modifies_0 h0 h2)) [SMTPat (modifies_0 h0 h1); SMTPat (modifies_1 b h1 h2)] = () #reset-options "--z3rlimit 100 --initial_fuel 0 --max_fuel 0" let lemma_modifies_1_1 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_1 b h0 h1 /\ modifies_1 b' h1 h2)) (ensures (modifies_2 b b' h0 h2 /\ modifies_2 b' b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_1 b' h1 h2)] = if frameOf b = frameOf b' then modifies_trans_1_1' (frameOf b) b b' h0 h1 h2 else () #reset-options "--z3rlimit 200 --initial_fuel 0 --max_fuel 0" let lemma_modifies_0_2 (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ b' `unused_in` h0 /\ modifies_0 h0 h1 /\ live h1 b' /\ modifies_2 b b' h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_2 b b' h1 h2); SMTPat (modifies_0 h0 h1)] = () let lemma_modifies_0_2' (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ b' `unused_in` h0 /\ modifies_0 h0 h1 /\ live h1 b' /\ modifies_2 b' b h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_2 b' b h1 h2); SMTPat (modifies_0 h0 h1)] = () let lemma_modifies_1_2 (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_1 b h0 h1 /\ b' `unused_in` h0 /\ live h1 b' /\ modifies_2 b b' h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_2 b b' h1 h2)] = () let lemma_modifies_1_2' (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_1 b h0 h1 /\ b' `unused_in` h0 /\ live h1 b' /\ modifies_2 b' b h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_2 b' b h1 h2)] = () let lemma_modifies_1_2'' (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_1 b h0 h1 /\ modifies_2 b b' h1 h2)) (ensures (modifies_2 b b' h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_2 b b' h1 h2)] = () let lemma_modifies_1_2''' (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_1 b h0 h1 /\ modifies_2 b' b h1 h2)) (ensures (modifies_2 b' b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_2 b' b h1 h2)] = () let lemma_modifies_1_1_prime (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_1 b h0 h1 /\ b' `unused_in` h0 /\ live h1 b' /\ modifies_1 b' h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_1 b' h1 h2)] = () let lemma_modifies_2_1 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_2 b b' h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_2 b b' h0 h2)) [SMTPat (modifies_2 b b' h0 h1); SMTPat (modifies_1 b h1 h2)] = () let lemma_modifies_2_1' (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_2 b' b h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_2 b' b h0 h2)) [SMTPat (modifies_2 b' b h0 h1); SMTPat (modifies_1 b h1 h2)] = () let lemma_modifies_2_1'' (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_2_1 b h0 h1 /\ modifies_1 b' h1 h2)) (ensures (modifies_3_2 b b' h0 h2)) [SMTPat (modifies_2_1 b h0 h1); SMTPat (modifies_1 b' h1 h2)] = () (* TODO: lemmas for modifies_3 *) let lemma_modifies_0_unalloc (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (b `unused_in` h0 /\ frameOf b == HS.get_tip h0 /\ modifies_0 h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_0 h0 h2)) = () let lemma_modifies_none_1_trans (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (modifies_none h0 h1 /\ live h0 b /\ modifies_1 b h1 h2)) (ensures (modifies_1 b h0 h2)) = () let lemma_modifies_0_none_trans h0 h1 h2 : Lemma (requires (modifies_0 h0 h1 /\ modifies_none h1 h2)) (ensures (modifies_0 h0 h2)) = () #reset-options "--initial_fuel 0 --max_fuel 0" (** Concrete getters and setters *) val create: #a:Type -> init:a -> len:UInt32.t -> StackInline (buffer a) (requires (fun h -> True)) (ensures (fun (h0:mem) b h1 -> b `unused_in` h0 /\ live h1 b /\ idx b == 0 /\ length b == v len /\ frameOf b == HS.get_tip h0 /\ Map.domain (HS.get_hmap h1) == Map.domain (HS.get_hmap h0) /\ modifies_0 h0 h1 /\ as_seq h1 b == Seq.create (v len) init)) let create #a init len = let content: reference (lseq a (v len)) = salloc (Seq.create (v len) init) in let b = MkBuffer len content 0ul len in let h = HST.get() in assert (Seq.equal (as_seq h b) (sel h b)); b #reset-options "--initial_fuel 0 --max_fuel 0" unfold let p (#a:Type0) (init:list a) : GTot Type0 = normalize (0 < FStar.List.Tot.length init) /\ normalize (FStar.List.Tot.length init <= UInt.max_int 32) unfold let q (#a:Type0) (len:nat) (buf:buffer a) : GTot Type0 = normalize (length buf == len) (** Concrete getters and setters *) val createL: #a:Type0 -> init:list a -> StackInline (buffer a) (requires (fun h -> p #a init)) (ensures (fun (h0:mem) b h1 -> let len = FStar.List.Tot.length init in len > 0 /\ b `unused_in` h0 /\ live h1 b /\ idx b == 0 /\ length b == len /\ frameOf b == (HS.get_tip h0) /\ Map.domain (HS.get_hmap h1) == Map.domain (HS.get_hmap h0) /\ modifies_0 h0 h1 /\ as_seq h1 b == Seq.seq_of_list init /\ q #a len b)) #set-options "--initial_fuel 1 --max_fuel 1" //the normalize_term (length init) in the pre-condition will be unfolded //whereas the L.length init below will not let createL #a init = let len = UInt32.uint_to_t (FStar.List.Tot.length init) in let s = Seq.seq_of_list init in let content: reference (lseq a (v len)) = salloc (Seq.seq_of_list init) in let b = MkBuffer len content 0ul len in let h = HST.get() in assert (Seq.equal (as_seq h b) (sel h b)); b #reset-options "--initial_fuel 0 --max_fuel 0" let lemma_upd (#a:Type) (h:mem) (x:reference a{live_region h (HS.frameOf x)}) (v:a) : Lemma (requires True) (ensures (Map.domain (HS.get_hmap h) == Map.domain (HS.get_hmap (upd h x v)))) = let m = HS.get_hmap h in let m' = Map.upd m (HS.frameOf x) (Heap.upd (Map.sel m (HS.frameOf x)) (HS.as_ref x) v) in Set.lemma_equal_intro (Map.domain m) (Map.domain m') unfold let rcreate_post_common (#a:Type) (r:rid) (init:a) (len:UInt32.t) (b:buffer a) (h0 h1:mem) :Type0 = b `unused_in` h0 /\ live h1 b /\ idx b == 0 /\ length b == v len /\ Map.domain (HS.get_hmap h1) == Map.domain (HS.get_hmap h0) /\ HS.get_tip h1 == HS.get_tip h0 /\ modifies (Set.singleton r) h0 h1 /\ modifies_ref r Set.empty h0 h1 /\ as_seq h1 b == Seq.create (v len) init private let rcreate_common (#a:Type) (r:rid) (init:a) (len:UInt32.t) (mm:bool) :ST (buffer a) (requires (fun h0 -> is_eternal_region r)) (ensures (fun h0 b h1 -> rcreate_post_common r init len b h0 h1 /\ is_mm b.content == mm)) = let h0 = HST.get() in let s = Seq.create (v len) init in let content: reference (lseq a (v len)) = if mm then ralloc_mm r s else ralloc r s in let b = MkBuffer len content 0ul len in let h1 = HST.get() in assert (Seq.equal (as_seq h1 b) (sel h1 b)); lemma_upd h0 content s; b (** This function allocates a buffer in an "eternal" region, i.e. a region where memory is // * automatically-managed. One does not need to call rfree on such a buffer. It // * translates to C as a call to malloc and assumes a conservative garbage // * collector is running. *) val rcreate: #a:Type -> r:rid -> init:a -> len:UInt32.t -> ST (buffer a) (requires (fun h -> is_eternal_region r)) (ensures (fun (h0:mem) b h1 -> rcreate_post_common r init len b h0 h1 /\ ~(is_mm b.content))) let rcreate #a r init len = rcreate_common r init len false (** This predicate tells whether a buffer can be `rfree`d. The only way to produce it should be `rcreate_mm`, and the only way to consume it should be `rfree.` Rationale: a buffer can be `rfree`d only if it is the result of `rcreate_mm`. Subbuffers should not. *) let freeable (#a: Type) (b: buffer a) : GTot Type0 = is_mm b.content /\ is_eternal_region (frameOf b) /\ idx b == 0 (** This function allocates a buffer into a manually-managed buffer in a heap * region, meaning that the client must call rfree in order to avoid memory
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Monotonic.HyperHeap.rid -> init: a -> len: FStar.UInt32.t -> FStar.HyperStack.ST.ST (FStar.Buffer.buffer a)
FStar.HyperStack.ST.ST
[]
[]
[ "FStar.Monotonic.HyperHeap.rid", "FStar.UInt32.t", "FStar.Buffer.rcreate_common", "FStar.Buffer.buffer", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.is_eternal_region", "Prims.l_and", "FStar.Buffer.rcreate_post_common", "Prims.b2t", "FStar.Monotonic.HyperStack.is_mm", "FStar.Buffer.lseq", "FStar.Buffer.max_length", "FStar.Heap.trivial_preorder", "FStar.Buffer.content", "FStar.Buffer.freeable" ]
[]
false
true
false
false
false
let rcreate_mm (#a: Type) (r: rid) (init: a) (len: UInt32.t) : ST (buffer a) (requires (fun h0 -> is_eternal_region r)) (ensures (fun h0 b h1 -> rcreate_post_common r init len b h0 h1 /\ is_mm (content b) /\ freeable b)) =
rcreate_common r init len true
false
FStar.Buffer.fst
FStar.Buffer.freeable
val freeable (#a: Type) (b: buffer a) : GTot Type0
val freeable (#a: Type) (b: buffer a) : GTot Type0
let freeable (#a: Type) (b: buffer a) : GTot Type0 = is_mm b.content /\ is_eternal_region (frameOf b) /\ idx b == 0
{ "file_name": "ulib/legacy/FStar.Buffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 64, "end_line": 905, "start_col": 0, "start_line": 904 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Buffer open FStar.Seq open FStar.UInt32 module Int32 = FStar.Int32 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Ghost module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--initial_fuel 0 --max_fuel 0" //17-01-04 usage? move to UInt? let lemma_size (x:int) : Lemma (requires (UInt.size x n)) (ensures (x >= 0)) [SMTPat (UInt.size x n)] = () let lseq (a: Type) (l: nat) : Type = (s: seq a { Seq.length s == l } ) (* Buffer general type, fully implemented on FStar's arrays *) noeq private type _buffer (a:Type) = | MkBuffer: max_length:UInt32.t -> content:reference (lseq a (v max_length)) -> idx:UInt32.t -> length:UInt32.t{v idx + v length <= v max_length} -> _buffer a (* Exposed buffer type *) type buffer (a:Type) = _buffer a (* Ghost getters for specifications *) // TODO: remove `contains` after replacing all uses with `live` let contains #a h (b:buffer a) : GTot Type0 = HS.contains h b.content let unused_in #a (b:buffer a) h : GTot Type0 = HS.unused_in b.content h (* In most cases `as_seq` should be used instead of this one. *) let sel #a h (b:buffer a) : GTot (seq a) = HS.sel h b.content let max_length #a (b:buffer a) : GTot nat = v b.max_length let length #a (b:buffer a) : GTot nat = v b.length let idx #a (b:buffer a) : GTot nat = v b.idx //17-01-04 rename to container or ref? let content #a (b:buffer a) : GTot (reference (lseq a (max_length b))) = b.content (* Lifting from buffer to reference *) let as_ref #a (b:buffer a) = as_ref (content b) let as_addr #a (b:buffer a) = as_addr (content b) let frameOf #a (b:buffer a) : GTot HS.rid = HS.frameOf (content b) (* Liveliness condition, necessary for any computation on the buffer *) let live #a (h:mem) (b:buffer a) : GTot Type0 = HS.contains h b.content let unmapped_in #a (b:buffer a) (h:mem) : GTot Type0 = unused_in b h val recall: #a:Type -> b:buffer a{is_eternal_region (frameOf b) /\ not (is_mm b.content)} -> Stack unit (requires (fun m -> True)) (ensures (fun m0 _ m1 -> m0 == m1 /\ live m1 b)) let recall #a b = recall b.content (* Ghostly access an element of the array, or the full underlying sequence *) let as_seq #a h (b:buffer a) : GTot (s:seq a{Seq.length s == length b}) = Seq.slice (sel h b) (idx b) (idx b + length b) let get #a h (b:buffer a) (i:nat{i < length b}) : GTot a = Seq.index (as_seq h b) i (* Equality predicate on buffer contents, without quantifiers *) //17-01-04 revise comment? rename? let equal #a h (b:buffer a) h' (b':buffer a) : GTot Type0 = as_seq h b == as_seq h' b' (* y is included in x / x contains y *) let includes #a (x:buffer a) (y:buffer a) : GTot Type0 = x.max_length == y.max_length /\ x.content === y.content /\ idx y >= idx x /\ idx x + length x >= idx y + length y let includes_live #a h (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y)) (ensures (live h x <==> live h y)) = () let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a) : Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) (ensures (as_seq h1 y == as_seq h2 y)) = Seq.slice_slice (sel h1 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y); Seq.slice_slice (sel h2 x) (idx x) (idx x + length x) (idx y - idx x) (idx y - idx x + length y) let includes_trans #a (x y z: buffer a) : Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = () (* Disjointness between two buffers *) let disjoint #a #a' (x:buffer a) (y:buffer a') : GTot Type0 = frameOf x =!= frameOf y \/ as_addr x =!= as_addr y \/ (a == a' /\ as_addr x == as_addr y /\ frameOf x == frameOf y /\ x.max_length == y.max_length /\ (idx x + length x <= idx y \/ idx y + length y <= idx x)) (* Disjointness is symmetric *) let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma (requires True) (ensures (disjoint x y <==> disjoint y x)) [SMTPat (disjoint x y)] = () let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint subx y); SMTPat (includes x subx)] = () let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma (requires (includes x subx /\ disjoint x y)) (ensures (disjoint subx y)) [SMTPat (disjoint y subx); SMTPat (includes x subx)] = () val lemma_live_disjoint: #a:Type -> #a':Type -> h:mem -> b:buffer a -> b':buffer a' -> Lemma (requires (live h b /\ b' `unused_in` h)) (ensures (disjoint b b')) [SMTPat (disjoint b b'); SMTPat (live h b)] let lemma_live_disjoint #a #a' h b b' = () (* Heterogeneous buffer type *) noeq type abuffer = | Buff: #t:Type -> b:buffer t -> abuffer (* let empty : TSet.set abuffer = TSet.empty #abuffer *) let only #t (b:buffer t) : Tot (TSet.set abuffer) = FStar.TSet.singleton (Buff #t b) (* let op_Plus_Plus #a s (b:buffer a) : Tot (TSet.set abuffer) = TSet.union s (only b) *) (* let op_Plus_Plus_Plus set1 set2 : Tot (TSet.set abuffer) = FStar.TSet.union set1 set2 *) let op_Bang_Bang = TSet.singleton let op_Plus_Plus = TSet.union (* Maps a set of buffer to the set of their references *) assume val arefs: TSet.set abuffer -> Tot (Set.set nat) assume Arefs_def: forall (x:nat) (s:TSet.set abuffer). {:pattern (Set.mem x (arefs s))} Set.mem x (arefs s) <==> (exists (y:abuffer). TSet.mem y s /\ as_addr y.b == x) val lemma_arefs_1: s:TSet.set abuffer -> Lemma (requires (s == TSet.empty #abuffer)) (ensures (arefs s == Set.empty #nat)) [SMTPat (arefs s)] let lemma_arefs_1 s = Set.lemma_equal_intro (arefs s) (Set.empty) val lemma_arefs_2: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires True) (ensures (arefs (s1 ++ s2) == Set.union (arefs s1) (arefs s2))) [SMTPatOr [ [SMTPat (arefs (s2 ++ s1))]; [SMTPat (arefs (s1 ++ s2))] ]] let lemma_arefs_2 s1 s2 = Set.lemma_equal_intro (arefs (s1 ++ s2)) (Set.union (arefs s1) (arefs s2)) val lemma_arefs_3: s1:TSet.set abuffer -> s2:TSet.set abuffer -> Lemma (requires (TSet.subset s1 s2)) (ensures (Set.subset (arefs s1) (arefs s2))) let lemma_arefs_3 s1 s2 = () (* General disjointness predicate between a buffer and a set of heterogeneous buffers *) let disjoint_from_bufs #a (b:buffer a) (bufs:TSet.set abuffer) = forall b'. TSet.mem b' bufs ==> disjoint b b'.b (* General disjointness predicate between a buffer and a set of heterogeneous references *) let disjoint_from_refs #a (b:buffer a) (set:Set.set nat) = ~(Set.mem (as_addr b) set) (* Similar but specialized disjointness predicates *) let disjoint_1 a b = disjoint a b let disjoint_2 a b b' = disjoint a b /\ disjoint a b' let disjoint_3 a b b' b'' = disjoint a b /\ disjoint a b' /\ disjoint a b'' let disjoint_4 a b b' b'' b''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' let disjoint_5 a b b' b'' b''' b'''' = disjoint a b /\ disjoint a b' /\ disjoint a b'' /\ disjoint a b''' /\ disjoint a b'''' let disjoint_ref_1 (#t:Type) (#u:Type) (a:buffer t) (r:reference u) = frameOf a =!= HS.frameOf r \/ as_addr a =!= HS.as_addr r let disjoint_ref_2 a r r' = disjoint_ref_1 a r /\ disjoint_ref_1 a r' let disjoint_ref_3 a r r' r'' = disjoint_ref_1 a r /\ disjoint_ref_2 a r' r'' let disjoint_ref_4 a r r' r'' r''' = disjoint_ref_1 a r /\ disjoint_ref_3 a r' r'' r''' let disjoint_ref_5 a r r' r'' r''' r'''' = disjoint_ref_1 a r /\ disjoint_ref_4 a r' r'' r''' r'''' val disjoint_only_lemma: #a:Type -> #a':Type -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint b b')) (ensures (disjoint_from_bufs b (only b'))) let disjoint_only_lemma #a #a' b b' = () (* Fully general modifies clause *) let modifies_bufs_and_refs (bufs:TSet.set abuffer) (refs:Set.set nat) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (Set.union (arefs bufs) refs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs /\ disjoint_from_refs b refs) ==> equal h b h' b /\ live h' b))) (* Fully general modifies clause for buffer sets *) let modifies_buffers (bufs:TSet.set abuffer) h h' : GTot Type0 = (forall rid. Set.mem rid (Map.domain (HS.get_hmap h)) ==> (HS.modifies_ref rid (arefs bufs) h h' /\ (forall (#a:Type) (b:buffer a). {:pattern (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs)} (frameOf b == rid /\ live h b /\ disjoint_from_bufs b bufs ==> equal h b h' b /\ live h' b)))) (* General modifies clause for buffers only *) let modifies_bufs rid buffs h h' = modifies_ref rid (arefs buffs) h h' /\ (forall (#a:Type) (b:buffer a). (frameOf b == rid /\ live h b /\ disjoint_from_bufs b buffs) ==> equal h b h' b /\ live h' b) let modifies_none h h' = HS.get_tip h' == HS.get_tip h /\ HS.modifies_transitively Set.empty h h' (* Specialized clauses for small numbers of buffers *) let modifies_buf_0 rid h h' = modifies_ref rid (Set.empty #nat) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb) ==> equal h bb h' bb /\ live h' bb) let modifies_buf_1 (#t:Type) rid (b:buffer t) h h' = //would be good to drop the rid argument on these, since they can be computed from the buffers modifies_ref rid (Set.singleton (Heap.addr_of (as_ref b))) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb) ==> equal h bb h' bb /\ live h' bb) let to_set_2 (n1:nat) (n2:nat) :Set.set nat = Set.union (Set.singleton n1) (Set.singleton n2) let modifies_buf_2 (#t:Type) (#t':Type) rid (b:buffer t) (b':buffer t') h h' = modifies_ref rid (to_set_2 (as_addr b) (as_addr b')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_3 (n1:nat) (n2:nat) (n3:nat) :Set.set nat = Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3) let modifies_buf_3 (#t:Type) (#t':Type) (#t'':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') h h' = modifies_ref rid (to_set_3 (as_addr b) (as_addr b') (as_addr b'')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb) ==> equal h bb h' bb /\ live h' bb) let to_set_4 (n1:nat) (n2:nat) (n3:nat) (n4:nat) :Set.set nat = Set.union (Set.union (Set.union (Set.singleton n1) (Set.singleton n2)) (Set.singleton n3)) (Set.singleton n4) let modifies_buf_4 (#t:Type) (#t':Type) (#t'':Type) (#t''':Type) rid (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') h h' = modifies_ref rid (to_set_4 (as_addr b) (as_addr b') (as_addr b'') (as_addr b''')) h h' /\ (forall (#tt:Type) (bb:buffer tt). (frameOf bb == rid /\ live h bb /\ disjoint b bb /\ disjoint b' bb /\ disjoint b'' bb /\ disjoint b''' bb) ==> equal h bb h' bb /\ live h' bb) (* General lemmas for the modifies_bufs clause *) let lemma_modifies_bufs_trans rid bufs h0 h1 h2 : Lemma (requires (modifies_bufs rid bufs h0 h1 /\ modifies_bufs rid bufs h1 h2)) (ensures (modifies_bufs rid bufs h0 h2)) [SMTPat (modifies_bufs rid bufs h0 h1); SMTPat (modifies_bufs rid bufs h1 h2)] = () let lemma_modifies_bufs_sub rid bufs subbufs h0 h1 : Lemma (requires (TSet.subset subbufs bufs /\ modifies_bufs rid subbufs h0 h1)) (ensures (modifies_bufs rid bufs h0 h1)) [SMTPat (modifies_bufs rid subbufs h0 h1); SMTPat (TSet.subset subbufs bufs)] = () val lemma_modifies_bufs_subset: #a:Type -> #a':Type -> h0:mem -> h1:mem -> bufs:TSet.set abuffer -> b:buffer a -> b':buffer a' -> Lemma (requires (disjoint_from_bufs b (bufs ++ (only b')) )) (ensures (disjoint_from_bufs b bufs)) [SMTPat (modifies_bufs (HS.get_tip h0) (bufs ++ (only b')) h0 h1); SMTPat (live h0 b)] let lemma_modifies_bufs_subset #a #a' h0 h1 bufs b b' = () val lemma_modifies_bufs_superset: #a:Type -> #a':Type -> h0:mem -> h1:mem -> bufs:TSet.set abuffer -> b:buffer a -> b':buffer a' -> Lemma (requires (b' `unused_in` h0 /\ live h0 b /\ disjoint_from_bufs b bufs)) (ensures (disjoint_from_bufs b (bufs ++ (only b')))) [SMTPat (modifies_bufs (HS.get_tip h0) bufs h0 h1); SMTPat (b' `unmapped_in` h0); SMTPat (live h0 b)] let lemma_modifies_bufs_superset #a #a' h0 h1 bufs b b' = () (* Specialized lemmas *) let modifies_trans_0_0 (rid:rid) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_0 rid h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_1_0 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_0_1 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_1_1 (#t:Type) (rid:rid) (b:buffer t) (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_1 rid b h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_1_1' (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_1 rid b' h1 h2)] = () let modifies_trans_2_0 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 rid h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_0 rid h1 h2)] = () let modifies_trans_2_1 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_2_1' (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b' b h0 h1 /\ modifies_buf_1 rid b h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b' b h0 h1); SMTPat (modifies_buf_1 rid b h1 h2)] = () let modifies_trans_0_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_0 rid h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_0 rid h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_1_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_1 rid b h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_1 rid b h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_2_2 (#t:Type) (#t':Type) (rid:rid) (b:buffer t) (b':buffer t') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_2 rid b b' h1 h2)) (ensures (modifies_buf_2 rid b b' h0 h2)) [SMTPat (modifies_buf_2 rid b b' h0 h1); SMTPat (modifies_buf_2 rid b b' h1 h2)] = () let modifies_trans_3_3 (#t #t' #t'':Type) (rid:rid) (b:buffer t) (b':buffer t') (b'':buffer t'') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_buf_3 rid b b' b'' h1 h2)) (ensures (modifies_buf_3 rid b b' b'' h0 h2)) [SMTPat (modifies_buf_3 rid b b' b'' h0 h1); SMTPat (modifies_buf_3 rid b b' b'' h1 h2)] = () let modifies_trans_4_4 (#t #t' #t'' #t''':Type) (rid:rid) (b:buffer t) (b':buffer t') (b'':buffer t'') (b''':buffer t''') (h0 h1 h2:mem) : Lemma (requires (modifies_buf_4 rid b b' b'' b''' h0 h1 /\ modifies_buf_4 rid b b' b'' b''' h1 h2)) (ensures (modifies_buf_4 rid b b' b'' b''' h0 h2)) [SMTPat (modifies_buf_4 rid b b' b'' b''' h0 h1); SMTPat (modifies_buf_4 rid b b' b'' b''' h1 h2)] = () (* TODO: complete with specialized versions of every general lemma *) (* Modifies clauses that do not change the shape of the HyperStack ((HS.get_tip h1) = (HS.get_tip h0)) *) (* NB: those clauses are made abstract in order to make verification faster // Lemmas follow to allow the programmer to make use of the real definition // of those predicates in a general setting *) let modifies_0 (h0 h1:mem) :Type0 = modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 (* This one is very generic: it says // * - some references have changed in the frame of b, but // * - among all buffers in this frame, b is the only one that changed. *) let modifies_1 (#a:Type) (b:buffer a) (h0 h1:mem) :Type0 = let rid = frameOf b in modifies_one rid h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 let modifies_2_1 (#a:Type) (b:buffer a) (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in ((rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 ))) let modifies_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= rid' /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 ))) let modifies_3 (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in let rid'' = frameOf b'' in ((rid == rid' /\ rid' == rid'' /\ modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid =!= rid' /\ rid' == rid'' /\ modifies_buf_2 rid' b' b'' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid == rid'' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b'' h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= rid'' /\ rid =!= rid'' /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton rid'')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1))) let modifies_3_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') (h0 h1:mem) :Type0 = HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid') (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= HS.get_tip h0 /\ rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1))) let modifies_region (rid:rid) (bufs:TSet.set abuffer) (h0 h1:mem) :Type0 = modifies_one rid h0 h1 /\ modifies_bufs rid bufs h0 h1 /\ HS.get_tip h0 == HS.get_tip h1 (* Lemmas introducing the 'modifies' predicates *) let lemma_intro_modifies_0 h0 h1 : Lemma (requires (modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) (ensures (modifies_0 h0 h1)) = () let lemma_intro_modifies_1 (#a:Type) (b:buffer a) h0 h1 : Lemma (requires (let rid = frameOf b in modifies_one rid h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) (ensures (modifies_1 b h0 h1)) = () let lemma_intro_modifies_2_1 (#a:Type) (b:buffer a) h0 h1 : Lemma (requires ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in ((rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 ))))) (ensures (modifies_2_1 b h0 h1)) = () let lemma_intro_modifies_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= rid' /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 ))))) (ensures (modifies_2 b b' h0 h1)) = () let lemma_intro_modifies_3 (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') h0 h1 : Lemma (requires ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in let rid'' = frameOf b'' in ((rid == rid' /\ rid' == rid'' /\ modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid =!= rid' /\ rid' == rid'' /\ modifies_buf_2 rid' b' b'' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid == rid'' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b'' h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= rid'' /\ rid =!= rid'' /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton rid'')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1))))) (ensures (modifies_3 b b' b'' h0 h1)) = () let lemma_intro_modifies_3_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid') (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= HS.get_tip h0 /\ rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1))))) (ensures (modifies_3_2 b b' h0 h1)) = () let lemma_intro_modifies_region (rid:rid) bufs h0 h1 : Lemma (requires (modifies_one rid h0 h1 /\ modifies_bufs rid bufs h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) (ensures (modifies_region rid bufs h0 h1)) = () (* Lemmas revealing the content of the specialized modifies clauses in order to // be able to generalize them if needs be. *) let lemma_reveal_modifies_0 h0 h1 : Lemma (requires (modifies_0 h0 h1)) (ensures (modifies_one (HS.get_tip h0) h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) = () let lemma_reveal_modifies_1 (#a:Type) (b:buffer a) h0 h1 : Lemma (requires (modifies_1 b h0 h1)) (ensures (let rid = frameOf b in modifies_one rid h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) = () let lemma_reveal_modifies_2_1 (#a:Type) (b:buffer a) h0 h1 : Lemma (requires (modifies_2_1 b h0 h1)) (ensures ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in ((rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 ))))) = () let lemma_reveal_modifies_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires (modifies_2 b b' h0 h1)) (ensures ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid =!= rid' /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 )) ))) = () let lemma_reveal_modifies_3 (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') h0 h1 : Lemma (requires (modifies_3 b b' b'' h0 h1)) (ensures ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in let rid'' = frameOf b'' in ((rid == rid' /\ rid' == rid'' /\ modifies_buf_3 rid b b' b'' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid =!= rid' /\ rid' == rid'' /\ modifies_buf_2 rid' b' b'' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid'')) h0 h1 ) \/ (rid == rid'' /\ rid' =!= rid'' /\ modifies_buf_2 rid b b'' h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton rid')) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= rid'' /\ rid =!= rid'' /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton rid'')) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid'' b'' h0 h1)) ))) = () let lemma_reveal_modifies_3_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires (modifies_3_2 b b' h0 h1)) (ensures ( HS.get_tip h0 == HS.get_tip h1 /\ (let rid = frameOf b in let rid' = frameOf b' in ((rid == rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_one rid h0 h1) \/ (rid == rid' /\ rid' =!= HS.get_tip h0 /\ modifies_buf_2 rid b b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid == HS.get_tip h0 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ HS.modifies (Set.union (Set.singleton rid') (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' == HS.get_tip h0 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ HS.modifies (Set.union (Set.singleton rid) (Set.singleton (HS.get_tip h0))) h0 h1 ) \/ (rid =!= rid' /\ rid' =!= HS.get_tip h0 /\ rid =!= HS.get_tip h0 /\ HS.modifies (Set.union (Set.union (Set.singleton rid) (Set.singleton rid')) (Set.singleton (HS.get_tip h0))) h0 h1 /\ modifies_buf_1 rid b h0 h1 /\ modifies_buf_1 rid' b' h0 h1 /\ modifies_buf_0 (HS.get_tip h0) h0 h1)) ))) = () let lemma_reveal_modifies_region (rid:rid) bufs h0 h1 : Lemma (requires (modifies_region rid bufs h0 h1)) (ensures (modifies_one rid h0 h1 /\ modifies_bufs rid bufs h0 h1 /\ HS.get_tip h0 == HS.get_tip h1)) = () #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0" (* Stack effect specific lemmas *) let lemma_stack_1 (#a:Type) (b:buffer a) h0 h1 h2 h3 : Lemma (requires (live h0 b /\ fresh_frame h0 h1 /\ modifies_1 b h1 h2 /\ popped h2 h3)) (ensures (modifies_buf_1 (frameOf b) b h0 h3)) [SMTPat (modifies_1 b h1 h2); SMTPat (fresh_frame h0 h1); SMTPat (popped h2 h3)] = () let lemma_stack_2 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 h3 : Lemma (requires (live h0 b /\ live h0 b' /\ fresh_frame h0 h1 /\ modifies_2 b b' h1 h2 /\ popped h2 h3)) (ensures (modifies_2 b b' h0 h3)) [SMTPat (modifies_2 b b' h1 h2); SMTPat (fresh_frame h0 h1); SMTPat (popped h2 h3)] = () (* Specialized modifies clauses lemmas + associated SMTPatterns. Those are critical for // verification as the specialized modifies clauses are abstract from outside the // module *) (** Commutativity lemmas *) let lemma_modifies_2_comm (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires True) (ensures (modifies_2 b b' h0 h1 <==> modifies_2 b' b h0 h1)) [SMTPat (modifies_2 b b' h0 h1)] = () let lemma_modifies_3_2_comm (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 : Lemma (requires True) (ensures (modifies_3_2 b b' h0 h1 <==> modifies_3_2 b' b h0 h1)) [SMTPat (modifies_3_2 b b' h0 h1)] = () (* TODO: add commutativity lemmas for modifies_3 *) #reset-options "--z3rlimit 20" (** Transitivity lemmas *) let lemma_modifies_0_trans h0 h1 h2 : Lemma (requires (modifies_0 h0 h1 /\ modifies_0 h1 h2)) (ensures (modifies_0 h0 h2)) [SMTPat (modifies_0 h0 h1); SMTPat (modifies_0 h1 h2)] = () let lemma_modifies_1_trans (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (modifies_1 b h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_1 b h1 h2)] = () let lemma_modifies_2_1_trans (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (modifies_2_1 b h0 h1 /\ modifies_2_1 b h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_2_1 b h0 h1); SMTPat (modifies_2_1 b h1 h2)] = () let lemma_modifies_2_trans (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (modifies_2 b b' h0 h1 /\ modifies_2 b b' h1 h2)) (ensures (modifies_2 b b' h0 h2)) (* TODO: Make the following work and merge with the following lemma *) (* [SMTPatOr [ *) (* [SMTPat (modifies_2 b b' h0 h1); *) (* SMTPat (modifies_2 b' b h0 h1)]]; *) (* SMTPat (modifies_2 b' b h1 h2)] *) [SMTPat (modifies_2 b b' h0 h1); SMTPat (modifies_2 b b' h1 h2)] = () let lemma_modifies_2_trans' (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (modifies_2 b b' h0 h1 /\ modifies_2 b b' h1 h2)) (ensures (modifies_2 b b' h0 h2)) [SMTPat (modifies_2 b' b h0 h1); SMTPat (modifies_2 b b' h1 h2)] = () #reset-options "--z3rlimit 40" let lemma_modifies_3_trans (#a:Type) (#a':Type) (#a'':Type) (b:buffer a) (b':buffer a') (b'':buffer a'') h0 h1 h2 : Lemma (requires (modifies_3 b b' b'' h0 h1 /\ modifies_3 b b' b'' h1 h2)) (ensures (modifies_3 b b' b'' h0 h2)) (* TODO: add the appropriate SMTPatOr patterns so as not to rewrite X times the same lemma *) [SMTPat (modifies_3 b b' b'' h0 h1); SMTPat (modifies_3 b b' b'' h1 h2)] = () #reset-options "--z3rlimit 200" let lemma_modifies_3_2_trans (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (modifies_3_2 b b' h0 h1 /\ modifies_3_2 b b' h1 h2)) (ensures (modifies_3_2 b b' h0 h2)) [SMTPat (modifies_3_2 b b' h0 h1); SMTPat (modifies_3_2 b b' h1 h2)] = () let lemma_modifies_3_2_trans' (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (modifies_3_2 b' b h0 h1 /\ modifies_3_2 b b' h1 h2)) (ensures (modifies_3_2 b b' h0 h2)) [SMTPat (modifies_3_2 b' b h0 h1); SMTPat (modifies_3_2 b b' h1 h2)] = () #reset-options "--z3rlimit 20" (* Specific modifies clause lemmas *) val lemma_modifies_0_0: h0:mem -> h1:mem -> h2:mem -> Lemma (requires (modifies_0 h0 h1 /\ modifies_0 h1 h2)) (ensures (modifies_0 h0 h2)) [SMTPat (modifies_0 h0 h1); SMTPat (modifies_0 h1 h2)] let lemma_modifies_0_0 h0 h1 h2 = () #reset-options "--z3rlimit 20 --initial_fuel 0 --max_fuel 0" let lemma_modifies_1_0 (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_1 b h0 h1 /\ modifies_0 h1 h2)) (ensures (live h2 b /\ modifies_2_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_0 h1 h2)] = () let lemma_modifies_0_1 (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_0 h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_0 h0 h1); SMTPat (modifies_1 b h1 h2)] = () let lemma_modifies_0_1' (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (b `unused_in` h0 /\ modifies_0 h0 h1 /\ live h1 b /\ modifies_1 b h1 h2)) (ensures (modifies_0 h0 h2)) [SMTPat (modifies_0 h0 h1); SMTPat (modifies_1 b h1 h2)] = () #reset-options "--z3rlimit 100 --initial_fuel 0 --max_fuel 0" let lemma_modifies_1_1 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_1 b h0 h1 /\ modifies_1 b' h1 h2)) (ensures (modifies_2 b b' h0 h2 /\ modifies_2 b' b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_1 b' h1 h2)] = if frameOf b = frameOf b' then modifies_trans_1_1' (frameOf b) b b' h0 h1 h2 else () #reset-options "--z3rlimit 200 --initial_fuel 0 --max_fuel 0" let lemma_modifies_0_2 (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ b' `unused_in` h0 /\ modifies_0 h0 h1 /\ live h1 b' /\ modifies_2 b b' h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_2 b b' h1 h2); SMTPat (modifies_0 h0 h1)] = () let lemma_modifies_0_2' (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ b' `unused_in` h0 /\ modifies_0 h0 h1 /\ live h1 b' /\ modifies_2 b' b h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_2 b' b h1 h2); SMTPat (modifies_0 h0 h1)] = () let lemma_modifies_1_2 (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_1 b h0 h1 /\ b' `unused_in` h0 /\ live h1 b' /\ modifies_2 b b' h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_2 b b' h1 h2)] = () let lemma_modifies_1_2' (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_1 b h0 h1 /\ b' `unused_in` h0 /\ live h1 b' /\ modifies_2 b' b h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_2 b' b h1 h2)] = () let lemma_modifies_1_2'' (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_1 b h0 h1 /\ modifies_2 b b' h1 h2)) (ensures (modifies_2 b b' h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_2 b b' h1 h2)] = () let lemma_modifies_1_2''' (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_1 b h0 h1 /\ modifies_2 b' b h1 h2)) (ensures (modifies_2 b' b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_2 b' b h1 h2)] = () let lemma_modifies_1_1_prime (#t:Type) (#t':Type) (b:buffer t) (b':buffer t') h0 h1 h2 : Lemma (requires (live h0 b /\ modifies_1 b h0 h1 /\ b' `unused_in` h0 /\ live h1 b' /\ modifies_1 b' h1 h2)) (ensures (modifies_2_1 b h0 h2)) [SMTPat (modifies_1 b h0 h1); SMTPat (modifies_1 b' h1 h2)] = () let lemma_modifies_2_1 (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_2 b b' h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_2 b b' h0 h2)) [SMTPat (modifies_2 b b' h0 h1); SMTPat (modifies_1 b h1 h2)] = () let lemma_modifies_2_1' (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_2 b' b h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_2 b' b h0 h2)) [SMTPat (modifies_2 b' b h0 h1); SMTPat (modifies_1 b h1 h2)] = () let lemma_modifies_2_1'' (#a:Type) (#a':Type) (b:buffer a) (b':buffer a') h0 h1 h2 : Lemma (requires (live h0 b /\ live h0 b' /\ modifies_2_1 b h0 h1 /\ modifies_1 b' h1 h2)) (ensures (modifies_3_2 b b' h0 h2)) [SMTPat (modifies_2_1 b h0 h1); SMTPat (modifies_1 b' h1 h2)] = () (* TODO: lemmas for modifies_3 *) let lemma_modifies_0_unalloc (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (b `unused_in` h0 /\ frameOf b == HS.get_tip h0 /\ modifies_0 h0 h1 /\ modifies_1 b h1 h2)) (ensures (modifies_0 h0 h2)) = () let lemma_modifies_none_1_trans (#a:Type) (b:buffer a) h0 h1 h2 : Lemma (requires (modifies_none h0 h1 /\ live h0 b /\ modifies_1 b h1 h2)) (ensures (modifies_1 b h0 h2)) = () let lemma_modifies_0_none_trans h0 h1 h2 : Lemma (requires (modifies_0 h0 h1 /\ modifies_none h1 h2)) (ensures (modifies_0 h0 h2)) = () #reset-options "--initial_fuel 0 --max_fuel 0" (** Concrete getters and setters *) val create: #a:Type -> init:a -> len:UInt32.t -> StackInline (buffer a) (requires (fun h -> True)) (ensures (fun (h0:mem) b h1 -> b `unused_in` h0 /\ live h1 b /\ idx b == 0 /\ length b == v len /\ frameOf b == HS.get_tip h0 /\ Map.domain (HS.get_hmap h1) == Map.domain (HS.get_hmap h0) /\ modifies_0 h0 h1 /\ as_seq h1 b == Seq.create (v len) init)) let create #a init len = let content: reference (lseq a (v len)) = salloc (Seq.create (v len) init) in let b = MkBuffer len content 0ul len in let h = HST.get() in assert (Seq.equal (as_seq h b) (sel h b)); b #reset-options "--initial_fuel 0 --max_fuel 0" unfold let p (#a:Type0) (init:list a) : GTot Type0 = normalize (0 < FStar.List.Tot.length init) /\ normalize (FStar.List.Tot.length init <= UInt.max_int 32) unfold let q (#a:Type0) (len:nat) (buf:buffer a) : GTot Type0 = normalize (length buf == len) (** Concrete getters and setters *) val createL: #a:Type0 -> init:list a -> StackInline (buffer a) (requires (fun h -> p #a init)) (ensures (fun (h0:mem) b h1 -> let len = FStar.List.Tot.length init in len > 0 /\ b `unused_in` h0 /\ live h1 b /\ idx b == 0 /\ length b == len /\ frameOf b == (HS.get_tip h0) /\ Map.domain (HS.get_hmap h1) == Map.domain (HS.get_hmap h0) /\ modifies_0 h0 h1 /\ as_seq h1 b == Seq.seq_of_list init /\ q #a len b)) #set-options "--initial_fuel 1 --max_fuel 1" //the normalize_term (length init) in the pre-condition will be unfolded //whereas the L.length init below will not let createL #a init = let len = UInt32.uint_to_t (FStar.List.Tot.length init) in let s = Seq.seq_of_list init in let content: reference (lseq a (v len)) = salloc (Seq.seq_of_list init) in let b = MkBuffer len content 0ul len in let h = HST.get() in assert (Seq.equal (as_seq h b) (sel h b)); b #reset-options "--initial_fuel 0 --max_fuel 0" let lemma_upd (#a:Type) (h:mem) (x:reference a{live_region h (HS.frameOf x)}) (v:a) : Lemma (requires True) (ensures (Map.domain (HS.get_hmap h) == Map.domain (HS.get_hmap (upd h x v)))) = let m = HS.get_hmap h in let m' = Map.upd m (HS.frameOf x) (Heap.upd (Map.sel m (HS.frameOf x)) (HS.as_ref x) v) in Set.lemma_equal_intro (Map.domain m) (Map.domain m') unfold let rcreate_post_common (#a:Type) (r:rid) (init:a) (len:UInt32.t) (b:buffer a) (h0 h1:mem) :Type0 = b `unused_in` h0 /\ live h1 b /\ idx b == 0 /\ length b == v len /\ Map.domain (HS.get_hmap h1) == Map.domain (HS.get_hmap h0) /\ HS.get_tip h1 == HS.get_tip h0 /\ modifies (Set.singleton r) h0 h1 /\ modifies_ref r Set.empty h0 h1 /\ as_seq h1 b == Seq.create (v len) init private let rcreate_common (#a:Type) (r:rid) (init:a) (len:UInt32.t) (mm:bool) :ST (buffer a) (requires (fun h0 -> is_eternal_region r)) (ensures (fun h0 b h1 -> rcreate_post_common r init len b h0 h1 /\ is_mm b.content == mm)) = let h0 = HST.get() in let s = Seq.create (v len) init in let content: reference (lseq a (v len)) = if mm then ralloc_mm r s else ralloc r s in let b = MkBuffer len content 0ul len in let h1 = HST.get() in assert (Seq.equal (as_seq h1 b) (sel h1 b)); lemma_upd h0 content s; b (** This function allocates a buffer in an "eternal" region, i.e. a region where memory is // * automatically-managed. One does not need to call rfree on such a buffer. It // * translates to C as a call to malloc and assumes a conservative garbage // * collector is running. *) val rcreate: #a:Type -> r:rid -> init:a -> len:UInt32.t -> ST (buffer a) (requires (fun h -> is_eternal_region r)) (ensures (fun (h0:mem) b h1 -> rcreate_post_common r init len b h0 h1 /\ ~(is_mm b.content))) let rcreate #a r init len = rcreate_common r init len false (** This predicate tells whether a buffer can be `rfree`d. The only way to produce it should be `rcreate_mm`, and the only way to consume it should be `rfree.` Rationale: a buffer can be `rfree`d
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Heap.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "FStar.Buffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "Int32" }, { "abbrev": false, "full_module": "FStar.UInt32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "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": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Buffer.buffer a -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "FStar.Buffer.buffer", "Prims.l_and", "Prims.b2t", "FStar.Monotonic.HyperStack.is_mm", "FStar.Buffer.lseq", "FStar.UInt32.v", "FStar.Buffer.__proj__MkBuffer__item__max_length", "FStar.Heap.trivial_preorder", "FStar.Buffer.__proj__MkBuffer__item__content", "FStar.HyperStack.ST.is_eternal_region", "FStar.Buffer.frameOf", "Prims.eq2", "Prims.int", "FStar.Buffer.idx" ]
[]
false
false
false
false
true
let freeable (#a: Type) (b: buffer a) : GTot Type0 =
is_mm b.content /\ is_eternal_region (frameOf b) /\ idx b == 0
false